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