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