15a2a7371SAndrew Jones/* 25a2a7371SAndrew Jones * init::start will pass stacktop to setup() as the base of free memory. 35a2a7371SAndrew Jones * setup() will then move the FDT and initrd to that base before calling 45a2a7371SAndrew Jones * mem_init(). With those movements and this linker script, we'll end up 55a2a7371SAndrew Jones * having the following memory layout: 65a2a7371SAndrew Jones * 75a2a7371SAndrew Jones * +----------------------+ <-- top of physical memory 85a2a7371SAndrew Jones * | | 95a2a7371SAndrew Jones * ~ ~ 105a2a7371SAndrew Jones * | | 115a2a7371SAndrew Jones * +----------------------+ <-- top of initrd 125a2a7371SAndrew Jones * | | 135a2a7371SAndrew Jones * +----------------------+ <-- top of FDT 145a2a7371SAndrew Jones * | | 155a2a7371SAndrew Jones * +----------------------+ <-- top of cpu0's stack 165a2a7371SAndrew Jones * | | 175a2a7371SAndrew Jones * +----------------------+ <-- top of text/data/bss sections 185a2a7371SAndrew Jones * | | 195a2a7371SAndrew Jones * | | 205a2a7371SAndrew Jones * +----------------------+ <-- load address 215a2a7371SAndrew Jones * | | 225a2a7371SAndrew Jones * +----------------------+ <-- physical address 0x0 235a2a7371SAndrew Jones */ 245e61cba0SAndrew Jones 25*59a797f4SThomas HuthPHDRS 26*59a797f4SThomas Huth{ 27*59a797f4SThomas Huth text PT_LOAD FLAGS(5); 28*59a797f4SThomas Huth data PT_LOAD FLAGS(6); 29*59a797f4SThomas Huth} 30*59a797f4SThomas Huth 315e61cba0SAndrew JonesSECTIONS 325e61cba0SAndrew Jones{ 33a09aa3fbSAndrew Jones PROVIDE(_text = .); 34*59a797f4SThomas Huth .text : { *(.init) *(.text) *(.text.*) } :text 35b26ded10SAndrew Jones . = ALIGN(64K); 362b9c908eSAndrew Jones PROVIDE(_etext = .); 37f6416021SAndrew Jones 38f6416021SAndrew Jones PROVIDE(reloc_start = .); 39f6416021SAndrew Jones .rela.dyn : { *(.rela.dyn) } 40f6416021SAndrew Jones PROVIDE(reloc_end = .); 41f6416021SAndrew Jones .dynsym : { *(.dynsym) } 42f6416021SAndrew Jones .dynstr : { *(.dynstr) } 43f6416021SAndrew Jones .hash : { *(.hash) } 44f6416021SAndrew Jones .gnu.hash : { *(.gnu.hash) } 45f6416021SAndrew Jones .got : { *(.got) *(.got.plt) } 46f6416021SAndrew Jones .eh_frame : { *(.eh_frame) } 47f6416021SAndrew Jones 48*59a797f4SThomas Huth .rodata : { *(.rodata*) } :data 49*59a797f4SThomas Huth .data : { *(.data) } :data 50993c37beSAndrew Jones . = ALIGN(16); 51993c37beSAndrew Jones PROVIDE(bss = .); 525e61cba0SAndrew Jones .bss : { *(.bss) } 53993c37beSAndrew Jones . = ALIGN(16); 54993c37beSAndrew Jones PROVIDE(ebss = .); 55b26ded10SAndrew Jones . = ALIGN(64K); 56f6416021SAndrew Jones PROVIDE(edata = .); 57f6416021SAndrew Jones 581693644dSAndrew Jones /* 59ad14f089SAndrew Jones * stack depth is 16K for arm and PAGE_SIZE for arm64, see THREAD_SIZE 601693644dSAndrew Jones * sp must be 16 byte aligned for arm64, and 8 byte aligned for arm 611693644dSAndrew Jones * sp must always be strictly less than the true stacktop 621693644dSAndrew Jones */ 63f6416021SAndrew Jones . += 64K; 64f6416021SAndrew Jones . = ALIGN(64K); 65f6416021SAndrew Jones PROVIDE(stackptr = . - 16); 66f6416021SAndrew Jones PROVIDE(stacktop = .); 67f6416021SAndrew Jones 68f6416021SAndrew Jones /DISCARD/ : { 69f6416021SAndrew Jones *(.note*) 70f6416021SAndrew Jones *(.interp) 71f6416021SAndrew Jones *(.comment) 72f6416021SAndrew Jones *(.dynamic) 73f6416021SAndrew Jones } 745e61cba0SAndrew Jones} 755e61cba0SAndrew Jones 765e61cba0SAndrew JonesENTRY(start) 77