RustForge

foundry

Foundry OS: the operating system built on the Rustbelt kernel

foundry / link.ld
1042 bytes ยท raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* Linker script for user programs: a static executable loaded at 4 MiB into
   user space (USER_START = 0x80_0000_0000, see src/memory.rs). Each part
   starts on its own page so it can get its own page permissions:
   code = read+execute, rodata = read-only, data/bss = read+write.
   The `large` code model (see build.rs) names its sections .ltext, .lrodata,
   .ldata and .lbss, so those must be listed too -- otherwise the linker
   places them wherever it likes (e.g. code in a non-executable segment). */
ENTRY(_start)

PHDRS {
    text   PT_LOAD FLAGS(5);  /* R-X */
    rodata PT_LOAD FLAGS(4);  /* R-- */
    data   PT_LOAD FLAGS(6);  /* RW- */
}

SECTIONS {
    . = 0x8000400000;
    .text   : ALIGN(4K) { *(.text .text.* .ltext .ltext.*) } :text
    .rodata : ALIGN(4K) { *(.rodata .rodata.* .lrodata .lrodata.*) } :rodata
    .data   : ALIGN(4K) { *(.data .data.* .ldata .ldata.* .got .got.*) } :data
    .bss    : ALIGN(8)  { *(.bss .bss.* .lbss .lbss.* COMMON) } :data
    /DISCARD/ : { *(.comment) *(.eh_frame*) *(.note*) }
}