* Makefile.in (earmsymbian.c): Depend on armbpabi.sc, not elf.sc.
[deliverable/binutils-gdb.git] / ld / scripttempl / armbpabi.sc
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.
5
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=""
19 DATA_SEGMENT_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});"
25 else
26 DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (.);"
27 fi
28 fi
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} :
36 {
37 ${RELOCATING+PROVIDE (__sbss_start = .);}
38 ${RELOCATING+PROVIDE (___sbss_start = .);}
39 *(.dynsbss)
40 *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
41 *(.scommon)
42 ${RELOCATING+PROVIDE (__sbss_end = .);}
43 ${RELOCATING+PROVIDE (___sbss_end = .);}
44 }"
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} :
50 {
51 ${RELOCATING+${SDATA_START_SYMBOLS}}
52 *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
53 }"
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.*}) }"
63 else
64 NO_SMALL_DATA=" "
65 fi
66 test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
67 CTOR=".ctors ${CONSTRUCTING-0} :
68 {
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
78 is in. */
79
80 KEEP (*crtbegin*.o(.ctors))
81
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 */
86
87 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
88 KEEP (*(SORT(.ctors.*)))
89 KEEP (*(.ctors))
90 ${CONSTRUCTING+${CTOR_END}}
91 }"
92 DTOR=".dtors ${CONSTRUCTING-0} :
93 {
94 ${CONSTRUCTING+${DTOR_START}}
95 KEEP (*crtbegin*.o(.dtors))
96 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
97 KEEP (*(SORT(.dtors.*)))
98 KEEP (*(.dtors))
99 ${CONSTRUCTING+${DTOR_END}}
100 }"
101 STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
102 {
103 ${RELOCATING+_stack = .;}
104 *(.stack)
105 }"
106
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}})"
111
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"
116 else
117 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
118 SHLIB_BASE_ADDRESS="${SHLIB_TEXT_START_ADDR}"
119 fi
120
121 cat <<EOF
122 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
123 "${LITTLE_OUTPUT_FORMAT}")
124 OUTPUT_ARCH(${OUTPUT_ARCH})
125 ENTRY(${ENTRY})
126
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. */}
136
137 SECTIONS
138 {
139 /* Read-only sections, merged into text segment: */
140 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
141 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_BASE_ADDRESS};}}
142 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_BASE_ADDRESS};}}
143 ${INITIAL_READONLY_SECTIONS}
144
145 EOF
146 cat <<EOF
147 .init ${RELOCATING-0} :
148 {
149 ${RELOCATING+${INIT_START}}
150 KEEP (*(.init))
151 ${RELOCATING+${INIT_END}}
152 } =${NOP-0}
153
154 ${DATA_PLT-${BSS_PLT-${PLT}}}
155 .text ${RELOCATING-0} :
156 {
157 ${RELOCATING+${TEXT_START_SYMBOLS}}
158 *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
159 KEEP (*(.text.*personality*))
160 /* .gnu.warning sections are handled specially by elf32.em. */
161 *(.gnu.warning)
162 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
163 } =${NOP-0}
164 .fini ${RELOCATING-0} :
165 {
166 ${RELOCATING+${FINI_START}}
167 KEEP (*(.fini))
168 ${RELOCATING+${FINI_END}}
169 } =${NOP-0}
170 ${RELOCATING+PROVIDE (__etext = .);}
171 ${RELOCATING+PROVIDE (_etext = .);}
172 ${RELOCATING+PROVIDE (etext = .);}
173 ${WRITABLE_RODATA-${RODATA}}
174 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
175 ${CREATE_SHLIB-${SDATA2}}
176 ${CREATE_SHLIB-${SBSS2}}
177 ${OTHER_READONLY_SECTIONS}
178 .eh_frame_hdr : { *(.eh_frame_hdr) }
179 .eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
180 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
181
182 /* Adjust the address for the data segment. We want to adjust up to
183 the same address within the page on the next page up. */
184 ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR};}}}
185 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR};}}
186 ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR};}}
187
188 /* Exception handling */
189 .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
190 .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
191
192 /* Thread Local Storage sections */
193 .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
194 .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
195
196 /* Ensure the __preinit_array_start label is properly aligned. We
197 could instead move the label definition inside the section, but
198 the linker would then create the section even if it turns out to
199 be empty, which isn't pretty. */
200 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
201 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}}
202 .preinit_array ${RELOCATING-0} : { *(.preinit_array) }
203 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}}
204
205 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_start = .);}}
206 .init_array ${RELOCATING-0} : { *(.init_array) }
207 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_end = .);}}
208
209 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_start = .);}}
210 .fini_array ${RELOCATING-0} : { *(.fini_array) }
211 ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
212
213 ${RELOCATING+${CTOR}}
214 ${RELOCATING+${DTOR}}
215 .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) }
216
217 ${RELOCATING+${DATARELRO}}
218 ${OTHER_RELRO_SECTIONS}
219 ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
220
221 ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
222
223 .data ${RELOCATING-0} :
224 {
225 ${RELOCATING+${DATA_START_SYMBOLS}}
226 *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
227 KEEP (*(.gnu.linkonce.d.*personality*))
228 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
229 }
230 .data1 ${RELOCATING-0} : { *(.data1) }
231 ${WRITABLE_RODATA+${RODATA}}
232 ${OTHER_READWRITE_SECTIONS}
233 ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
234 ${CREATE_SHLIB+${SDATA2}}
235 ${CREATE_SHLIB+${SBSS2}}
236 ${SDATA}
237 ${OTHER_SDATA_SECTIONS}
238 ${RELOCATING+_edata = .;}
239 ${RELOCATING+PROVIDE (edata = .);}
240 ${RELOCATING+. = DEFINED(__bss_segment_start) ? __bss_segment_start : .;}
241 ${RELOCATING+__bss_start = .;}
242 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
243 ${SBSS}
244 ${BSS_PLT+${PLT}}
245 .bss ${RELOCATING-0} :
246 {
247 *(.dynbss)
248 *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
249 *(COMMON)
250 /* Align here to ensure that the .bss section occupies space up to
251 _end. Align after .bss to ensure correct alignment even if the
252 .bss section disappears because there are no input sections. */
253 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
254 }
255 ${OTHER_BSS_SECTIONS}
256 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
257 ${RELOCATING+_end = .;}
258 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
259 ${RELOCATING+PROVIDE (end = .);}
260 ${RELOCATING+${DATA_SEGMENT_END}}
261
262 /* These sections are not mapped under the BPABI. */
263 .dynamic 0 : { *(.dynamic) }
264 .hash 0 : { *(.hash) }
265 .dynsym 0 : { *(.dynsym) }
266 .dynstr 0 : { *(.dynstr) }
267 .gnu.version 0 : { *(.gnu.version) }
268 .gnu.version_d 0: { *(.gnu.version_d) }
269 .gnu.version_r 0: { *(.gnu.version_r) }
270 ${CREATE_SHLIB-${INTERP}}
271
272 /* Stabs debugging sections. */
273 .stab 0 : { *(.stab) }
274 .stabstr 0 : { *(.stabstr) }
275 .stab.excl 0 : { *(.stab.excl) }
276 .stab.exclstr 0 : { *(.stab.exclstr) }
277 .stab.index 0 : { *(.stab.index) }
278 .stab.indexstr 0 : { *(.stab.indexstr) }
279
280 .comment 0 : { *(.comment) }
281
282 /* DWARF debug sections.
283 Symbols in the DWARF debugging sections are relative to the beginning
284 of the section so we begin them at 0. */
285
286 /* DWARF 1 */
287 .debug 0 : { *(.debug) }
288 .line 0 : { *(.line) }
289
290 /* GNU DWARF 1 extensions */
291 .debug_srcinfo 0 : { *(.debug_srcinfo) }
292 .debug_sfnames 0 : { *(.debug_sfnames) }
293
294 /* DWARF 1.1 and DWARF 2 */
295 .debug_aranges 0 : { *(.debug_aranges) }
296 .debug_pubnames 0 : { *(.debug_pubnames) }
297
298 /* DWARF 2 */
299 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
300 .debug_abbrev 0 : { *(.debug_abbrev) }
301 .debug_line 0 : { *(.debug_line) }
302 .debug_frame 0 : { *(.debug_frame) }
303 .debug_str 0 : { *(.debug_str) }
304 .debug_loc 0 : { *(.debug_loc) }
305 .debug_macinfo 0 : { *(.debug_macinfo) }
306
307 /* SGI/MIPS DWARF 2 extensions */
308 .debug_weaknames 0 : { *(.debug_weaknames) }
309 .debug_funcnames 0 : { *(.debug_funcnames) }
310 .debug_typenames 0 : { *(.debug_typenames) }
311 .debug_varnames 0 : { *(.debug_varnames) }
312
313 ${STACK_ADDR+${STACK}}
314 ${OTHER_SECTIONS}
315 ${RELOCATING+${OTHER_END_SYMBOLS}}
316 ${RELOCATING+${STACKNOTE}}
317 EOF
318
319 # These relocations sections are part of the read-only segment in SVR4
320 # executables, but are not mapped in BPABI executables.
321 if [ "x$COMBRELOC" = x ]; then
322 COMBRELOCCAT=cat
323 else
324 COMBRELOCCAT="cat > $COMBRELOC"
325 fi
326 eval $COMBRELOCCAT <<EOF
327 .rel.init 0 : { *(.rel.init) }
328 .rela.init 0 : { *(.rela.init) }
329 .rel.text 0 : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
330 .rela.text 0 : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
331 .rel.fini 0 : { *(.rel.fini) }
332 .rela.fini 0 : { *(.rela.fini) }
333 .rel.rodata 0 : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
334 .rela.rodata 0 : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
335 ${OTHER_READONLY_RELOC_SECTIONS}
336 .rel.data.rel.ro 0 : { *(.rel.data.rel.ro${RELOCATING+*}) }
337 .rela.data.rel.ro 0 : { *(.rel.data.rel.ro${RELOCATING+*}) }
338 .rel.data 0 : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
339 .rela.data 0 : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
340 .rel.tdata 0 : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
341 .rela.tdata 0 : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
342 .rel.tbss 0 : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
343 .rela.tbss 0 : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
344 .rel.ctors 0 : { *(.rel.ctors) }
345 .rela.ctors 0 : { *(.rela.ctors) }
346 .rel.dtors 0 : { *(.rel.dtors) }
347 .rela.dtors 0 : { *(.rela.dtors) }
348 ${REL_SDATA}
349 ${REL_SBSS}
350 ${REL_SDATA2}
351 ${REL_SBSS2}
352 .rel.bss 0 : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
353 .rela.bss 0 : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
354 EOF
355 if [ -n "$COMBRELOC" ]; then
356 cat <<EOF
357 .rel.dyn 0 :
358 {
359 EOF
360 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/ \1/' $COMBRELOC
361 cat <<EOF
362 }
363 .rela.dyn 0 :
364 {
365 EOF
366 sed -e '/^[ ]*[{}][ ]*$/d;/:[ ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/ \1/' $COMBRELOC
367 cat <<EOF
368 }
369 EOF
370 fi
371 cat <<EOF
372 .rel.plt 0 : { *(.rel.plt) }
373 .rela.plt 0 : { *(.rela.plt) }
374 ${OTHER_PLT_RELOC_SECTIONS}
375 }
376 EOF
This page took 0.037768 seconds and 4 git commands to generate.