1ed9f17e4SJohn Marino/* Default linker script, for normal executables */ 2ed9f17e4SJohn MarinoOUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", 3ed9f17e4SJohn Marino "elf64-x86-64") 4b2b3ffcdSSimon SchubertOUTPUT_ARCH(i386:x86-64) 5b2b3ffcdSSimon SchubertENTRY(btext) 6b2b3ffcdSSimon SchubertSEARCH_DIR("/usr/lib"); 7e19c755cSJohn Marino 8e19c755cSJohn MarinoPHDRS 9e19c755cSJohn Marino{ 10e19c755cSJohn Marino headers PT_PHDR PHDRS ; 11e19c755cSJohn Marino interp PT_INTERP ; 12e19c755cSJohn Marino text PT_LOAD FILEHDR PHDRS ; 13e19c755cSJohn Marino data PT_LOAD ; 14e19c755cSJohn Marino dynamic PT_DYNAMIC ; 15e19c755cSJohn Marino} 16e19c755cSJohn Marino 17b2b3ffcdSSimon SchubertSECTIONS 18b2b3ffcdSSimon Schubert{ 19b2b3ffcdSSimon Schubert /* Read-only sections, merged into text segment: */ 20ed9f17e4SJohn Marino kernphys = 0x200000; 21ed9f17e4SJohn Marino kernmxps = CONSTANT (MAXPAGESIZE); 22ed9f17e4SJohn Marino kernpage = CONSTANT (COMMONPAGESIZE); 23be065f57SJohn Marino . = kernbase + kernphys + SIZEOF_HEADERS; 24e19c755cSJohn Marino .interp : { *(.interp) } :text :interp 25e19c755cSJohn Marino .note.gnu.build-id : { *(.note.gnu.build-id) } :text 26b2b3ffcdSSimon Schubert .hash : { *(.hash) } 27be065f57SJohn Marino .gnu.hash : { *(.gnu.hash) } 28b2b3ffcdSSimon Schubert .dynsym : { *(.dynsym) } 29b2b3ffcdSSimon Schubert .dynstr : { *(.dynstr) } 30b2b3ffcdSSimon Schubert .gnu.version : { *(.gnu.version) } 31b2b3ffcdSSimon Schubert .gnu.version_d : { *(.gnu.version_d) } 32b2b3ffcdSSimon Schubert .gnu.version_r : { *(.gnu.version_r) } 33b2b3ffcdSSimon Schubert .rela.init : { *(.rela.init) } 34b2b3ffcdSSimon Schubert .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } 35b2b3ffcdSSimon Schubert .rela.fini : { *(.rela.fini) } 36b2b3ffcdSSimon Schubert .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } 37be065f57SJohn Marino .rela.data.rel.ro : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) } 38b2b3ffcdSSimon Schubert .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } 39b2b3ffcdSSimon Schubert .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) } 40b2b3ffcdSSimon Schubert .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) } 41b2b3ffcdSSimon Schubert .rela.ctors : { *(.rela.ctors) } 42b2b3ffcdSSimon Schubert .rela.dtors : { *(.rela.dtors) } 43b2b3ffcdSSimon Schubert .rela.got : { *(.rela.got) } 44b2b3ffcdSSimon Schubert .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } 45be065f57SJohn Marino .rela.ldata : { *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*) } 46be065f57SJohn Marino .rela.lbss : { *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*) } 47be065f57SJohn Marino .rela.lrodata : { *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*) } 48ed9f17e4SJohn Marino .rela.ifunc : { *(.rela.ifunc) } 49ed9f17e4SJohn Marino .rela.plt : 50ed9f17e4SJohn Marino { 51ed9f17e4SJohn Marino *(.rela.plt) 52ed9f17e4SJohn Marino PROVIDE_HIDDEN (__rela_iplt_start = .); 53ed9f17e4SJohn Marino *(.rela.iplt) 54ed9f17e4SJohn Marino PROVIDE_HIDDEN (__rela_iplt_end = .); 55ed9f17e4SJohn Marino } 56b2b3ffcdSSimon Schubert .init : 57b2b3ffcdSSimon Schubert { 58b2b3ffcdSSimon Schubert KEEP (*(.init)) 59b2b3ffcdSSimon Schubert } =0x90909090 60ed9f17e4SJohn Marino .plt : { *(.plt) *(.iplt) } 61b2b3ffcdSSimon Schubert .text : 62b2b3ffcdSSimon Schubert { 63ed9f17e4SJohn Marino *(.text.unlikely .text.*_unlikely) 64ed9f17e4SJohn Marino *(.text.exit .text.exit.*) 65ed9f17e4SJohn Marino *(.text.startup .text.startup.*) 66ed9f17e4SJohn Marino *(.text.hot .text.hot.*) 67b2b3ffcdSSimon Schubert *(.text .stub .text.* .gnu.linkonce.t.*) 68b2b3ffcdSSimon Schubert /* .gnu.warning sections are handled specially by elf32.em. */ 69b2b3ffcdSSimon Schubert *(.gnu.warning) 70b2b3ffcdSSimon Schubert } =0x90909090 71b2b3ffcdSSimon Schubert .fini : 72b2b3ffcdSSimon Schubert { 73b2b3ffcdSSimon Schubert KEEP (*(.fini)) 74b2b3ffcdSSimon Schubert } =0x90909090 75b2b3ffcdSSimon Schubert PROVIDE (__etext = .); 76b2b3ffcdSSimon Schubert PROVIDE (_etext = .); 77b2b3ffcdSSimon Schubert PROVIDE (etext = .); 78b2b3ffcdSSimon Schubert .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } 79b2b3ffcdSSimon Schubert .rodata1 : { *(.rodata1) } 80b2b3ffcdSSimon Schubert .eh_frame_hdr : { *(.eh_frame_hdr) } 81be065f57SJohn Marino .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } 82ed9f17e4SJohn Marino .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table 83ed9f17e4SJohn Marino .gcc_except_table.*) } 84ed9f17e4SJohn Marino /* These sections are generated by the Sun/Oracle C++ compiler. */ 85ed9f17e4SJohn Marino .exception_ranges : ONLY_IF_RO { *(.exception_ranges 86ed9f17e4SJohn Marino .exception_ranges*) } 87b2b3ffcdSSimon Schubert /* Adjust the address for the data segment. We want to adjust up to 88b2b3ffcdSSimon Schubert the same address within the page on the next page up. */ 89ed9f17e4SJohn Marino . = ALIGN (kernmxps) - ((kernmxps - .) & (kernmxps - 1)); 90ed9f17e4SJohn Marino . = DATA_SEGMENT_ALIGN (kernmxps, kernpage); 91be065f57SJohn Marino /* Exception handling */ 92be065f57SJohn Marino .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } 93be065f57SJohn Marino .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } 94ed9f17e4SJohn Marino .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } 95be065f57SJohn Marino /* Thread Local Storage sections */ 96b2b3ffcdSSimon Schubert .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } 97b2b3ffcdSSimon Schubert .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 98be065f57SJohn Marino .preinit_array : 99be065f57SJohn Marino { 100be065f57SJohn Marino PROVIDE_HIDDEN (__preinit_array_start = .); 101be065f57SJohn Marino KEEP (*(.preinit_array)) 102be065f57SJohn Marino PROVIDE_HIDDEN (__preinit_array_end = .); 103be065f57SJohn Marino } 104be065f57SJohn Marino .init_array : 105be065f57SJohn Marino { 106be065f57SJohn Marino PROVIDE_HIDDEN (__init_array_start = .); 107be065f57SJohn Marino KEEP (*(SORT(.init_array.*))) 108be065f57SJohn Marino KEEP (*(.init_array)) 109be065f57SJohn Marino PROVIDE_HIDDEN (__init_array_end = .); 110be065f57SJohn Marino } 111be065f57SJohn Marino .fini_array : 112be065f57SJohn Marino { 113be065f57SJohn Marino PROVIDE_HIDDEN (__fini_array_start = .); 114be065f57SJohn Marino KEEP (*(SORT(.fini_array.*))) 115ed9f17e4SJohn Marino KEEP (*(.fini_array)) 116be065f57SJohn Marino PROVIDE_HIDDEN (__fini_array_end = .); 117be065f57SJohn Marino } 118b2b3ffcdSSimon Schubert _start_ctors = .; 119b2b3ffcdSSimon Schubert PROVIDE (start_ctors = .); 120b2b3ffcdSSimon Schubert .ctors : 121b2b3ffcdSSimon Schubert { 122b2b3ffcdSSimon Schubert /* gcc uses crtbegin.o to find the start of 123b2b3ffcdSSimon Schubert the constructors, so we make sure it is 124b2b3ffcdSSimon Schubert first. Because this is a wildcard, it 125b2b3ffcdSSimon Schubert doesn't matter if the user does not 126b2b3ffcdSSimon Schubert actually link against crtbegin.o; the 127b2b3ffcdSSimon Schubert linker won't look for a file to match a 128b2b3ffcdSSimon Schubert wildcard. The wildcard also means that it 129b2b3ffcdSSimon Schubert doesn't matter which directory crtbegin.o 130b2b3ffcdSSimon Schubert is in. */ 131b2b3ffcdSSimon Schubert KEEP (*crtbegin.o(.ctors)) 132ed9f17e4SJohn Marino KEEP (*crtbegin?.o(.ctors)) 133b2b3ffcdSSimon Schubert /* We don't want to include the .ctor section from 134be065f57SJohn Marino the crtend.o file until after the sorted ctors. 135b2b3ffcdSSimon Schubert The .ctor section from the crtend file contains the 136b2b3ffcdSSimon Schubert end of ctors marker and it must be last */ 137ed9f17e4SJohn Marino KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) 138b2b3ffcdSSimon Schubert KEEP (*(SORT(.ctors.*))) 139b2b3ffcdSSimon Schubert KEEP (*(.ctors)) 140b2b3ffcdSSimon Schubert } 141b2b3ffcdSSimon Schubert _stop_ctors = .; 142b2b3ffcdSSimon Schubert PROVIDE (stop_ctors = .); 143b2b3ffcdSSimon Schubert .dtors : 144b2b3ffcdSSimon Schubert { 145b2b3ffcdSSimon Schubert KEEP (*crtbegin.o(.dtors)) 146ed9f17e4SJohn Marino KEEP (*crtbegin?.o(.dtors)) 147ed9f17e4SJohn Marino KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) 148b2b3ffcdSSimon Schubert KEEP (*(SORT(.dtors.*))) 149b2b3ffcdSSimon Schubert KEEP (*(.dtors)) 150b2b3ffcdSSimon Schubert } 151b2b3ffcdSSimon Schubert .jcr : { KEEP (*(.jcr)) } 152e19c755cSJohn Marino .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } :data 153e19c755cSJohn Marino .dynamic : { *(.dynamic) } :data :dynamic 154e19c755cSJohn Marino .got : { *(.got) *(.igot) } :data 155be065f57SJohn Marino . = DATA_SEGMENT_RELRO_END (24, .); 156ed9f17e4SJohn Marino .got.plt : { *(.got.plt) *(.igot.plt) } 157*23951da2SMatthew Dillon . = ALIGN(128); 158*23951da2SMatthew Dillon .data.read_frequently : 159*23951da2SMatthew Dillon { 160*23951da2SMatthew Dillon *(SORT_BY_ALIGNMENT(.data.read_frequently)) 161*23951da2SMatthew Dillon } 162*23951da2SMatthew Dillon .data.read_mostly : 163*23951da2SMatthew Dillon { 164*23951da2SMatthew Dillon *(.data.read_mostly) 165*23951da2SMatthew Dillon } 166*23951da2SMatthew Dillon . = ALIGN(128); 167*23951da2SMatthew Dillon .data.exclusive_cache_line : 168*23951da2SMatthew Dillon { 169*23951da2SMatthew Dillon *(.data.exclusive_cache_line) 170*23951da2SMatthew Dillon } 171*23951da2SMatthew Dillon . = ALIGN(128); 172be065f57SJohn Marino .data : 173be065f57SJohn Marino { 174be065f57SJohn Marino *(.data .data.* .gnu.linkonce.d.*) 175be065f57SJohn Marino SORT(CONSTRUCTORS) 176be065f57SJohn Marino } 177be065f57SJohn Marino .data1 : { *(.data1) } 178be065f57SJohn Marino _edata = .; PROVIDE (edata = .); 179b2b3ffcdSSimon Schubert __bss_start = .; 180b2b3ffcdSSimon Schubert .bss : 181b2b3ffcdSSimon Schubert { 182b2b3ffcdSSimon Schubert *(.dynbss) 183b2b3ffcdSSimon Schubert *(.bss .bss.* .gnu.linkonce.b.*) 184b2b3ffcdSSimon Schubert *(COMMON) 185b2b3ffcdSSimon Schubert /* Align here to ensure that the .bss section occupies space up to 186b2b3ffcdSSimon Schubert _end. Align after .bss to ensure correct alignment even if the 187be065f57SJohn Marino .bss section disappears because there are no input sections. 188be065f57SJohn Marino FIXME: Why do we need it? When there is no .bss section, we don't 189be065f57SJohn Marino pad the .data section. */ 190be065f57SJohn Marino . = ALIGN(. != 0 ? 64 / 8 : 1); 191be065f57SJohn Marino } 192be065f57SJohn Marino .lbss : 193be065f57SJohn Marino { 194be065f57SJohn Marino *(.dynlbss) 195be065f57SJohn Marino *(.lbss .lbss.* .gnu.linkonce.lb.*) 196be065f57SJohn Marino *(LARGE_COMMON) 197b2b3ffcdSSimon Schubert } 198b2b3ffcdSSimon Schubert . = ALIGN(64 / 8); 199ed9f17e4SJohn Marino .lrodata ALIGN(kernmxps) + (. & (kernmxps - 1)) : 200be065f57SJohn Marino { 201be065f57SJohn Marino *(.lrodata .lrodata.* .gnu.linkonce.lr.*) 202be065f57SJohn Marino } 203ed9f17e4SJohn Marino .ldata ALIGN(kernmxps) + (. & (kernmxps - 1)) : 204be065f57SJohn Marino { 205be065f57SJohn Marino *(.ldata .ldata.* .gnu.linkonce.l.*) 206be065f57SJohn Marino . = ALIGN(. != 0 ? 64 / 8 : 1); 207be065f57SJohn Marino } 208be065f57SJohn Marino . = ALIGN(64 / 8); 209be065f57SJohn Marino _end = .; PROVIDE (end = .); 210b2b3ffcdSSimon Schubert . = DATA_SEGMENT_END (.); 211b2b3ffcdSSimon Schubert /* Stabs debugging sections. */ 212b2b3ffcdSSimon Schubert .stab 0 : { *(.stab) } 213b2b3ffcdSSimon Schubert .stabstr 0 : { *(.stabstr) } 214b2b3ffcdSSimon Schubert .stab.excl 0 : { *(.stab.excl) } 215b2b3ffcdSSimon Schubert .stab.exclstr 0 : { *(.stab.exclstr) } 216b2b3ffcdSSimon Schubert .stab.index 0 : { *(.stab.index) } 217b2b3ffcdSSimon Schubert .stab.indexstr 0 : { *(.stab.indexstr) } 218b2b3ffcdSSimon Schubert .comment 0 : { *(.comment) } 219b2b3ffcdSSimon Schubert /* DWARF debug sections. 220b2b3ffcdSSimon Schubert Symbols in the DWARF debugging sections are relative to the beginning 221b2b3ffcdSSimon Schubert of the section so we begin them at 0. */ 222b2b3ffcdSSimon Schubert /* DWARF 1 */ 223b2b3ffcdSSimon Schubert .debug 0 : { *(.debug) } 224b2b3ffcdSSimon Schubert .line 0 : { *(.line) } 225b2b3ffcdSSimon Schubert /* GNU DWARF 1 extensions */ 226b2b3ffcdSSimon Schubert .debug_srcinfo 0 : { *(.debug_srcinfo) } 227b2b3ffcdSSimon Schubert .debug_sfnames 0 : { *(.debug_sfnames) } 228b2b3ffcdSSimon Schubert /* DWARF 1.1 and DWARF 2 */ 229b2b3ffcdSSimon Schubert .debug_aranges 0 : { *(.debug_aranges) } 230b2b3ffcdSSimon Schubert .debug_pubnames 0 : { *(.debug_pubnames) } 231b2b3ffcdSSimon Schubert /* DWARF 2 */ 232b2b3ffcdSSimon Schubert .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 233b2b3ffcdSSimon Schubert .debug_abbrev 0 : { *(.debug_abbrev) } 234b2b3ffcdSSimon Schubert .debug_line 0 : { *(.debug_line) } 235b2b3ffcdSSimon Schubert .debug_frame 0 : { *(.debug_frame) } 236b2b3ffcdSSimon Schubert .debug_str 0 : { *(.debug_str) } 237b2b3ffcdSSimon Schubert .debug_loc 0 : { *(.debug_loc) } 238b2b3ffcdSSimon Schubert .debug_macinfo 0 : { *(.debug_macinfo) } 239b2b3ffcdSSimon Schubert /* SGI/MIPS DWARF 2 extensions */ 240b2b3ffcdSSimon Schubert .debug_weaknames 0 : { *(.debug_weaknames) } 241b2b3ffcdSSimon Schubert .debug_funcnames 0 : { *(.debug_funcnames) } 242b2b3ffcdSSimon Schubert .debug_typenames 0 : { *(.debug_typenames) } 243b2b3ffcdSSimon Schubert .debug_varnames 0 : { *(.debug_varnames) } 244be065f57SJohn Marino /* DWARF 3 */ 245be065f57SJohn Marino .debug_pubtypes 0 : { *(.debug_pubtypes) } 246be065f57SJohn Marino .debug_ranges 0 : { *(.debug_ranges) } 247be065f57SJohn Marino .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } 248ed9f17e4SJohn Marino /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } 249b2b3ffcdSSimon Schubert} 250