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