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