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