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