* scripttempl/elf.sc (DISCARDED): Renamed from STACKNOTE. Add
[external/binutils.git] / ld / scripttempl / elfxtensa.sc
1 #
2 # Unusual variables checked by this code:
3 #       NOP - four byte opcode for no-op (defaults to 0)
4 #       NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
5 #               empty.
6 #       SMALL_DATA_CTOR - .ctors contains small data.
7 #       SMALL_DATA_DTOR - .dtors contains small data.
8 #       DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
9 #       INITIAL_READONLY_SECTIONS - at start of text segment
10 #       OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
11 #               (e.g., .PARISC.milli)
12 #       OTHER_TEXT_SECTIONS - these get put in .text when relocating
13 #       OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
14 #               (e.g., .PARISC.global)
15 #       OTHER_RELRO_SECTIONS - other than .data.rel.ro ...
16 #               (e.g. PPC32 .fixup, .got[12])
17 #       OTHER_BSS_SECTIONS - other than .bss .sbss ...
18 #       ATTRS_SECTIONS - at the end
19 #       OTHER_SECTIONS - at the end
20 #       EXECUTABLE_SYMBOLS - symbols that must be defined for an
21 #               executable (e.g., _DYNAMIC_LINK)
22 #       TEXT_START_ADDR - the first byte of the text segment, after any
23 #               headers.
24 #       TEXT_BASE_ADDRESS - the first byte of the text segment.
25 #       TEXT_START_SYMBOLS - symbols that appear at the start of the
26 #               .text section.
27 #       DATA_START_SYMBOLS - symbols that appear at the start of the
28 #               .data section.
29 #       DATA_END_SYMBOLS - symbols that appear at the end of the
30 #               writeable data sections.
31 #       OTHER_GOT_SYMBOLS - symbols defined just before .got.
32 #       OTHER_GOT_SECTIONS - sections just after .got.
33 #       OTHER_SDATA_SECTIONS - sections just after .sdata.
34 #       OTHER_BSS_SYMBOLS - symbols that appear at the start of the
35 #               .bss section besides __bss_start.
36 #       DATA_PLT - .plt should be in data segment, not text segment.
37 #       PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement.
38 #       BSS_PLT - .plt should be in bss segment
39 #       TEXT_DYNAMIC - .dynamic in text segment, not data segment.
40 #       EMBEDDED - whether this is for an embedded system. 
41 #       SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
42 #               start address of shared library.
43 #       INPUT_FILES - INPUT command of files to always include
44 #       WRITABLE_RODATA - if set, the .rodata section should be writable
45 #       INIT_START, INIT_END -  statements just before and just after
46 #       combination of .init sections.
47 #       FINI_START, FINI_END - statements just before and just after
48 #       combination of .fini sections.
49 #       STACK_ADDR - start of a .stack section.
50 #       OTHER_SYMBOLS - symbols to place right at the end of the script.
51 #       ETEXT_NAME - name of a symbol for the end of the text section,
52 #               normally etext.
53 #       SEPARATE_GOTPLT - if set, .got.plt should be separate output section,
54 #               so that .got can be in the RELRO area.  It should be set to
55 #               the number of bytes in the beginning of .got.plt which can be
56 #               in the RELRO area as well.
57 #       USER_LABEL_PREFIX - prefix to add to user-visible symbols.
58 #
59 # When adding sections, do note that the names of some sections are used
60 # when specifying the start address of the next.
61 #
62
63 #  Many sections come in three flavours.  There is the 'real' section,
64 #  like ".data".  Then there are the per-procedure or per-variable
65 #  sections, generated by -ffunction-sections and -fdata-sections in GCC,
66 #  and useful for --gc-sections, which for a variable "foo" might be
67 #  ".data.foo".  Then there are the linkonce sections, for which the linker
68 #  eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
69 #  The exact correspondences are:
70 #
71 #  Section      Linkonce section
72 #  .text        .gnu.linkonce.t.foo
73 #  .rodata      .gnu.linkonce.r.foo
74 #  .data        .gnu.linkonce.d.foo
75 #  .bss         .gnu.linkonce.b.foo
76 #  .sdata       .gnu.linkonce.s.foo
77 #  .sbss        .gnu.linkonce.sb.foo
78 #  .sdata2      .gnu.linkonce.s2.foo
79 #  .sbss2       .gnu.linkonce.sb2.foo
80 #  .debug_info  .gnu.linkonce.wi.foo
81 #  .tdata       .gnu.linkonce.td.foo
82 #  .tbss        .gnu.linkonce.tb.foo
83 #  .lrodata     .gnu.linkonce.lr.foo
84 #  .ldata       .gnu.linkonce.l.foo
85 #  .lbss        .gnu.linkonce.lb.foo
86 #
87 # plus exception-handling information for Tensilica's XCC compiler:
88 #  .xt_except_table .gnu.linkonce.e.foo
89 #  .xt_except_desc  .gnu.linkonce.h.foo
90 #
91 # plus Xtensa-specific literal sections:
92 #  .literal     .gnu.linkonce.literal.foo
93 #  .lit4        .gnu.linkonce.lit4.foo
94 #
95 # plus Xtensa-specific "property table" sections:
96 #  .xt.lit      .gnu.linkonce.p.foo
97 #  .xt.insn     .gnu.linkonce.x.foo (obsolete)
98 #  .xt.prop     .gnu.linkonce.prop.foo
99 #
100 #  Each of these can also have corresponding .rel.* and .rela.* sections.
101
102 test -z "$ENTRY" && ENTRY=_start
103 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
104 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
105 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
106 test -z "${ELFSIZE}" && ELFSIZE=32
107 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
108 test "$LD_FLAG" = "N" && DATA_ADDR=.
109 test -z "${ETEXT_NAME}" && ETEXT_NAME=etext
110 test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
111 test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
112 test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
113 test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
114 DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
115 DATA_SEGMENT_RELRO_END=""
116 DATA_SEGMENT_END=""
117 if test -n "${COMMONPAGESIZE}"; then
118   DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
119   DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
120   DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
121 fi
122 if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
123   INITIAL_READONLY_SECTIONS=".interp       ${RELOCATING-0} : { *(.interp) }"
124 fi
125 if test -z "$PLT"; then
126   PLT=".plt          ${RELOCATING-0} : { *(.plt) }"
127 fi
128 test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes
129 if test -z "$GOT"; then
130   if test -z "$SEPARATE_GOTPLT"; then
131     GOT=".got          ${RELOCATING-0} : { *(.got.plt) *(.got) }"
132   else
133     GOT=".got          ${RELOCATING-0} : { *(.got) }"
134     GOTPLT=".got.plt      ${RELOCATING-0} : { *(.got.plt) }"
135   fi
136 fi
137 DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
138 RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
139 DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }"
140 DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }"
141 INIT_LIT=".init.literal 0 : { *(.init.literal)  }"
142 INIT=".init         0 : { *(.init)              }"
143 FINI_LIT=".fini.literal 0 : { *(.fini.literal)  }"
144 FINI=".fini         0 : { *(.fini)              }"
145 if test -z "${NO_SMALL_DATA}"; then
146   SBSS=".sbss         ${RELOCATING-0} :
147   {
148     ${RELOCATING+${SBSS_START_SYMBOLS}}
149     ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)}
150     *(.dynsbss)
151     *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
152     *(.scommon)
153     ${RELOCATING+${SBSS_END_SYMBOLS}}
154   }"
155   SBSS2=".sbss2        ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
156   SDATA="/* We want the small data sections together, so single-instruction offsets
157      can access them all, and initialized data all before uninitialized, so
158      we can shorten the on-disk segment size.  */
159   .sdata        ${RELOCATING-0} : 
160   {
161     ${RELOCATING+${SDATA_START_SYMBOLS}}
162     ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)}
163     *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
164   }"
165   SDATA2=".sdata2       ${RELOCATING-0} :
166   {
167     ${RELOCATING+${SDATA2_START_SYMBOLS}}
168     *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*})
169   }"
170   REL_SDATA=".rel.sdata    ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
171   .rela.sdata   ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
172   REL_SBSS=".rel.sbss     ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
173   .rela.sbss    ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
174   REL_SDATA2=".rel.sdata2   ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
175   .rela.sdata2  ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
176   REL_SBSS2=".rel.sbss2    ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
177   .rela.sbss2   ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
178 else
179   NO_SMALL_DATA=" "
180 fi
181 if test -z "${DATA_GOT}"; then
182   if test -n "${NO_SMALL_DATA}"; then
183     DATA_GOT=" "
184   fi
185 fi
186 if test -z "${SDATA_GOT}"; then
187   if test -z "${NO_SMALL_DATA}"; then
188     SDATA_GOT=" "
189   fi
190 fi
191 test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
192 test "${LARGE_SECTIONS}" = "yes" && REL_LARGE="
193   .rel.ldata    ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) }
194   .rela.ldata   ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) }
195   .rel.lbss     ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) }
196   .rela.lbss    ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) }
197   .rel.lrodata  ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) }
198   .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }"
199 test "${LARGE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS="
200   ${OTHER_BSS_SECTIONS}
201   .lbss ${RELOCATING-0} :
202   {
203     *(.dynlbss)
204     *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
205     *(LARGE_COMMON)
206   }"
207 test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
208   .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
209   {
210     *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
211   }
212   .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
213   {
214     *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
215     ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
216   }"
217 CTOR=".ctors        ${CONSTRUCTING-0} : 
218   {
219     ${CONSTRUCTING+${CTOR_START}}
220     /* gcc uses crtbegin.o to find the start of
221        the constructors, so we make sure it is
222        first.  Because this is a wildcard, it
223        doesn't matter if the user does not
224        actually link against crtbegin.o; the
225        linker won't look for a file to match a
226        wildcard.  The wildcard also means that it
227        doesn't matter which directory crtbegin.o
228        is in.  */
229
230     KEEP (*crtbegin.o(.ctors))
231     KEEP (*crtbegin?.o(.ctors))
232
233     /* We don't want to include the .ctor section from
234        the crtend.o file until after the sorted ctors.
235        The .ctor section from the crtend file contains the
236        end of ctors marker and it must be last */
237
238     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
239     KEEP (*(SORT(.ctors.*)))
240     KEEP (*(.ctors))
241     ${CONSTRUCTING+${CTOR_END}}
242   }"
243 DTOR=".dtors        ${CONSTRUCTING-0} :
244   {
245     ${CONSTRUCTING+${DTOR_START}}
246     KEEP (*crtbegin.o(.dtors))
247     KEEP (*crtbegin?.o(.dtors))
248     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
249     KEEP (*(SORT(.dtors.*)))
250     KEEP (*(.dtors))
251     ${CONSTRUCTING+${DTOR_END}}
252   }"
253 STACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
254   {
255     ${RELOCATING+_stack = .;}
256     *(.stack)
257   }"
258
259 # if this is for an embedded system, don't add SIZEOF_HEADERS.
260 if [ -z "$EMBEDDED" ]; then
261    test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
262 else
263    test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
264 fi
265
266 cat <<EOF
267 ENTRY(${ENTRY})
268
269 ${RELOCATING+${LIB_SEARCH_DIRS}}
270 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
271 ${RELOCATING+${INPUT_FILES}}
272 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
273   if gld -r is used and the intermediate file has sections starting
274   at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld
275   bug.  But for now assigning the zero vmas works.  */}
276
277 SECTIONS
278 {
279   /* Read-only sections, merged into text segment: */
280   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
281   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
282   ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
283   ${INITIAL_READONLY_SECTIONS}
284   ${TEXT_DYNAMIC+${DYNAMIC}}
285   .hash         ${RELOCATING-0} : { *(.hash) }
286   .gnu.hash     ${RELOCATING-0} : { *(.gnu.hash) }
287   .dynsym       ${RELOCATING-0} : { *(.dynsym) }
288   .dynstr       ${RELOCATING-0} : { *(.dynstr) }
289   .gnu.version  ${RELOCATING-0} : { *(.gnu.version) }
290   .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
291   .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
292
293 EOF
294 if [ "x$COMBRELOC" = x ]; then
295   COMBRELOCCAT=cat
296 else
297   COMBRELOCCAT="cat > $COMBRELOC"
298 fi
299 eval $COMBRELOCCAT <<EOF
300   .rel.init     ${RELOCATING-0} : { *(.rel.init) }
301   .rela.init    ${RELOCATING-0} : { *(.rela.init) }
302   .rel.text     ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
303   .rela.text    ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
304   .rel.fini     ${RELOCATING-0} : { *(.rel.fini) }
305   .rela.fini    ${RELOCATING-0} : { *(.rela.fini) }
306   .rel.rodata   ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
307   .rela.rodata  ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
308   ${OTHER_READONLY_RELOC_SECTIONS}
309   .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+* .rel.gnu.linkonce.d.rel.ro.*}) }
310   .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+* .rela.gnu.linkonce.d.rel.ro.*}) }
311   .rel.data     ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
312   .rela.data    ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
313   .rel.tdata    ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
314   .rela.tdata   ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
315   .rel.tbss     ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
316   .rela.tbss    ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
317   .rel.ctors    ${RELOCATING-0} : { *(.rel.ctors) }
318   .rela.ctors   ${RELOCATING-0} : { *(.rela.ctors) }
319   .rel.dtors    ${RELOCATING-0} : { *(.rel.dtors) }
320   .rela.dtors   ${RELOCATING-0} : { *(.rela.dtors) }
321   .rel.got      ${RELOCATING-0} : { *(.rel.got) }
322   .rela.got     ${RELOCATING-0} : { *(.rela.got) }
323   ${OTHER_GOT_RELOC_SECTIONS}
324   ${REL_SDATA}
325   ${REL_SBSS}
326   ${REL_SDATA2}
327   ${REL_SBSS2}
328   .rel.bss      ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
329   .rela.bss     ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
330   ${REL_LARGE}
331 EOF
332 if [ -n "$COMBRELOC" ]; then
333 cat <<EOF
334   .rel.dyn      ${RELOCATING-0} :
335     {
336 EOF
337 sed -e '/^[     ]*[{}][         ]*$/d;/:[       ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/      \1/' $COMBRELOC
338 cat <<EOF
339     }
340   .rela.dyn     ${RELOCATING-0} :
341     {
342 EOF
343 sed -e '/^[     ]*[{}][         ]*$/d;/:[       ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/      \1/' $COMBRELOC
344 cat <<EOF
345     }
346 EOF
347 fi
348 cat <<EOF
349   .rel.plt      ${RELOCATING-0} : { *(.rel.plt) }
350   .rela.plt     ${RELOCATING-0} : { *(.rela.plt) }
351   ${OTHER_PLT_RELOC_SECTIONS}
352
353   ${RELOCATING-$INIT_LIT}
354   ${RELOCATING-$INIT}
355
356   ${TEXT_PLT+${PLT}}
357   ${TINY_READONLY_SECTION}
358   .text         ${RELOCATING-0} :
359   {
360     *(.got.plt* .plt*)
361
362     ${RELOCATING+${INIT_START}}
363     ${RELOCATING+KEEP (*(.init.literal))}
364     ${RELOCATING+KEEP (*(.init))}
365     ${RELOCATING+${INIT_END}}
366
367     ${RELOCATING+${TEXT_START_SYMBOLS}}
368     *(.literal .text .stub${RELOCATING+ .literal.* .text.* .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*})
369     KEEP (*(.text.*personality*))
370     /* .gnu.warning sections are handled specially by elf32.em.  */
371     *(.gnu.warning)
372     ${RELOCATING+${OTHER_TEXT_SECTIONS}}
373
374     ${RELOCATING+${FINI_START}}
375     ${RELOCATING+KEEP (*(.fini.literal))}
376     ${RELOCATING+KEEP (*(.fini))}
377     ${RELOCATING+${FINI_END}}
378   } =${NOP-0}
379
380   ${RELOCATING-$FINI_LIT}
381   ${RELOCATING-$FINI}
382
383   ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
384   ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);}
385   ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);}
386   ${WRITABLE_RODATA-${RODATA}}
387   .rodata1      ${RELOCATING-0} : { *(.rodata1) }
388   ${CREATE_SHLIB-${SDATA2}}
389   ${CREATE_SHLIB-${SBSS2}}
390   ${OTHER_READONLY_SECTIONS}
391   .eh_frame_hdr : { *(.eh_frame_hdr) }
392   .eh_frame     ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
393   .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
394
395   /* Adjust the address for the data segment.  We want to adjust up to
396      the same address within the page on the next page up.  */
397   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
398   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
399   ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
400
401   /* Exception handling  */
402   .eh_frame     ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
403   .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
404
405   /* Thread Local Storage sections  */
406   .tdata        ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
407   .tbss         ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
408
409   .preinit_array   ${RELOCATING-0} :
410   {
411     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
412     KEEP (*(.preinit_array))
413     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
414   }
415   .init_array   ${RELOCATING-0} :
416   {
417      ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
418      KEEP (*(SORT(.init_array.*)))
419      KEEP (*(.init_array))
420      ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
421   }
422   .fini_array   ${RELOCATING-0} :
423   {
424     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
425     KEEP (*(.fini_array))
426     KEEP (*(SORT(.fini_array.*)))
427     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
428   }
429   ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
430   ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
431   .jcr          ${RELOCATING-0} : { KEEP (*(.jcr)) }
432
433   ${RELOCATING+${DATARELRO}}
434   ${OTHER_RELRO_SECTIONS}
435   ${TEXT_DYNAMIC-${DYNAMIC}}
436   ${DATA_GOT+${RELRO_NOW+${GOT}}}
437   ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
438   ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
439   ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
440   ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
441   ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
442
443   ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
444
445   .data         ${RELOCATING-0} :
446   {
447     ${RELOCATING+${DATA_START_SYMBOLS}}
448     *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
449     ${RELOCATING+KEEP (*(.gnu.linkonce.d.*personality*))}
450     ${CONSTRUCTING+SORT(CONSTRUCTORS)}
451   }
452   .data1        ${RELOCATING-0} : { *(.data1) }
453   ${WRITABLE_RODATA+${RODATA}}
454   ${OTHER_READWRITE_SECTIONS}
455   ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
456   ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
457   ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
458   ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS}}}
459   ${SDATA_GOT+${GOT}}
460   ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
461   ${SDATA}
462   ${OTHER_SDATA_SECTIONS}
463   ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
464   ${RELOCATING+__bss_start = .;}
465   ${RELOCATING+${OTHER_BSS_SYMBOLS}}
466   ${SBSS}
467   ${BSS_PLT+${PLT}}
468   .bss          ${RELOCATING-0} :
469   {
470    *(.dynbss)
471    *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
472    *(COMMON)
473    /* Align here to ensure that the .bss section occupies space up to
474       _end.  Align after .bss to ensure correct alignment even if the
475       .bss section disappears because there are no input sections.
476       FIXME: Why do we need it? When there is no .bss section, we don't
477       pad the .data section.  */
478    ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
479   }
480   ${OTHER_BSS_SECTIONS}
481   ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
482   ${RELOCATING+. = ALIGN(${ALIGNMENT});}
483   ${LARGE_SECTIONS}
484   ${RELOCATING+. = ALIGN(${ALIGNMENT});}
485   ${RELOCATING+${OTHER_END_SYMBOLS}}
486   ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
487   ${RELOCATING+${DATA_SEGMENT_END}}
488
489   /* Stabs debugging sections.  */
490   .stab          0 : { *(.stab) }
491   .stabstr       0 : { *(.stabstr) }
492   .stab.excl     0 : { *(.stab.excl) }
493   .stab.exclstr  0 : { *(.stab.exclstr) }
494   .stab.index    0 : { *(.stab.index) }
495   .stab.indexstr 0 : { *(.stab.indexstr) }
496
497   .comment       0 : { *(.comment) }
498
499   /* DWARF debug sections.
500      Symbols in the DWARF debugging sections are relative to the beginning
501      of the section so we begin them at 0.  */
502
503   /* DWARF 1 */
504   .debug          0 : { *(.debug) }
505   .line           0 : { *(.line) }
506
507   /* GNU DWARF 1 extensions */
508   .debug_srcinfo  0 : { *(.debug_srcinfo) }
509   .debug_sfnames  0 : { *(.debug_sfnames) }
510
511   /* DWARF 1.1 and DWARF 2 */
512   .debug_aranges  0 : { *(.debug_aranges) }
513   .debug_pubnames 0 : { *(.debug_pubnames) }
514
515   /* DWARF 2 */
516   .debug_info     0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*}) }
517   .debug_abbrev   0 : { *(.debug_abbrev) }
518   .debug_line     0 : { *(.debug_line) }
519   .debug_frame    0 : { *(.debug_frame) }
520   .debug_str      0 : { *(.debug_str) }
521   .debug_loc      0 : { *(.debug_loc) }
522   .debug_macinfo  0 : { *(.debug_macinfo) }
523
524   /* SGI/MIPS DWARF 2 extensions */
525   .debug_weaknames 0 : { *(.debug_weaknames) }
526   .debug_funcnames 0 : { *(.debug_funcnames) }
527   .debug_typenames 0 : { *(.debug_typenames) }
528   .debug_varnames  0 : { *(.debug_varnames) }
529
530   /* DWARF 3 */
531   .debug_pubtypes 0 : { *(.debug_pubtypes) }
532   .debug_ranges   0 : { *(.debug_ranges) }
533
534   ${TINY_DATA_SECTION}
535   ${TINY_BSS_SECTION}
536
537   ${STACK_ADDR+${STACK}}
538   ${ATTRS_SECTIONS}
539   ${OTHER_SECTIONS}
540   ${RELOCATING+${OTHER_SYMBOLS}}
541   ${RELOCATING+${DISCARDED}}
542 }
543 EOF