1 # This variant of elf.sc is used for ARM BPABI platforms, like Symbian
2 # OS, where a separate postlinker will operated on the generated
3 # executable or shared object. See elf.sc for configuration variables
4 # that apply; only BPABI-specific variables will be noted here.
6 test -z "$ENTRY" && ENTRY=_start
7 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
8 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
9 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
10 test -z "${ELFSIZE}" && ELFSIZE=32
11 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
12 test "$LD_FLAG" = "N" && DATA_ADDR=.
13 test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
14 test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
15 test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
16 DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
17 DATA_SEGMENT_RELRO_END=""
18 DATA_SEGMENT_RELRO_GOTPLT_END=""
20 if test -n "${COMMONPAGESIZE}"; then
21 DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
22 DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
23 if test -n "${SEPARATE_GOTPLT}"; then
24 DATA_SEGMENT_RELRO_GOTPLT_END=". = DATA_SEGMENT_RELRO_END (. + ${SEPARATE_GOTPLT});"
26 DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (.);"
29 INTERP=".interp 0 : { *(.interp) }"
30 PLT=".plt ${RELOCATING-0} : { *(.plt) }"
31 RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
32 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }"
33 STACKNOTE="/DISCARD/ : { *(.note.GNU-stack) }"
34 if test -z "${NO_SMALL_DATA}"; then
35 SBSS=".sbss ${RELOCATING-0} :
37 ${RELOCATING+PROVIDE (__sbss_start = .);}
38 ${RELOCATING+PROVIDE (___sbss_start = .);}
40 *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
42 ${RELOCATING+PROVIDE (__sbss_end = .);}
43 ${RELOCATING+PROVIDE (___sbss_end = .);}
45 SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
46 SDATA="/* We want the small data sections together, so single-instruction offsets
47 can access them all, and initialized data all before uninitialized, so
48 we can shorten the on-disk segment size. */
49 .sdata ${RELOCATING-0} :
51 ${RELOCATING+${SDATA_START_SYMBOLS}}
52 *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
54 SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }"
55 REL_SDATA=".rel.sdata ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
56 .rela.sdata ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
57 REL_SBSS=".rel.sbss ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
58 .rela.sbss ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
59 REL_SDATA2=".rel.sdata2 ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
60 .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
61 REL_SBSS2=".rel.sbss2 ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
62 .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
66 test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
67 CTOR=".ctors ${CONSTRUCTING-0} :
69 ${CONSTRUCTING+${CTOR_START}}
70 /* gcc uses crtbegin.o to find the start of
71 the constructors, so we make sure it is
72 first. Because this is a wildcard, it
73 doesn't matter if the user does not
74 actually link against crtbegin.o; the
75 linker won't look for a file to match a
76 wildcard. The wildcard also means that it
77 doesn't matter which directory crtbegin.o
80 KEEP (*crtbegin*.o(.ctors))
82 /* We don't want to include the .ctor section from
83 from the crtend.o file until after the sorted ctors.
84 The .ctor section from the crtend file contains the
85 end of ctors marker and it must be last */
87 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
88 KEEP (*(SORT(.ctors.*)))
90 ${CONSTRUCTING+${CTOR_END}}
92 DTOR=".dtors ${CONSTRUCTING-0} :
94 ${CONSTRUCTING+${DTOR_START}}
95 KEEP (*crtbegin*.o(.dtors))
96 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
97 KEEP (*(SORT(.dtors.*)))
99 ${CONSTRUCTING+${DTOR_END}}
101 STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
103 ${RELOCATING+_stack = .;}
107 TEXT_START_ADDR="SEGMENT_START(\"text\", ${TEXT_START_ADDR})"
108 SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text\", ${SHLIB_TEXT_START_ADDR:-0})"
109 DATA_ADDR="SEGMENT_START(\"data\", ${DATA_ADDR-${DATA_SEGMENT_ALIGN}})"
110 SHLIB_DATA_ADDR="SEGMENT_START(\"data\", ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}})"
112 # if this is for an embedded system, don't add SIZEOF_HEADERS.
113 if [ -z "$EMBEDDED" ]; then
114 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
115 SHLIB_BASE_ADDRESS="${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS"
117 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
118 SHLIB_BASE_ADDRESS="${SHLIB_TEXT_START_ADDR}"
122 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
123 "${LITTLE_OUTPUT_FORMAT}")
124 OUTPUT_ARCH(${OUTPUT_ARCH})
127 ${RELOCATING+${LIB_SEARCH_DIRS}}
128 ${RELOCATING+/* Do we need any of these for elf?
129 __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */}
130 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
131 ${RELOCATING+${INPUT_FILES}}
132 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
133 if gld -r is used and the intermediate file has sections starting
134 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
135 bug. But for now assigning the zero vmas works. */}
137 /* ARM's proprietary toolchain generate these symbols to match the start
138 and end of particular sections of the image. SymbianOS uses these
139 symbols. We provide them for compatibility with ARM's toolchains.
140 These symbols should be bound locally; each shared object may define
141 its own version of these symbols. */
145 /* Give these a dummy version to work around linker lameness.
146 The name used shouldn't matter as these are all local symbols. */
149 Image\$\$ER_RO\$\$Base;
150 Image\$\$ER_RO\$\$Limit;
151 SHT\$\$INIT_ARRAY\$\$Base;
152 SHT\$\$INIT_ARRAY\$\$Limit;
160 /* Read-only sections, merged into text segment: */
161 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR});}}}
163 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+ . = ${TEXT_BASE_ADDRESS};}}}
164 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_BASE_ADDRESS};}}
165 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_BASE_ADDRESS};}}
167 /* Define Image\$\$ER_RO\$\$Base. */
168 ${RELOCATING+PROVIDE (Image\$\$ER_RO\$\$Base = .);}
170 ${INITIAL_READONLY_SECTIONS}
174 .init ${RELOCATING-0} :
176 ${RELOCATING+${INIT_START}}
178 ${RELOCATING+${INIT_END}}
180 .text ${RELOCATING-0} :
182 ${RELOCATING+${TEXT_START_SYMBOLS}}
183 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
184 KEEP (*(.text.*personality*))
185 /* .gnu.warning sections are handled specially by elf32.em. */
187 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
189 .fini ${RELOCATING-0} :
191 ${RELOCATING+${FINI_START}}
193 ${RELOCATING+${FINI_END}}
195 /* The SymbianOS kernel requires that the PLT go at the end of the
197 ${DATA_PLT-${BSS_PLT-${PLT}}}
198 ${RELOCATING+PROVIDE (__etext = .);}
199 ${RELOCATING+PROVIDE (_etext = .);}
200 ${RELOCATING+PROVIDE (etext = .);}
202 /* Define Image\$\$ER_RO\$\$Limit. */
203 ${RELOCATING+PROVIDE (Image\$\$ER_RO\$\$Limit = .);}
205 ${WRITABLE_RODATA-${RODATA}}
206 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
207 ${CREATE_SHLIB-${SDATA2}}
208 ${CREATE_SHLIB-${SBSS2}}
210 /* On SymbianOS, put .init_array and friends in the read-only
211 segment; there is no runtime relocation applied to these
214 /* Ensure the __preinit_array_start label is properly aligned. We
215 could instead move the label definition inside the section, but
216 the linker would then create the section even if it turns out to
217 be empty, which isn't pretty. */
218 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
219 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}}
220 .preinit_array ${RELOCATING-0} : { *(.preinit_array) }
221 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}}
223 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_start = .);}}
224 /* SymbianOS uses this symbol. */
225 ${RELOCATING+PROVIDE (SHT\$\$INIT_ARRAY\$\$Base = .);}
226 .init_array ${RELOCATING-0} : { *(.init_array) }
227 /* SymbianOS uses this symbol. */
228 ${RELOCATING+PROVIDE (SHT\$\$INIT_ARRAY\$\$Limit = .);}
229 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_end = .);}}
231 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_start = .);}}
232 .fini_array ${RELOCATING-0} : { *(.fini_array) }
233 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
235 ${OTHER_READONLY_SECTIONS}
236 .eh_frame_hdr : { *(.eh_frame_hdr) }
237 .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
238 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
240 /* Adjust the address for the data segment. We want to adjust up to
241 the same address within the page on the next page up. */
242 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR};}}}
243 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR};}}
244 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR};}}
246 /* Exception handling */
247 .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
248 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
250 /* Thread Local Storage sections */
251 .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
252 .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
254 ${RELOCATING+${CTOR}}
255 ${RELOCATING+${DTOR}}
256 .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
258 ${RELOCATING+${DATARELRO}}
259 ${OTHER_RELRO_SECTIONS}
260 ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
262 ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
264 .data ${RELOCATING-0} :
266 ${RELOCATING+${DATA_START_SYMBOLS}}
267 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
268 KEEP (*(.gnu.linkonce.d.*personality*))
269 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
271 .data1 ${RELOCATING-0} : { *(.data1) }
272 ${WRITABLE_RODATA+${RODATA}}
273 ${OTHER_READWRITE_SECTIONS}
274 ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
275 ${CREATE_SHLIB+${SDATA2}}
276 ${CREATE_SHLIB+${SBSS2}}
278 ${OTHER_SDATA_SECTIONS}
279 ${RELOCATING+_edata = .;}
280 ${RELOCATING+PROVIDE (edata = .);}
281 ${RELOCATING+. = DEFINED(__bss_segment_start) ? __bss_segment_start : .;}
282 ${RELOCATING+__bss_start = .;}
283 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
286 .bss ${RELOCATING-0} :
289 *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
291 /* Align here to ensure that the .bss section occupies space up to
292 _end. Align after .bss to ensure correct alignment even if the
293 .bss section disappears because there are no input sections. */
294 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
296 ${OTHER_BSS_SECTIONS}
297 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
298 ${RELOCATING+_end = .;}
299 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
300 ${RELOCATING+PROVIDE (end = .);}
301 ${RELOCATING+${DATA_SEGMENT_END}}
303 /* These sections are not mapped under the BPABI. */
304 .dynamic 0 : { *(.dynamic) }
305 .hash 0 : { *(.hash) }
306 .dynsym 0 : { *(.dynsym) }
307 .dynstr 0 : { *(.dynstr) }
308 .gnu.version 0 : { *(.gnu.version) }
309 .gnu.version_d 0: { *(.gnu.version_d) }
310 .gnu.version_r 0: { *(.gnu.version_r) }
311 ${CREATE_SHLIB-${INTERP}}
313 /* Stabs debugging sections. */
314 .stab 0 : { *(.stab) }
315 .stabstr 0 : { *(.stabstr) }
316 .stab.excl 0 : { *(.stab.excl) }
317 .stab.exclstr 0 : { *(.stab.exclstr) }
318 .stab.index 0 : { *(.stab.index) }
319 .stab.indexstr 0 : { *(.stab.indexstr) }
321 .comment 0 : { *(.comment) }
323 /* DWARF debug sections.
324 Symbols in the DWARF debugging sections are relative to the beginning
325 of the section so we begin them at 0. */
328 .debug 0 : { *(.debug) }
329 .line 0 : { *(.line) }
331 /* GNU DWARF 1 extensions */
332 .debug_srcinfo 0 : { *(.debug_srcinfo) }
333 .debug_sfnames 0 : { *(.debug_sfnames) }
335 /* DWARF 1.1 and DWARF 2 */
336 .debug_aranges 0 : { *(.debug_aranges) }
337 .debug_pubnames 0 : { *(.debug_pubnames) }
340 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
341 .debug_abbrev 0 : { *(.debug_abbrev) }
342 .debug_line 0 : { *(.debug_line) }
343 .debug_frame 0 : { *(.debug_frame) }
344 .debug_str 0 : { *(.debug_str) }
345 .debug_loc 0 : { *(.debug_loc) }
346 .debug_macinfo 0 : { *(.debug_macinfo) }
348 /* SGI/MIPS DWARF 2 extensions */
349 .debug_weaknames 0 : { *(.debug_weaknames) }
350 .debug_funcnames 0 : { *(.debug_funcnames) }
351 .debug_typenames 0 : { *(.debug_typenames) }
352 .debug_varnames 0 : { *(.debug_varnames) }
354 ${STACK_ADDR+${STACK}}
356 ${RELOCATING+${OTHER_END_SYMBOLS}}
357 ${RELOCATING+${STACKNOTE}}
360 # These relocations sections are part of the read-only segment in SVR4
361 # executables, but are not mapped in BPABI executables.
362 if [ "x$COMBRELOC" = x ]; then
365 COMBRELOCCAT="cat > $COMBRELOC"
367 eval $COMBRELOCCAT <<EOF
368 .rel.init 0 : { *(.rel.init) }
369 .rela.init 0 : { *(.rela.init) }
370 .rel.text 0 : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
371 .rela.text 0 : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
372 .rel.fini 0 : { *(.rel.fini) }
373 .rela.fini 0 : { *(.rela.fini) }
374 .rel.rodata 0 : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
375 .rela.rodata 0 : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
376 ${OTHER_READONLY_RELOC_SECTIONS}
377 .rel.data.rel.ro 0 : { *(.rel.data.rel.ro${RELOCATING+*}) }
378 .rela.data.rel.ro 0 : { *(.rel.data.rel.ro${RELOCATING+*}) }
379 .rel.data 0 : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
380 .rela.data 0 : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
381 .rel.tdata 0 : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
382 .rela.tdata 0 : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
383 .rel.tbss 0 : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
384 .rela.tbss 0 : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
385 .rel.ctors 0 : { *(.rel.ctors) }
386 .rela.ctors 0 : { *(.rela.ctors) }
387 .rel.dtors 0 : { *(.rel.dtors) }
388 .rela.dtors 0 : { *(.rela.dtors) }
393 .rel.bss 0 : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
394 .rela.bss 0 : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
395 .rel.init_array 0 : { *(.rel.init_array) }
396 .rela.init_array 0 : { *(.rela.init_array) }
397 .rel.fini_array 0 : { *(.rel.fini_array) }
398 .rela.fini_array 0 : { *(.rela.fini_array) }
400 if [ -n "$COMBRELOC" ]; then
405 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC
411 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC
417 .rel.plt 0 : { *(.rel.plt) }
418 .rela.plt 0 : { *(.rela.plt) }
419 ${OTHER_PLT_RELOC_SECTIONS}
420 .rel.other 0 : { *(.rel.*) }
421 .rela.other 0 : { *(.rela.*) }
422 .reli.other 0 : { *(.reli.*) }