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 25PHDRS 26{ 27 text PT_LOAD FLAGS(5); 28 data PT_LOAD FLAGS(6); 29} 30 31SECTIONS 32{ 33 PROVIDE(ImageBase = .); 34 PROVIDE(_text = .); 35 .text : { *(.init) *(.text) *(.text.*) } :text 36 . = ALIGN(4K); 37 PROVIDE(_etext = .); 38 39 PROVIDE(reloc_start = .); 40 .rela.dyn : { *(.rela.dyn) } 41 PROVIDE(reloc_end = .); 42 .dynsym : { *(.dynsym) } 43 .dynstr : { *(.dynstr) } 44 .hash : { *(.hash) } 45 .gnu.hash : { *(.gnu.hash) } 46 .got : { *(.got) *(.got.plt) } 47 .eh_frame : { *(.eh_frame) } 48 49 .rodata : { *(.rodata*) } :data 50 .data : { *(.data) } :data 51 . = ALIGN(16); 52 PROVIDE(bss = .); 53 .bss : { *(.bss) } 54 . = ALIGN(16); 55 PROVIDE(ebss = .); 56 . = ALIGN(4K); 57 PROVIDE(edata = .); 58 59 /* 60 * stack depth is 8K and sp must be 16 byte aligned 61 * sp must always be strictly less than the true stacktop 62 */ 63 . += 12K; 64 . = ALIGN(4K); 65 PROVIDE(stackptr = . - 16); 66 PROVIDE(stacktop = .); 67 68 /DISCARD/ : { 69 *(.note*) 70 *(.interp) 71 *(.comment) 72 *(.dynamic) 73 } 74} 75 76ENTRY(start) 77