1*dc6a7fd2Sgarbled/* $NetBSD: ldscript,v 1.1 2008/02/13 20:11:38 garbled Exp $ */ 2*dc6a7fd2Sgarbled 3*dc6a7fd2Sgarbled/* This only differs from the stock one by the addition of the text name 4*dc6a7fd2Sgarbled and the addition of the PHDRS section. 5*dc6a7fd2Sgarbled*/ 6*dc6a7fd2Sgarbled/* Script for -N: mix text and data on same page; don't align data */ 7*dc6a7fd2SgarbledOUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", 8*dc6a7fd2Sgarbled "elf32-powerpc") 9*dc6a7fd2SgarbledOUTPUT_ARCH(powerpc:common) 10*dc6a7fd2SgarbledENTRY(_start) 11*dc6a7fd2SgarbledSEARCH_DIR("/usr/src/tools/ppc-hack/powerpc--netbsd/lib"); 12*dc6a7fd2Sgarbled/* Do we need any of these for elf? 13*dc6a7fd2Sgarbled __DYNAMIC = 0; */ 14*dc6a7fd2SgarbledPROVIDE (__stack = 0); PROVIDE (___stack = 0); 15*dc6a7fd2SgarbledPHDRS 16*dc6a7fd2Sgarbled{ 17*dc6a7fd2Sgarbled/* headers PT_PHDR PHDRS ;*/ 18*dc6a7fd2Sgarbled text PT_LOAD; 19*dc6a7fd2Sgarbled text PT_NOTE; 20*dc6a7fd2Sgarbled} 21*dc6a7fd2SgarbledSECTIONS 22*dc6a7fd2Sgarbled{ 23*dc6a7fd2Sgarbled /* Read-only sections, merged into text segment: */ 24*dc6a7fd2Sgarbled PROVIDE (__executable_start = 0x0); . = 0x0 + SIZEOF_HEADERS; 25*dc6a7fd2Sgarbled .interp : { *(.interp) } 26*dc6a7fd2Sgarbled .hash : { *(.hash) } 27*dc6a7fd2Sgarbled .dynsym : { *(.dynsym) } 28*dc6a7fd2Sgarbled .dynstr : { *(.dynstr) } 29*dc6a7fd2Sgarbled .gnu.version : { *(.gnu.version) } 30*dc6a7fd2Sgarbled .gnu.version_d : { *(.gnu.version_d) } 31*dc6a7fd2Sgarbled .gnu.version_r : { *(.gnu.version_r) } 32*dc6a7fd2Sgarbled .rel.init : { *(.rel.init) } 33*dc6a7fd2Sgarbled .rela.init : { *(.rela.init) } 34*dc6a7fd2Sgarbled .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) } 35*dc6a7fd2Sgarbled .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } 36*dc6a7fd2Sgarbled .rel.fini : { *(.rel.fini) } 37*dc6a7fd2Sgarbled .rela.fini : { *(.rela.fini) } 38*dc6a7fd2Sgarbled .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) } 39*dc6a7fd2Sgarbled .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } 40*dc6a7fd2Sgarbled .rel.data.rel.ro : { *(.rel.data.rel.ro*) } 41*dc6a7fd2Sgarbled .rela.data.rel.ro : { *(.rel.data.rel.ro*) } 42*dc6a7fd2Sgarbled .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) } 43*dc6a7fd2Sgarbled .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } 44*dc6a7fd2Sgarbled .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) } 45*dc6a7fd2Sgarbled .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) } 46*dc6a7fd2Sgarbled .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) } 47*dc6a7fd2Sgarbled .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) } 48*dc6a7fd2Sgarbled .rel.ctors : { *(.rel.ctors) } 49*dc6a7fd2Sgarbled .rela.ctors : { *(.rela.ctors) } 50*dc6a7fd2Sgarbled .rel.dtors : { *(.rel.dtors) } 51*dc6a7fd2Sgarbled .rela.dtors : { *(.rela.dtors) } 52*dc6a7fd2Sgarbled .rel.got : { *(.rel.got) } 53*dc6a7fd2Sgarbled .rela.got : { *(.rela.got) } 54*dc6a7fd2Sgarbled .rela.got1 : { *(.rela.got1) } 55*dc6a7fd2Sgarbled .rela.got2 : { *(.rela.got2) } 56*dc6a7fd2Sgarbled .rel.sdata : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) } 57*dc6a7fd2Sgarbled .rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) } 58*dc6a7fd2Sgarbled .rel.sbss : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) } 59*dc6a7fd2Sgarbled .rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) } 60*dc6a7fd2Sgarbled .rel.sdata2 : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) } 61*dc6a7fd2Sgarbled .rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) } 62*dc6a7fd2Sgarbled .rel.sbss2 : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) } 63*dc6a7fd2Sgarbled .rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) } 64*dc6a7fd2Sgarbled .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } 65*dc6a7fd2Sgarbled .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } 66*dc6a7fd2Sgarbled .rel.plt : { *(.rel.plt) } 67*dc6a7fd2Sgarbled .rela.plt : { *(.rela.plt) } 68*dc6a7fd2Sgarbled .init : 69*dc6a7fd2Sgarbled { 70*dc6a7fd2Sgarbled KEEP (*(.init)) 71*dc6a7fd2Sgarbled } =0 72*dc6a7fd2Sgarbled .text : 73*dc6a7fd2Sgarbled { 74*dc6a7fd2Sgarbled *(.text .stub .text.* .gnu.linkonce.t.*) 75*dc6a7fd2Sgarbled KEEP (*(.text.*personality*)) 76*dc6a7fd2Sgarbled /* .gnu.warning sections are handled specially by elf32.em. */ 77*dc6a7fd2Sgarbled *(.gnu.warning) 78*dc6a7fd2Sgarbled } :text 79*dc6a7fd2Sgarbled .fini : 80*dc6a7fd2Sgarbled { 81*dc6a7fd2Sgarbled KEEP (*(.fini)) 82*dc6a7fd2Sgarbled } =0 83*dc6a7fd2Sgarbled PROVIDE (__etext = .); 84*dc6a7fd2Sgarbled PROVIDE (_etext = .); 85*dc6a7fd2Sgarbled PROVIDE (etext = .); 86*dc6a7fd2Sgarbled .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } 87*dc6a7fd2Sgarbled .rodata1 : { *(.rodata1) } 88*dc6a7fd2Sgarbled .sdata2 : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) } 89*dc6a7fd2Sgarbled .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } 90*dc6a7fd2Sgarbled .eh_frame_hdr : { *(.eh_frame_hdr) } 91*dc6a7fd2Sgarbled .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } 92*dc6a7fd2Sgarbled .gcc_except_table : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) } 93*dc6a7fd2Sgarbled /* Adjust the address for the data segment. We want to adjust up to 94*dc6a7fd2Sgarbled the same address within the page on the next page up. */ 95*dc6a7fd2Sgarbled . = .; 96*dc6a7fd2Sgarbled /* Exception handling */ 97*dc6a7fd2Sgarbled .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } 98*dc6a7fd2Sgarbled .gcc_except_table : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) } 99*dc6a7fd2Sgarbled /* Thread Local Storage sections */ 100*dc6a7fd2Sgarbled .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } 101*dc6a7fd2Sgarbled .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 102*dc6a7fd2Sgarbled /* Ensure the __preinit_array_start label is properly aligned. We 103*dc6a7fd2Sgarbled could instead move the label definition inside the section, but 104*dc6a7fd2Sgarbled the linker would then create the section even if it turns out to 105*dc6a7fd2Sgarbled be empty, which isn't pretty. */ 106*dc6a7fd2Sgarbled . = ALIGN(32 / 8); 107*dc6a7fd2Sgarbled PROVIDE (__preinit_array_start = .); 108*dc6a7fd2Sgarbled .preinit_array : { KEEP (*(.preinit_array)) } 109*dc6a7fd2Sgarbled PROVIDE (__preinit_array_end = .); 110*dc6a7fd2Sgarbled PROVIDE (__init_array_start = .); 111*dc6a7fd2Sgarbled .init_array : { KEEP (*(.init_array)) } 112*dc6a7fd2Sgarbled PROVIDE (__init_array_end = .); 113*dc6a7fd2Sgarbled PROVIDE (__fini_array_start = .); 114*dc6a7fd2Sgarbled .fini_array : { KEEP (*(.fini_array)) } 115*dc6a7fd2Sgarbled PROVIDE (__fini_array_end = .); 116*dc6a7fd2Sgarbled .ctors : 117*dc6a7fd2Sgarbled { 118*dc6a7fd2Sgarbled /* gcc uses crtbegin.o to find the start of 119*dc6a7fd2Sgarbled the constructors, so we make sure it is 120*dc6a7fd2Sgarbled first. Because this is a wildcard, it 121*dc6a7fd2Sgarbled doesn't matter if the user does not 122*dc6a7fd2Sgarbled actually link against crtbegin.o; the 123*dc6a7fd2Sgarbled linker won't look for a file to match a 124*dc6a7fd2Sgarbled wildcard. The wildcard also means that it 125*dc6a7fd2Sgarbled doesn't matter which directory crtbegin.o 126*dc6a7fd2Sgarbled is in. */ 127*dc6a7fd2Sgarbled KEEP (*crtbegin*.o(.ctors)) 128*dc6a7fd2Sgarbled /* We don't want to include the .ctor section from 129*dc6a7fd2Sgarbled from the crtend.o file until after the sorted ctors. 130*dc6a7fd2Sgarbled The .ctor section from the crtend file contains the 131*dc6a7fd2Sgarbled end of ctors marker and it must be last */ 132*dc6a7fd2Sgarbled KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors)) 133*dc6a7fd2Sgarbled KEEP (*(SORT(.ctors.*))) 134*dc6a7fd2Sgarbled KEEP (*(.ctors)) 135*dc6a7fd2Sgarbled } 136*dc6a7fd2Sgarbled .dtors : 137*dc6a7fd2Sgarbled { 138*dc6a7fd2Sgarbled KEEP (*crtbegin*.o(.dtors)) 139*dc6a7fd2Sgarbled KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors)) 140*dc6a7fd2Sgarbled KEEP (*(SORT(.dtors.*))) 141*dc6a7fd2Sgarbled KEEP (*(.dtors)) 142*dc6a7fd2Sgarbled } 143*dc6a7fd2Sgarbled .jcr : { KEEP (*(.jcr)) } 144*dc6a7fd2Sgarbled .data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) } 145*dc6a7fd2Sgarbled .fixup : { *(.fixup) } 146*dc6a7fd2Sgarbled .got1 : { *(.got1) } 147*dc6a7fd2Sgarbled .got2 : { *(.got2) } 148*dc6a7fd2Sgarbled .dynamic : { *(.dynamic) } 149*dc6a7fd2Sgarbled .data : 150*dc6a7fd2Sgarbled { 151*dc6a7fd2Sgarbled *(.data .data.* .gnu.linkonce.d.*) 152*dc6a7fd2Sgarbled KEEP (*(.gnu.linkonce.d.*personality*)) 153*dc6a7fd2Sgarbled SORT(CONSTRUCTORS) 154*dc6a7fd2Sgarbled } 155*dc6a7fd2Sgarbled .data1 : { *(.data1) } 156*dc6a7fd2Sgarbled .got : { *(.got.plt) *(.got) } 157*dc6a7fd2Sgarbled /* We want the small data sections together, so single-instruction offsets 158*dc6a7fd2Sgarbled can access them all, and initialized data all before uninitialized, so 159*dc6a7fd2Sgarbled we can shorten the on-disk segment size. */ 160*dc6a7fd2Sgarbled .sdata : 161*dc6a7fd2Sgarbled { 162*dc6a7fd2Sgarbled *(.sdata .sdata.* .gnu.linkonce.s.*) 163*dc6a7fd2Sgarbled } 164*dc6a7fd2Sgarbled _edata = .; 165*dc6a7fd2Sgarbled PROVIDE (edata = .); 166*dc6a7fd2Sgarbled __bss_start = .; 167*dc6a7fd2Sgarbled .sbss : 168*dc6a7fd2Sgarbled { 169*dc6a7fd2Sgarbled PROVIDE (__sbss_start = .); 170*dc6a7fd2Sgarbled PROVIDE (___sbss_start = .); 171*dc6a7fd2Sgarbled *(.dynsbss) 172*dc6a7fd2Sgarbled *(.sbss .sbss.* .gnu.linkonce.sb.*) 173*dc6a7fd2Sgarbled *(.scommon) 174*dc6a7fd2Sgarbled PROVIDE (__sbss_end = .); 175*dc6a7fd2Sgarbled PROVIDE (___sbss_end = .); 176*dc6a7fd2Sgarbled } 177*dc6a7fd2Sgarbled .plt : { *(.plt) } 178*dc6a7fd2Sgarbled .bss : 179*dc6a7fd2Sgarbled { 180*dc6a7fd2Sgarbled *(.dynbss) 181*dc6a7fd2Sgarbled *(.bss .bss.* .gnu.linkonce.b.*) 182*dc6a7fd2Sgarbled *(COMMON) 183*dc6a7fd2Sgarbled /* Align here to ensure that the .bss section occupies space up to 184*dc6a7fd2Sgarbled _end. Align after .bss to ensure correct alignment even if the 185*dc6a7fd2Sgarbled .bss section disappears because there are no input sections. */ 186*dc6a7fd2Sgarbled . = ALIGN(32 / 8); 187*dc6a7fd2Sgarbled } 188*dc6a7fd2Sgarbled . = ALIGN(32 / 8); 189*dc6a7fd2Sgarbled _end = .; 190*dc6a7fd2Sgarbled __end = .; 191*dc6a7fd2Sgarbled PROVIDE (end = .); 192*dc6a7fd2Sgarbled /* Stabs debugging sections. */ 193*dc6a7fd2Sgarbled .stab 0 : { *(.stab) } 194*dc6a7fd2Sgarbled .stabstr 0 : { *(.stabstr) } 195*dc6a7fd2Sgarbled .stab.excl 0 : { *(.stab.excl) } 196*dc6a7fd2Sgarbled .stab.exclstr 0 : { *(.stab.exclstr) } 197*dc6a7fd2Sgarbled .stab.index 0 : { *(.stab.index) } 198*dc6a7fd2Sgarbled .stab.indexstr 0 : { *(.stab.indexstr) } 199*dc6a7fd2Sgarbled .comment 0 : { *(.comment) } 200*dc6a7fd2Sgarbled /* DWARF debug sections. 201*dc6a7fd2Sgarbled Symbols in the DWARF debugging sections are relative to the beginning 202*dc6a7fd2Sgarbled of the section so we begin them at 0. */ 203*dc6a7fd2Sgarbled /* DWARF 1 */ 204*dc6a7fd2Sgarbled .debug 0 : { *(.debug) } 205*dc6a7fd2Sgarbled .line 0 : { *(.line) } 206*dc6a7fd2Sgarbled /* GNU DWARF 1 extensions */ 207*dc6a7fd2Sgarbled .debug_srcinfo 0 : { *(.debug_srcinfo) } 208*dc6a7fd2Sgarbled .debug_sfnames 0 : { *(.debug_sfnames) } 209*dc6a7fd2Sgarbled /* DWARF 1.1 and DWARF 2 */ 210*dc6a7fd2Sgarbled .debug_aranges 0 : { *(.debug_aranges) } 211*dc6a7fd2Sgarbled .debug_pubnames 0 : { *(.debug_pubnames) } 212*dc6a7fd2Sgarbled /* DWARF 2 */ 213*dc6a7fd2Sgarbled .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 214*dc6a7fd2Sgarbled .debug_abbrev 0 : { *(.debug_abbrev) } 215*dc6a7fd2Sgarbled .debug_line 0 : { *(.debug_line) } 216*dc6a7fd2Sgarbled .debug_frame 0 : { *(.debug_frame) } 217*dc6a7fd2Sgarbled .debug_str 0 : { *(.debug_str) } 218*dc6a7fd2Sgarbled .debug_loc 0 : { *(.debug_loc) } 219*dc6a7fd2Sgarbled .debug_macinfo 0 : { *(.debug_macinfo) } 220*dc6a7fd2Sgarbled /* SGI/MIPS DWARF 2 extensions */ 221*dc6a7fd2Sgarbled .debug_weaknames 0 : { *(.debug_weaknames) } 222*dc6a7fd2Sgarbled .debug_funcnames 0 : { *(.debug_funcnames) } 223*dc6a7fd2Sgarbled .debug_typenames 0 : { *(.debug_typenames) } 224*dc6a7fd2Sgarbled .debug_varnames 0 : { *(.debug_varnames) } 225*dc6a7fd2Sgarbled /DISCARD/ : { *(.note.GNU-stack) } 226*dc6a7fd2Sgarbled} 227