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