1/* 2 * init::start will pass stacktop to setup() as the base of free memory. 3 * setup() will then move the FDT and initrd to that base before calling 4 * mem_init(). With those movements and this linker script, we'll end up 5 * having the following memory layout: 6 * 7 * +----------------------+ <-- top of physical memory 8 * | | 9 * ~ ~ 10 * | | 11 * +----------------------+ <-- top of initrd 12 * | | 13 * +----------------------+ <-- top of FDT 14 * | | 15 * +----------------------+ <-- top of cpu0's stack 16 * | | 17 * +----------------------+ <-- top of text/data/bss sections 18 * | | 19 * | | 20 * +----------------------+ <-- load address 21 * | | 22 * +----------------------+ <-- physical address 0x0 23 */ 24 25SECTIONS 26{ 27 PROVIDE(_text = .); 28 .text : { *(.init) *(.text) *(.text.*) } 29 . = ALIGN(64K); 30 PROVIDE(etext = .); 31 32 PROVIDE(reloc_start = .); 33 .rela.dyn : { *(.rela.dyn) } 34 PROVIDE(reloc_end = .); 35 .dynsym : { *(.dynsym) } 36 .dynstr : { *(.dynstr) } 37 .hash : { *(.hash) } 38 .gnu.hash : { *(.gnu.hash) } 39 .got : { *(.got) *(.got.plt) } 40 .eh_frame : { *(.eh_frame) } 41 42 .rodata : { *(.rodata*) } 43 .data : { *(.data) } 44 . = ALIGN(16); 45 PROVIDE(bss = .); 46 .bss : { *(.bss) } 47 . = ALIGN(16); 48 PROVIDE(ebss = .); 49 . = ALIGN(64K); 50 PROVIDE(edata = .); 51 52 /* 53 * stack depth is 16K for arm and PAGE_SIZE for arm64, see THREAD_SIZE 54 * sp must be 16 byte aligned for arm64, and 8 byte aligned for arm 55 * sp must always be strictly less than the true stacktop 56 */ 57 . += 64K; 58 . = ALIGN(64K); 59 PROVIDE(stackptr = . - 16); 60 PROVIDE(stacktop = .); 61 62 /DISCARD/ : { 63 *(.note*) 64 *(.interp) 65 *(.comment) 66 *(.dynamic) 67 } 68} 69 70ENTRY(start) 71