1 /* Script for --shared -z combreloc -z now -z relro: shared library, combine & sort relocs */ 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 OUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradbigmips", 7 "elf32-tradlittlemips") 8 OUTPUT_ARCH(mips) 9 ENTRY(__start) 10 SECTIONS 11 { 12 /* Read-only sections, merged into text segment: */ 13 . = 0 + SIZEOF_HEADERS; 14 .MIPS.abiflags : { *(.MIPS.abiflags) } 15 .reginfo : { *(.reginfo) } 16 .note.gnu.build-id : { *(.note.gnu.build-id) } 17 .hash : { *(.hash) } 18 .gnu.hash : { *(.gnu.hash) } 19 .dynsym : { *(.dynsym) } 20 .dynstr : { *(.dynstr) } 21 .gnu.version : { *(.gnu.version) } 22 .gnu.version_d : { *(.gnu.version_d) } 23 .gnu.version_r : { *(.gnu.version_r) } 24 .rel.dyn : 25 { 26 *(.rel.init) 27 *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) 28 *(.rel.fini) 29 *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) 30 *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*) 31 *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) 32 *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) 33 *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) 34 *(.rel.ctors) 35 *(.rel.dtors) 36 *(.rel.got) 37 *(.rel.dyn) 38 *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) 39 *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) 40 *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) 41 *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) 42 *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) 43 *(.rel.iplt) 44 } 45 .rela.dyn : 46 { 47 *(.rela.init) 48 *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) 49 *(.rela.fini) 50 *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) 51 *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) 52 *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) 53 *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) 54 *(.rela.ctors) 55 *(.rela.dtors) 56 *(.rela.got) 57 *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) 58 *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) 59 *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) 60 *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) 61 *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) 62 *(.rela.iplt) 63 } 64 .rel.plt : 65 { 66 *(.rel.plt) 67 } 68 .rela.plt : 69 { 70 *(.rela.plt) 71 } 72 .init : 73 { 74 KEEP (*(SORT_NONE(.init))) 75 } 76 .text : 77 { 78 _ftext = . ; 79 *(.text.unlikely .text.*_unlikely .text.unlikely.*) 80 *(.text.exit .text.exit.*) 81 *(.text.startup .text.startup.*) 82 *(.text.hot .text.hot.*) 83 *(.text .stub .text.* .gnu.linkonce.t.*) 84 /* .gnu.warning sections are handled specially by elf32.em. */ 85 *(.gnu.warning) 86 *(.mips16.fn.*) *(.mips16.call.*) 87 } 88 .fini : 89 { 90 KEEP (*(SORT_NONE(.fini))) 91 } 92 PROVIDE (__etext = .); 93 PROVIDE (_etext = .); 94 PROVIDE (etext = .); 95 .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } 96 .rodata1 : { *(.rodata1) } 97 .eh_frame_hdr : { *(.eh_frame_hdr) } 98 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } 99 .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table 100 .gcc_except_table.*) } 101 /* These sections are generated by the Sun/Oracle C++ compiler. */ 102 .exception_ranges : ONLY_IF_RO { *(.exception_ranges 103 .exception_ranges*) } 104 .plt : { *(.plt) } 105 .iplt : { *(.iplt) } 106 /* Adjust the address for the data segment. For 32 bits we want to align 107 at exactly a page boundary to make life easier for apriori. */ 108 . = ALIGN (CONSTANT (MAXPAGESIZE)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); 109 /* Exception handling */ 110 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } 111 .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } 112 .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } 113 /* Thread Local Storage sections */ 114 .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } 115 .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } 116 /* Ensure the __preinit_array_start label is properly aligned. We 117 could instead move the label definition inside the section, but 118 the linker would then create the section even if it turns out to 119 be empty, which isn't pretty. */ 120 . = ALIGN(32 / 8); 121 .preinit_array : 122 { 123 KEEP (*(.preinit_array)) 124 } 125 .init_array : 126 { 127 KEEP (*crtbegin*.o(.init_array)) 128 KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) 129 KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o ) .ctors)) 130 } 131 .fini_array : 132 { 133 KEEP (*crtbegin*.o(.fini_array)) 134 KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) 135 KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o ) .dtors)) 136 } 137 .ctors : 138 { 139 /* gcc uses crtbegin.o to find the start of 140 the constructors, so we make sure it is 141 first. Because this is a wildcard, it 142 doesn't matter if the user does not 143 actually link against crtbegin.o; the 144 linker won't look for a file to match a 145 wildcard. The wildcard also means that it 146 doesn't matter which directory crtbegin.o 147 is in. */ 148 KEEP (*crtbegin.o(.ctors)) 149 KEEP (*crtbegin*.o(.ctors)) 150 /* We don't want to include the .ctor section from 151 the crtend.o file until after the sorted ctors. 152 The .ctor section from the crtend file contains the 153 end of ctors marker and it must be last */ 154 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .ctors)) 155 KEEP (*(SORT(.ctors.*))) 156 KEEP (*(.ctors)) 157 } 158 .dtors : 159 { 160 KEEP (*crtbegin.o(.dtors)) 161 KEEP (*crtbegin*.o(.dtors)) 162 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o ) .dtors)) 163 KEEP (*(SORT(.dtors.*))) 164 KEEP (*(.dtors)) 165 } 166 .jcr : { KEEP (*(.jcr)) } 167 .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) } 168 .got.plt : { *(.got.plt) } 169 .dynamic : { *(.dynamic) } 170 . = DATA_SEGMENT_RELRO_END (0, .); 171 .data : 172 { 173 _fdata = . ; 174 *(.data .data.* .gnu.linkonce.d.*) 175 SORT(CONSTRUCTORS) 176 } 177 .data1 : { *(.data1) } 178 . = .; 179 HIDDEN (_gp = ALIGN (16) + 0x7ff0); 180 .got : { *(.got) } 181 /* We want the small data sections together, so single-instruction offsets 182 can access them all, and initialized data all before uninitialized, so 183 we can shorten the on-disk segment size. */ 184 .sdata : 185 { 186 *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) 187 *(.sdata .sdata.* .gnu.linkonce.s.*) 188 } 189 .lit8 : { *(.lit8) } 190 .lit4 : { *(.lit4) } 191 _edata = .; PROVIDE (edata = .); 192 __bss_start = .; 193 _fbss = .; 194 .sbss : 195 { 196 *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) 197 *(.dynsbss) 198 *(.sbss .sbss.* .gnu.linkonce.sb.*) 199 *(.scommon) 200 } 201 .bss : 202 { 203 *(.dynbss) 204 *(.bss .bss.* .gnu.linkonce.b.*) 205 *(COMMON) 206 /* Align here to ensure that the .bss section occupies space up to 207 _end. Align after .bss to ensure correct alignment even if the 208 .bss section disappears because there are no input sections. */ 209 . = ALIGN(32 / 8); 210 } 211 . = ALIGN(32 / 8); 212 . = SEGMENT_START("ldata-segment", .); 213 . = ALIGN(32 / 8); 214 _end = .; 215 _bss_end__ = . ; __bss_end__ = . ; __end__ = . ; 216 PROVIDE (end = .); 217 . = DATA_SEGMENT_END (.); 218 /* Stabs debugging sections. */ 219 .stab 0 : { *(.stab) } 220 .stabstr 0 : { *(.stabstr) } 221 .stab.excl 0 : { *(.stab.excl) } 222 .stab.exclstr 0 : { *(.stab.exclstr) } 223 .stab.index 0 : { *(.stab.index) } 224 .stab.indexstr 0 : { *(.stab.indexstr) } 225 .comment 0 : { *(.comment) } 226 /* DWARF debug sections. 227 Symbols in the DWARF debugging sections are relative to the beginning 228 of the section so we begin them at 0. */ 229 /* DWARF 1 */ 230 .debug 0 : { *(.debug) } 231 .line 0 : { *(.line) } 232 /* GNU DWARF 1 extensions */ 233 .debug_srcinfo 0 : { *(.debug_srcinfo) } 234 .debug_sfnames 0 : { *(.debug_sfnames) } 235 /* DWARF 1.1 and DWARF 2 */ 236 .debug_aranges 0 : { *(.debug_aranges) } 237 .debug_pubnames 0 : { *(.debug_pubnames) } 238 /* DWARF 2 */ 239 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 240 .debug_abbrev 0 : { *(.debug_abbrev) } 241 .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } 242 .debug_frame 0 : { *(.debug_frame) } 243 .debug_str 0 : { *(.debug_str) } 244 .debug_loc 0 : { *(.debug_loc) } 245 .debug_macinfo 0 : { *(.debug_macinfo) } 246 /* SGI/MIPS DWARF 2 extensions */ 247 .debug_weaknames 0 : { *(.debug_weaknames) } 248 .debug_funcnames 0 : { *(.debug_funcnames) } 249 .debug_typenames 0 : { *(.debug_typenames) } 250 .debug_varnames 0 : { *(.debug_varnames) } 251 /* DWARF 3 */ 252 .debug_pubtypes 0 : { *(.debug_pubtypes) } 253 .debug_ranges 0 : { *(.debug_ranges) } 254 /* DWARF Extension. */ 255 .debug_macro 0 : { *(.debug_macro) } 256 .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } 257 .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } 258 .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } 259 .gcc_compiled_long32 0 : { KEEP(*(.gcc_compiled_long32)) } 260 .gcc_compiled_long64 0 : { KEEP(*(.gcc_compiled_long64)) } 261 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.mdebug.*) } 262 } 263