#memory #memory-block #ld #bootloader #build #gnu #offset

build ld-memory

Helper crate to programmatically create GNU ld MEMORY blocks

10 releases

0.2.9 Jun 29, 2023
0.2.7 Jun 2, 2023
0.2.3 May 30, 2023
0.2.2 Jul 5, 2021
0.1.0 Mar 16, 2021

#97 in Build Utils

Download history 30/week @ 2024-06-02 105/week @ 2024-06-09 122/week @ 2024-06-16 140/week @ 2024-06-23 248/week @ 2024-06-30 259/week @ 2024-07-07 128/week @ 2024-07-14 1/week @ 2024-07-21 59/week @ 2024-07-28 165/week @ 2024-08-04 21/week @ 2024-08-11 170/week @ 2024-08-18 176/week @ 2024-08-25 189/week @ 2024-09-01 506/week @ 2024-09-08 415/week @ 2024-09-15

1,289 downloads per month
Used in ld-memory-cli

MIT/Apache

13KB
252 lines

ld-memory

This crate allows creating MEMORY blocks programmatically.

It is supposed to be used in build.rs of crates that now ship memory.x files, which don't easily allow specifying offsets and limits as needed for e.g., a bootloader taking space in front of the application binary.

Example:

This code:

use ld_memory::{Memory, MemorySection};

pub fn main() {
    let memory = Memory::new()
        .add_section(MemorySection::new("FLASH", 0, 0x40000))
        .add_section(MemorySection::new("RAM", 0x20000000, 0x10000));

    println!("{}", memory.to_string());
}

... will print this:

MEMORY
{
    FLASH : ORIGIN = 0x00000000, LENGTH = 262144
    RAM : ORIGIN = 0x20000000, LENGTH = 65536
}

License

This work is licensed under either of

at your option.

No runtime deps

Features