1/* Default linker script, for normal executables */ 2/* Copyright (C) 2014 Free Software Foundation, Inc. 3 Copying and distribution of this script, with or without modification, 4 are permitted in any medium without royalty provided the copyright 5 notice and this notice are preserved. */ 6 7/* source, modified: 8 * /opt/CodeSourcery/Sourcery_G++_Lite/mips-sde-elf/lib/ldscripts/elf32ltsmip.x 9 */ 10#ifdef __mips64 11OUTPUT_FORMAT("elf64-tradlittlemips", "elf64-tradbigmips", 12 "elf64-tradlittlemips") 13#else 14OUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradbigmips", 15 "elf32-tradlittlemips") 16#endif 17OUTPUT_ARCH(mips) 18ENTRY(__start) 19 20PHDRS 21{ 22 phdr PT_PHDR PHDRS; 23 ro PT_LOAD FILEHDR PHDRS; 24 rw PT_LOAD; 25 tls PT_TLS; 26 L4_DEFINE_L4PHDRS 27} 28 29SECTIONS 30{ 31 /* Read-only sections, merged into text segment: */ 32 PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x0400000)); . = SEGMENT_START("text-segment", 0x0400000) + SIZEOF_HEADERS; 33 .interp : { *(.interp) } :ro 34 .MIPS.abiflags : { *(.MIPS.abiflags) } :ro 35 .MIPS.options : { *(.MIPS.options) } 36 .reginfo : { *(.reginfo) } 37 .note.gnu.build-id : { *(.note.gnu.build-id) } 38 .dynamic : { *(.dynamic) } 39 .hash : { *(.hash) } 40 .gnu.hash : { *(.gnu.hash) } 41 .dynsym : { *(.dynsym) } 42 .dynstr : { *(.dynstr) } 43 .gnu.version : { *(.gnu.version) } 44 .gnu.version_d : { *(.gnu.version_d) } 45 .gnu.version_r : { *(.gnu.version_r) } 46 .rel.init : { *(.rel.init) } 47 .rela.init : { *(.rela.init) } 48 .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) } 49 .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } 50 .rel.fini : { *(.rel.fini) } 51 .rela.fini : { *(.rela.fini) } 52 .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) } 53 .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } 54 .rel.data.rel.ro : { *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*) } 55 .rela.data.rel.ro : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) } 56 .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) } 57 .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } 58 .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) } 59 .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) } 60 .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) } 61 .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) } 62 .rel.ctors : { *(.rel.ctors) } 63 .rela.ctors : { *(.rela.ctors) } 64 .rel.dtors : { *(.rel.dtors) } 65 .rela.dtors : { *(.rela.dtors) } 66 .rel.got : { *(.rel.got) } 67 .rela.got : { *(.rela.got) } 68 .rel.dyn : { *(.rel.dyn) } 69 .rel.sdata : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) } 70 .rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) } 71 .rel.sbss : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) } 72 .rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) } 73 .rel.sdata2 : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) } 74 .rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) } 75 .rel.sbss2 : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) } 76 .rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) } 77 .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } 78 .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } 79 .rel.iplt : 80 { 81 PROVIDE_HIDDEN (__rel_iplt_start = .); 82 *(.rel.iplt) 83 PROVIDE_HIDDEN (__rel_iplt_end = .); 84 } 85 .rela.iplt : 86 { 87 PROVIDE_HIDDEN (__rela_iplt_start = .); 88 *(.rela.iplt) 89 PROVIDE_HIDDEN (__rela_iplt_end = .); 90 } 91 .rel.plt : 92 { 93 *(.rel.plt) 94 } 95 .rela.plt : 96 { 97 *(.rela.plt) 98 } 99 .init : 100 { 101 KEEP (*(SORT_NONE(.init))) 102 } 103 .plt : { *(.plt) } 104 .iplt : { *(.iplt) } 105 .text : 106 { 107 _ftext = . ; 108 *(.text.unlikely .text.*_unlikely .text.unlikely.*) 109 *(.text.exit .text.exit.*) 110 *(.text.startup .text.startup.*) 111 *(.text.hot .text.hot.*) 112 *(.text .stub .text.* .gnu.linkonce.t.*) 113 /* .gnu.warning sections are handled specially by elf32.em. */ 114 *(.gnu.warning) 115 *(.mips16.fn.*) *(.mips16.call.*) 116 } :ro 117 .fini : 118 { 119 KEEP (*(SORT_NONE(.fini))) 120 } 121 PROVIDE (__etext = .); 122 PROVIDE (_etext = .); 123 PROVIDE (etext = .); 124 .rol4re_elf_aux : { 125 KEEP (*(.rol4re_elf_aux)) 126 } : ro : l4re_aux 127 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } :ro 128 .rodata1 : { *(.rodata1) } 129 .sdata2 : 130 { 131 *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) 132 } 133 .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } 134 .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) } :ro 135 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } :ro 136 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table 137 .gcc_except_table.*) } :ro 138 .gnu_extab : ONLY_IF_RO { *(.gnu_extab*) } :ro 139 /* These sections are generated by the Sun/Oracle C++ compiler. */ 140 .exception_ranges : ONLY_IF_RO { *(.exception_ranges 141 .exception_ranges*) } :ro 142 /* Adjust the address for the data segment. We want to adjust up to 143 the same address within the page on the next page up. */ 144 . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); 145 /* Exception handling */ 146 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } :rw 147 .gnu_extab : ONLY_IF_RW { *(.gnu_extab) } :rw 148 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } :rw 149 .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } :rw 150 /* Thread Local Storage sections */ 151 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } :rw : tls 152 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 153 .preinit_array : 154 { 155 PROVIDE_HIDDEN (__preinit_array_start = .); 156 KEEP (*(.preinit_array)) 157 PROVIDE_HIDDEN (__preinit_array_end = .); 158 } : rw 159 .init_array : 160 { 161 PROVIDE_HIDDEN (__init_array_start = .); 162 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 163 KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) 164 PROVIDE_HIDDEN (__init_array_end = .); 165 } 166 .fini_array : 167 { 168 PROVIDE_HIDDEN (__fini_array_start = .); 169 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 170 KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) 171 PROVIDE_HIDDEN (__fini_array_end = .); 172 } 173 .ctors : 174 { 175 /* gcc uses crtbegin.o to find the start of 176 the constructors, so we make sure it is 177 first. Because this is a wildcard, it 178 doesn't matter if the user does not 179 actually link against crtbegin.o; the 180 linker won't look for a file to match a 181 wildcard. The wildcard also means that it 182 doesn't matter which directory crtbegin.o 183 is in. */ 184 KEEP (*crtbegin.o(.ctors)) 185 KEEP (*crtbegin?.o(.ctors)) 186 /* We don't want to include the .ctor section from 187 the crtend.o file until after the sorted ctors. 188 The .ctor section from the crtend file contains the 189 end of ctors marker and it must be last */ 190 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) 191 KEEP (*(SORT(.ctors.*))) 192 KEEP (*(.ctors)) 193 } :rw 194 .dtors : 195 { 196 KEEP (*crtbegin.o(.dtors)) 197 KEEP (*crtbegin?.o(.dtors)) 198 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) 199 KEEP (*(SORT(.dtors.*))) 200 KEEP (*(.dtors)) 201 } 202 .jcr : { KEEP (*(.jcr)) } 203 .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) } 204 . = DATA_SEGMENT_RELRO_END (0, .); 205 .data : 206 { 207 _fdata = . ; 208 *(.data .data.* .gnu.linkonce.d.*) 209 SORT(CONSTRUCTORS) 210 } 211 .data1 : { *(.data1) } 212 .got.plt : { *(.got.plt) } 213 . = .; 214 . = .; 215 HIDDEN (_gp = ALIGN (16) + 0x7ff0); 216 .got : { *(.got) } 217 /* We want the small data sections together, so single-instruction offsets 218 can access them all, and initialized data all before uninitialized, so 219 we can shorten the on-disk segment size. */ 220 .sdata : 221 { 222 *(.sdata .sdata.* .gnu.linkonce.s.*) 223 } 224 .lit8 : { *(.lit8) } 225 .lit4 : { *(.lit4) } 226 .srdata : { *(.srdata) } 227 _edata = .; PROVIDE (edata = .); 228 . = .; 229 __bss_start = .; 230 _fbss = .; 231 .sbss : 232 { 233 *(.dynsbss) 234 *(.sbss .sbss.* .gnu.linkonce.sb.*) 235 *(.scommon) 236 } 237 .bss : 238 { 239 *(.dynbss) 240 *(.bss .bss.* .gnu.linkonce.b.*) 241 *(COMMON) 242 /* Align here to ensure that the .bss section occupies space up to 243 _end. Align after .bss to ensure correct alignment even if the 244 .bss section disappears because there are no input sections. 245 FIXME: Why do we need it? When there is no .bss section, we don't 246 pad the .data section. */ 247 . = ALIGN(. != 0 ? __SIZEOF_LONG__ : 1); 248 } 249 . = ALIGN(__SIZEOF_LONG__); 250 . = SEGMENT_START("ldata-segment", .); 251 . = ALIGN(__SIZEOF_LONG__); 252 _end = .; PROVIDE (end = .); 253 . = DATA_SEGMENT_END (.); 254 /* Stabs debugging sections. */ 255 .stab 0 : { *(.stab) } 256 .stabstr 0 : { *(.stabstr) } 257 .stab.excl 0 : { *(.stab.excl) } 258 .stab.exclstr 0 : { *(.stab.exclstr) } 259 .stab.index 0 : { *(.stab.index) } 260 .stab.indexstr 0 : { *(.stab.indexstr) } 261 .comment 0 : { *(.comment) } 262 /* DWARF debug sections. 263 Symbols in the DWARF debugging sections are relative to the beginning 264 of the section so we begin them at 0. */ 265 /* DWARF 1 */ 266 .debug 0 : { *(.debug) } 267 .line 0 : { *(.line) } 268 /* GNU DWARF 1 extensions */ 269 .debug_srcinfo 0 : { *(.debug_srcinfo) } 270 .debug_sfnames 0 : { *(.debug_sfnames) } 271 /* DWARF 1.1 and DWARF 2 */ 272 .debug_aranges 0 : { *(.debug_aranges) } 273 .debug_pubnames 0 : { *(.debug_pubnames) } 274 /* DWARF 2 */ 275 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 276 .debug_abbrev 0 : { *(.debug_abbrev) } 277 .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } 278 .debug_frame 0 : { *(.debug_frame) } 279 .debug_str 0 : { *(.debug_str) } 280 .debug_loc 0 : { *(.debug_loc) } 281 .debug_macinfo 0 : { *(.debug_macinfo) } 282 /* SGI/MIPS DWARF 2 extensions */ 283 .debug_weaknames 0 : { *(.debug_weaknames) } 284 .debug_funcnames 0 : { *(.debug_funcnames) } 285 .debug_typenames 0 : { *(.debug_typenames) } 286 .debug_varnames 0 : { *(.debug_varnames) } 287 /* DWARF 3 */ 288 .debug_pubtypes 0 : { *(.debug_pubtypes) } 289 .debug_ranges 0 : { *(.debug_ranges) } 290 /* DWARF Extension. */ 291 .debug_macro 0 : { *(.debug_macro) } 292 .debug_addr 0 : { *(.debug_addr) } 293 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } 294 .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } 295 .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } 296 .mdebug.abi32 0 : { KEEP(*(.mdebug.abi32)) } 297 .mdebug.abiN32 0 : { KEEP(*(.mdebug.abiN32)) } 298 .mdebug.abi64 0 : { KEEP(*(.mdebug.abi64)) } 299 .mdebug.abiO64 0 : { KEEP(*(.mdebug.abiO64)) } 300 .mdebug.eabi32 0 : { KEEP(*(.mdebug.eabi32)) } 301 .mdebug.eabi64 0 : { KEEP(*(.mdebug.eabi64)) } 302 .gcc_compiled_long32 0 : { KEEP(*(.gcc_compiled_long32)) } 303 .gcc_compiled_long64 0 : { KEEP(*(.gcc_compiled_long64)) } 304 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } 305} 306