ld-memory-cli

Crates.iold-memory-cli
lib.rsld-memory-cli
version0.2.8
sourcesrc
created_at2023-06-01 19:37:38.463322
updated_at2023-06-29 13:16:26.090375
descriptiontool to create .ld MEMORY sections via cli
homepage
repositoryhttps://github.com/kaspar030/ld-memory
max_upload_size
id880086
size8,339
smithy-rs-server (github:awslabs:smithy-rs-server)

documentation

README

About

This CLI tool allows creating GNU ld linker script memory sections via command line.

Installation

cargo install ld-memory-cli

Usage

ld-memory is supposed to be hooked into your build system. Given the right arguments, it will output a snippet that can be used as part of a GNU ld linker script.

Example:

ld-memory --section rom:0x0:1024K

... outputs

_rom_start = 0x0;
_rom_length = 0x100000;

MEMORY
{
    rom : ORIGIN = 0x0, LENGTH = 0x100000
}

An offset can be specified, which will be added to ORIGIN and subtracted from LENGTH:

❯ ld-memory --section rom:0x0:1024K:128
_rom_start = 0x80;
_rom_length = 0xFFF80;

MEMORY
{
    rom : ORIGIN = 0x80, LENGTH = 0xFFF80
}

Empty field counts as "0". Simple arithmetic is allowed.

❯ ld-memory --section rom:0x0:1024K:128 --section empty:: --section other:0x0+128K:1K+7K
_rom_start = 0x80;
_rom_length = 0xFFF80;
_empty_start = 0x0;
_empty_length = 0x0;
_other_start = 0x20000;
_other_length = 0x2000;

MEMORY
{
    rom : ORIGIN = 0x80, LENGTH = 0xFFF80
    empty : ORIGIN = 0x0, LENGTH = 0x0
    other : ORIGIN = 0x20000, LENGTH = 0x2000
}
Commit count: 37

cargo fmt