1214571Sdim#
2214571Sdim# Unusual variables checked by this code:
3214571Sdim#	NOP - four byte opcode for no-op (defaults to 0)
4214571Sdim#	NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
5214571Sdim#		empty.
6214571Sdim#	SMALL_DATA_CTOR - .ctors contains small data.
7214571Sdim#	SMALL_DATA_DTOR - .dtors contains small data.
8214571Sdim#	DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
9214571Sdim#	INITIAL_READONLY_SECTIONS - at start of text segment
10214571Sdim#	OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
11214571Sdim#		(e.g., .PARISC.milli)
12214571Sdim#	OTHER_TEXT_SECTIONS - these get put in .text when relocating
13214571Sdim#	OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
14214571Sdim#		(e.g., .PARISC.global)
15214571Sdim#	OTHER_RELRO_SECTIONS - other than .data.rel.ro ...
16214571Sdim#		(e.g. PPC32 .fixup, .got[12])
17214571Sdim#	OTHER_BSS_SECTIONS - other than .bss .sbss ...
18214571Sdim#	OTHER_SECTIONS - at the end
19214571Sdim#	EXECUTABLE_SYMBOLS - symbols that must be defined for an
20214571Sdim#		executable (e.g., _DYNAMIC_LINK)
21214571Sdim#       TEXT_START_ADDR - the first byte of the text segment, after any
22214571Sdim#               headers.
23214571Sdim#       TEXT_BASE_ADDRESS - the first byte of the text segment.
24214571Sdim#	TEXT_START_SYMBOLS - symbols that appear at the start of the
25214571Sdim#		.text section.
26214571Sdim#	DATA_START_SYMBOLS - symbols that appear at the start of the
27214571Sdim#		.data section.
28214571Sdim#	OTHER_GOT_SYMBOLS - symbols defined just before .got.
29214571Sdim#	OTHER_GOT_SECTIONS - sections just after .got.
30214571Sdim#	OTHER_SDATA_SECTIONS - sections just after .sdata.
31214571Sdim#	OTHER_BSS_SYMBOLS - symbols that appear at the start of the
32214571Sdim#		.bss section besides __bss_start.
33214571Sdim#	DATA_PLT - .plt should be in data segment, not text segment.
34214571Sdim#	PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement.
35214571Sdim#	BSS_PLT - .plt should be in bss segment
36214571Sdim#	TEXT_DYNAMIC - .dynamic in text segment, not data segment.
37214571Sdim#	EMBEDDED - whether this is for an embedded system. 
38214571Sdim#	SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
39214571Sdim#		start address of shared library.
40214571Sdim#	INPUT_FILES - INPUT command of files to always include
41214571Sdim#	WRITABLE_RODATA - if set, the .rodata section should be writable
42214571Sdim#	INIT_START, INIT_END -  statements just before and just after
43214571Sdim# 	combination of .init sections.
44214571Sdim#	FINI_START, FINI_END - statements just before and just after
45214571Sdim# 	combination of .fini sections.
46214571Sdim#	STACK_ADDR - start of a .stack section.
47214571Sdim#	OTHER_END_SYMBOLS - symbols to place right at the end of the script.
48214571Sdim#	SEPARATE_GOTPLT - if set, .got.plt should be separate output section,
49214571Sdim#		so that .got can be in the RELRO area.  It should be set to
50214571Sdim#		the number of bytes in the beginning of .got.plt which can be
51214571Sdim#		in the RELRO area as well.
52214571Sdim#
53214571Sdim# When adding sections, do note that the names of some sections are used
54214571Sdim# when specifying the start address of the next.
55214571Sdim#
56214571Sdim
57214571Sdim#  Many sections come in three flavours.  There is the 'real' section,
58214571Sdim#  like ".data".  Then there are the per-procedure or per-variable
59214571Sdim#  sections, generated by -ffunction-sections and -fdata-sections in GCC,
60214571Sdim#  and useful for --gc-sections, which for a variable "foo" might be
61214571Sdim#  ".data.foo".  Then there are the linkonce sections, for which the linker
62214571Sdim#  eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
63214571Sdim#  The exact correspondences are:
64214571Sdim#
65214571Sdim#  Section	Linkonce section
66214571Sdim#  .text	.gnu.linkonce.t.foo
67214571Sdim#  .rodata	.gnu.linkonce.r.foo
68214571Sdim#  .data	.gnu.linkonce.d.foo
69214571Sdim#  .bss		.gnu.linkonce.b.foo
70214571Sdim#  .sdata	.gnu.linkonce.s.foo
71214571Sdim#  .sbss	.gnu.linkonce.sb.foo
72214571Sdim#  .sdata2	.gnu.linkonce.s2.foo
73214571Sdim#  .sbss2	.gnu.linkonce.sb2.foo
74214571Sdim#  .debug_info	.gnu.linkonce.wi.foo
75214571Sdim#  .tdata	.gnu.linkonce.td.foo
76214571Sdim#  .tbss	.gnu.linkonce.tb.foo
77214571Sdim#
78214571Sdim#  Each of these can also have corresponding .rel.* and .rela.* sections.
79214571Sdim
80214571Sdimtest -z "$ENTRY" && ENTRY=_start
81214571Sdimtest -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
82214571Sdimtest -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
83214571Sdimif [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
84214571Sdimtest -z "${ELFSIZE}" && ELFSIZE=32
85214571Sdimtest -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
86214571Sdimtest "$LD_FLAG" = "N" && DATA_ADDR=.
87214571Sdimtest -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
88214571Sdimtest -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
89214571Sdimtest -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
90214571SdimDATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
91214571SdimDATA_SEGMENT_RELRO_END=""
92214571SdimDATA_SEGMENT_RELRO_GOTPLT_END=""
93214571SdimDATA_SEGMENT_END=""
94214571Sdimif test -n "${COMMONPAGESIZE}"; then
95214571Sdim  DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
96214571Sdim  DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
97214571Sdim  if test -n "${SEPARATE_GOTPLT}"; then
98214571Sdim    DATA_SEGMENT_RELRO_GOTPLT_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT}, .);"
99214571Sdim  else
100214571Sdim    DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (0, .);"
101214571Sdim  fi
102214571Sdimfi
103214571SdimINTERP=".interp       ${RELOCATING-0} : { *(.interp) }"
104214571SdimPLT=".plt          ${RELOCATING-0} : { *(.plt) }"
105214571Sdimif test -z "$GOT"; then
106214571Sdim  if test -z "$SEPARATE_GOTPLT"; then
107214571Sdim    GOT=".got          ${RELOCATING-0} : { *(.got.plt) *(.got) }"
108214571Sdim  else
109214571Sdim    GOT=".got          ${RELOCATING-0} : { *(.got) }"
110214571Sdim    GOTPLT="${RELOCATING+${DATA_SEGMENT_RELRO_GOTPLT_END}}
111214571Sdim  .got.plt      ${RELOCATING-0} : { *(.got.plt) }"
112214571Sdim  fi
113214571Sdimfi
114214571SdimDYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
115214571SdimRODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
116214571SdimDATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }"
117214571SdimSTACKNOTE="/DISCARD/ : { *(.note.GNU-stack) }"
118214571Sdimif test -z "${NO_SMALL_DATA}"; then
119214571Sdim  SBSS=".sbss         ${RELOCATING-0} :
120214571Sdim  {
121214571Sdim    ${RELOCATING+PROVIDE (__sbss_start = .);}
122214571Sdim    ${RELOCATING+PROVIDE (___sbss_start = .);}
123214571Sdim    ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)}
124214571Sdim    *(.dynsbss)
125214571Sdim    *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*})
126214571Sdim    *(.scommon)
127214571Sdim    ${RELOCATING+PROVIDE (__sbss_end = .);}
128214571Sdim    ${RELOCATING+PROVIDE (___sbss_end = .);}
129214571Sdim  }"
130214571Sdim  SBSS2=".sbss2        ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }"
131214571Sdim  SDATA="/* We want the small data sections together, so single-instruction offsets
132214571Sdim     can access them all, and initialized data all before uninitialized, so
133214571Sdim     we can shorten the on-disk segment size.  */
134214571Sdim  .sdata        ${RELOCATING-0} : 
135214571Sdim  {
136214571Sdim    ${RELOCATING+${SDATA_START_SYMBOLS}}
137214571Sdim    ${CREATE_SHLIB+*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)}
138214571Sdim    *(.sdata${RELOCATING+ .sdata.* .gnu.linkonce.s.*})
139214571Sdim  }"
140214571Sdim  SDATA2=".sdata2       ${RELOCATING-0} : { *(.sdata2${RELOCATING+ .sdata2.* .gnu.linkonce.s2.*}) }"
141214571Sdim  REL_SDATA=".rel.sdata    ${RELOCATING-0} : { *(.rel.sdata${RELOCATING+ .rel.sdata.* .rel.gnu.linkonce.s.*}) }
142214571Sdim  .rela.sdata   ${RELOCATING-0} : { *(.rela.sdata${RELOCATING+ .rela.sdata.* .rela.gnu.linkonce.s.*}) }"
143214571Sdim  REL_SBSS=".rel.sbss     ${RELOCATING-0} : { *(.rel.sbss${RELOCATING+ .rel.sbss.* .rel.gnu.linkonce.sb.*}) }
144214571Sdim  .rela.sbss    ${RELOCATING-0} : { *(.rela.sbss${RELOCATING+ .rela.sbss.* .rela.gnu.linkonce.sb.*}) }"
145214571Sdim  REL_SDATA2=".rel.sdata2   ${RELOCATING-0} : { *(.rel.sdata2${RELOCATING+ .rel.sdata2.* .rel.gnu.linkonce.s2.*}) }
146214571Sdim  .rela.sdata2  ${RELOCATING-0} : { *(.rela.sdata2${RELOCATING+ .rela.sdata2.* .rela.gnu.linkonce.s2.*}) }"
147214571Sdim  REL_SBSS2=".rel.sbss2    ${RELOCATING-0} : { *(.rel.sbss2${RELOCATING+ .rel.sbss2.* .rel.gnu.linkonce.sb2.*}) }
148214571Sdim  .rela.sbss2   ${RELOCATING-0} : { *(.rela.sbss2${RELOCATING+ .rela.sbss2.* .rela.gnu.linkonce.sb2.*}) }"
149214571Sdimelse
150214571Sdim  NO_SMALL_DATA=" "
151214571Sdimfi
152214571Sdimtest -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
153214571SdimCTOR=".ctors        ${CONSTRUCTING-0} : 
154214571Sdim  {
155214571Sdim    ${CONSTRUCTING+${CTOR_START}}
156214571Sdim    /* gcc uses crtbegin.o to find the start of
157214571Sdim       the constructors, so we make sure it is
158214571Sdim       first.  Because this is a wildcard, it
159214571Sdim       doesn't matter if the user does not
160214571Sdim       actually link against crtbegin.o; the
161214571Sdim       linker won't look for a file to match a
162214571Sdim       wildcard.  The wildcard also means that it
163214571Sdim       doesn't matter which directory crtbegin.o
164214571Sdim       is in.  */
165214571Sdim
166214571Sdim    KEEP (*crtbegin*.o(.ctors))
167214571Sdim
168214571Sdim    /* We don't want to include the .ctor section from
169214571Sdim       from the crtend.o file until after the sorted ctors.
170214571Sdim       The .ctor section from the crtend file contains the
171214571Sdim       end of ctors marker and it must be last */
172214571Sdim
173214571Sdim    KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
174214571Sdim    KEEP (*(SORT(.ctors.*)))
175214571Sdim    KEEP (*(.ctors))
176214571Sdim    ${CONSTRUCTING+${CTOR_END}}
177214571Sdim  }"
178214571SdimDTOR=".dtors        ${CONSTRUCTING-0} :
179214571Sdim  {
180214571Sdim    ${CONSTRUCTING+${DTOR_START}}
181214571Sdim    KEEP (*crtbegin*.o(.dtors))
182214571Sdim    KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
183214571Sdim    KEEP (*(SORT(.dtors.*)))
184214571Sdim    KEEP (*(.dtors))
185214571Sdim    ${CONSTRUCTING+${DTOR_END}}
186214571Sdim  }"
187214571SdimSTACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
188214571Sdim  {
189214571Sdim    ${RELOCATING+_stack = .;}
190214571Sdim    *(.stack)
191214571Sdim  }"
192214571Sdim
193214571Sdim# if this is for an embedded system, don't add SIZEOF_HEADERS.
194214571Sdimif [ -z "$EMBEDDED" ]; then
195214571Sdim   test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
196214571Sdimelse
197214571Sdim   test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
198214571Sdimfi
199214571Sdim
200214571Sdimcat <<EOF
201214571SdimOUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
202214571Sdim	      "${LITTLE_OUTPUT_FORMAT}")
203214571SdimOUTPUT_ARCH(${OUTPUT_ARCH})
204214571SdimENTRY(${ENTRY})
205214571Sdim
206214571Sdim${RELOCATING+${LIB_SEARCH_DIRS}}
207214571Sdim${RELOCATING+/* Do we need any of these for elf?
208214571Sdim   __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}}  */}
209214571Sdim${RELOCATING+${EXECUTABLE_SYMBOLS}}
210214571Sdim${RELOCATING+${INPUT_FILES}}
211214571Sdim${RELOCATING- /* For some reason, the Solaris linker makes bad executables
212214571Sdim  if gld -r is used and the intermediate file has sections starting
213214571Sdim  at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld
214214571Sdim  bug.  But for now assigning the zero vmas works.  */}
215214571Sdim
216214571SdimSECTIONS
217214571Sdim{
218214571Sdim  /* Read-only sections, merged into text segment: */
219214571Sdim  ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
220214571Sdim  ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
221214571Sdim  ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
222214571Sdim  ${CREATE_SHLIB-${INTERP}}
223214571Sdim  ${INITIAL_READONLY_SECTIONS}
224214571Sdim  ${TEXT_DYNAMIC+${DYNAMIC}}
225214571Sdim  .hash         ${RELOCATING-0} : { *(.hash) }
226214571Sdim  .dynsym       ${RELOCATING-0} : { *(.dynsym) }
227214571Sdim  .dynstr       ${RELOCATING-0} : { *(.dynstr) }
228214571Sdim  .gnu.version  ${RELOCATING-0} : { *(.gnu.version) }
229214571Sdim  .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
230214571Sdim  .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
231214571Sdim
232214571SdimEOF
233214571Sdimif [ "x$COMBRELOC" = x ]; then
234214571Sdim  COMBRELOCCAT=cat
235214571Sdimelse
236214571Sdim  COMBRELOCCAT="cat > $COMBRELOC"
237214571Sdimfi
238214571Sdimeval $COMBRELOCCAT <<EOF
239214571Sdim  .rel.init     ${RELOCATING-0} : { *(.rel.init) }
240214571Sdim  .rela.init    ${RELOCATING-0} : { *(.rela.init) }
241214571Sdim  .rel.text     ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
242214571Sdim  .rela.text    ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
243214571Sdim  .rel.fini     ${RELOCATING-0} : { *(.rel.fini) }
244214571Sdim  .rela.fini    ${RELOCATING-0} : { *(.rela.fini) }
245214571Sdim  .rel.rodata   ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
246214571Sdim  .rela.rodata  ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
247214571Sdim  ${OTHER_READONLY_RELOC_SECTIONS}
248214571Sdim  .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+*}) }
249214571Sdim  .rela.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+*}) }
250214571Sdim  .rel.data     ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
251214571Sdim  .rela.data    ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
252214571Sdim  .rel.tdata	${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
253214571Sdim  .rela.tdata	${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
254214571Sdim  .rel.tbss	${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
255214571Sdim  .rela.tbss	${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
256214571Sdim  .rel.ctors    ${RELOCATING-0} : { *(.rel.ctors) }
257214571Sdim  .rela.ctors   ${RELOCATING-0} : { *(.rela.ctors) }
258214571Sdim  .rel.dtors    ${RELOCATING-0} : { *(.rel.dtors) }
259214571Sdim  .rela.dtors   ${RELOCATING-0} : { *(.rela.dtors) }
260214571Sdim  .rel.got      ${RELOCATING-0} : { *(.rel.got) }
261214571Sdim  .rela.got     ${RELOCATING-0} : { *(.rela.got) }
262214571Sdim  ${OTHER_GOT_RELOC_SECTIONS}
263214571Sdim  ${REL_SDATA}
264214571Sdim  ${REL_SBSS}
265214571Sdim  ${REL_SDATA2}
266214571Sdim  ${REL_SBSS2}
267214571Sdim  .rel.bss      ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
268214571Sdim  .rela.bss     ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
269214571SdimEOF
270214571Sdimif [ -n "$COMBRELOC" ]; then
271214571Sdimcat <<EOF
272214571Sdim  .rel.dyn      ${RELOCATING-0} :
273214571Sdim    {
274214571SdimEOF
275214571Sdimsed -e '/^[ 	]*[{}][ 	]*$/d;/:[ 	]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/      \1/' $COMBRELOC
276214571Sdimcat <<EOF
277214571Sdim    }
278214571Sdim  .rela.dyn     ${RELOCATING-0} :
279214571Sdim    {
280214571SdimEOF
281214571Sdimsed -e '/^[ 	]*[{}][ 	]*$/d;/:[ 	]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/      \1/' $COMBRELOC
282214571Sdimcat <<EOF
283214571Sdim    }
284214571SdimEOF
285214571Sdimfi
286214571Sdimcat <<EOF
287214571Sdim  .rel.plt      ${RELOCATING-0} : { *(.rel.plt) }
288214571Sdim  .rela.plt     ${RELOCATING-0} : { *(.rela.plt) }
289214571Sdim  ${OTHER_PLT_RELOC_SECTIONS}
290214571Sdim
291214571Sdim  .init         ${RELOCATING-0} : 
292214571Sdim  { 
293214571Sdim    ${RELOCATING+${INIT_START}}
294214571Sdim    KEEP (*(.init))
295214571Sdim    ${RELOCATING+${INIT_END}}
296214571Sdim  } =${NOP-0}
297214571Sdim
298214571Sdim  ${DATA_PLT-${BSS_PLT-${PLT}}}
299214571Sdim  .text         ${RELOCATING-0} :
300214571Sdim  {
301214571Sdim    ${RELOCATING+${TEXT_START_SYMBOLS}}
302214571Sdim    *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
303214571Sdim    KEEP (*(.text.*personality*))
304214571Sdim    /* .gnu.warning sections are handled specially by elf32.em.  */
305214571Sdim    *(.gnu.warning)
306214571Sdim    ${RELOCATING+${OTHER_TEXT_SECTIONS}}
307214571Sdim  } =${NOP-0}
308214571Sdim  .fini         ${RELOCATING-0} :
309214571Sdim  {
310214571Sdim    ${RELOCATING+${FINI_START}}
311214571Sdim    KEEP (*(.fini))
312214571Sdim    ${RELOCATING+${FINI_END}}
313214571Sdim  } =${NOP-0}
314214571Sdim  ${RELOCATING+PROVIDE (__etext = .);}
315214571Sdim  ${RELOCATING+PROVIDE (_etext = .);}
316214571Sdim  ${RELOCATING+PROVIDE (etext = .);}
317214571Sdim  ${WRITABLE_RODATA-${RODATA}}
318214571Sdim  .rodata1      ${RELOCATING-0} : { *(.rodata1) }
319214571Sdim  ${CREATE_SHLIB-${SDATA2}}
320214571Sdim  ${CREATE_SHLIB-${SBSS2}}
321214571Sdim  ${OTHER_READONLY_SECTIONS}
322214571Sdim  .eh_frame_hdr : { *(.eh_frame_hdr) }
323214571Sdim  .eh_frame     ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
324214571Sdim  .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
325214571Sdim
326214571Sdim  /* Adjust the address for the data segment.  We want to adjust up to
327214571Sdim     the same address within the page on the next page up.  */
328214571Sdim  ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
329214571Sdim  ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
330214571Sdim  ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
331214571Sdim
332214571Sdim  /* Exception handling  */
333214571Sdim  .eh_frame     ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
334214571Sdim  .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
335214571Sdim
336214571Sdim  /* Thread Local Storage sections  */
337214571Sdim  .tdata	${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
338214571Sdim  .tbss		${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
339214571Sdim
340214571Sdim  .preinit_array   ${RELOCATING-0} : { KEEP (*(.preinit_array)) }
341214571Sdim  .init_array   ${RELOCATING-0} : { KEEP (*(.init_array)) }
342214571Sdim  .fini_array   ${RELOCATING-0} : { KEEP (*(.fini_array)) }
343214571Sdim
344214571Sdim  ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
345214571Sdim  ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
346214571Sdim  .jcr          ${RELOCATING-0} : { KEEP (*(.jcr)) }
347214571Sdim
348214571Sdim  ${RELOCATING+${DATARELRO}}
349214571Sdim  ${OTHER_RELRO_SECTIONS}
350214571Sdim  ${TEXT_DYNAMIC-${DYNAMIC}}
351214571Sdim  ${NO_SMALL_DATA+${RELRO_NOW+${GOT}}}
352214571Sdim  ${NO_SMALL_DATA+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
353214571Sdim  ${NO_SMALL_DATA+${RELRO_NOW-${SEPARATE_GOTPLT+${GOTPLT}}}}
354214571Sdim  ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
355214571Sdim  ${NO_SMALL_DATA+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
356214571Sdim
357214571Sdim  ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
358214571Sdim
359214571Sdim  .data         ${RELOCATING-0} :
360214571Sdim  {
361214571Sdim    ${RELOCATING+${DATA_START_SYMBOLS}}
362214571Sdim    *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
363214571Sdim    KEEP (*(.gnu.linkonce.d.*personality*))
364214571Sdim    ${CONSTRUCTING+SORT(CONSTRUCTORS)}
365214571Sdim  }
366214571Sdim  .data1        ${RELOCATING-0} : { *(.data1) }
367214571Sdim  ${WRITABLE_RODATA+${RODATA}}
368214571Sdim  ${OTHER_READWRITE_SECTIONS}
369214571Sdim  ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
370214571Sdim  ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
371214571Sdim  ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
372214571Sdim  ${RELOCATING+${OTHER_GOT_SYMBOLS}}
373214571Sdim  ${NO_SMALL_DATA-${GOT}}
374214571Sdim  ${OTHER_GOT_SECTIONS}
375214571Sdim  ${SDATA}
376214571Sdim  ${OTHER_SDATA_SECTIONS}
377214571Sdim  ${RELOCATING+_edata = .;}
378214571Sdim  ${RELOCATING+PROVIDE (edata = .);}
379214571Sdim  ${RELOCATING+__bss_start = .;}
380214571Sdim  ${RELOCATING+${OTHER_BSS_SYMBOLS}}
381214571Sdim  ${SBSS}
382214571Sdim  ${BSS_PLT+${PLT}}
383214571Sdim  .bss          ${RELOCATING-0} :
384214571Sdim  {
385214571Sdim   *(.dynbss)
386214571Sdim   *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
387214571Sdim   *(COMMON)
388214571Sdim   /* Align here to ensure that the .bss section occupies space up to
389214571Sdim      _end.  Align after .bss to ensure correct alignment even if the
390214571Sdim      .bss section disappears because there are no input sections.  */
391214571Sdim   ${RELOCATING+. = ALIGN(${ALIGNMENT});}
392214571Sdim  }
393214571Sdim  ${OTHER_BSS_SECTIONS}
394214571Sdim  ${RELOCATING+. = ALIGN(${ALIGNMENT});}
395214571Sdim  ${RELOCATING+_end = .;}
396214571Sdim  ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
397214571Sdim  ${RELOCATING+PROVIDE (end = .);}
398214571Sdim  ${RELOCATING+${DATA_SEGMENT_END}}
399214571Sdim
400214571Sdim  /* Stabs debugging sections.  */
401214571Sdim  .stab          0 : { *(.stab) }
402214571Sdim  .stabstr       0 : { *(.stabstr) }
403214571Sdim  .stab.excl     0 : { *(.stab.excl) }
404214571Sdim  .stab.exclstr  0 : { *(.stab.exclstr) }
405214571Sdim  .stab.index    0 : { *(.stab.index) }
406214571Sdim  .stab.indexstr 0 : { *(.stab.indexstr) }
407214571Sdim
408214571Sdim  .comment       0 : { *(.comment) }
409214571Sdim
410214571Sdim  /* DWARF debug sections.
411214571Sdim     Symbols in the DWARF debugging sections are relative to the beginning
412214571Sdim     of the section so we begin them at 0.  */
413214571Sdim
414214571Sdim  /* DWARF 1 */
415214571Sdim  .debug          0 : { *(.debug) }
416214571Sdim  .line           0 : { *(.line) }
417214571Sdim
418214571Sdim  /* GNU DWARF 1 extensions */
419214571Sdim  .debug_srcinfo  0 : { *(.debug_srcinfo) }
420214571Sdim  .debug_sfnames  0 : { *(.debug_sfnames) }
421214571Sdim
422214571Sdim  /* DWARF 1.1 and DWARF 2 */
423214571Sdim  .debug_aranges  0 : { *(.debug_aranges) }
424214571Sdim  .debug_pubnames 0 : { *(.debug_pubnames) }
425214571Sdim
426214571Sdim  /* DWARF 2 */
427214571Sdim  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
428214571Sdim  .debug_abbrev   0 : { *(.debug_abbrev) }
429214571Sdim  .debug_line     0 : { *(.debug_line) }
430214571Sdim  .debug_frame    0 : { *(.debug_frame) }
431214571Sdim  .debug_str      0 : { *(.debug_str) }
432214571Sdim  .debug_loc      0 : { *(.debug_loc) }
433214571Sdim  .debug_macinfo  0 : { *(.debug_macinfo) }
434214571Sdim
435214571Sdim  /* SGI/MIPS DWARF 2 extensions */
436214571Sdim  .debug_weaknames 0 : { *(.debug_weaknames) }
437214571Sdim  .debug_funcnames 0 : { *(.debug_funcnames) }
438214571Sdim  .debug_typenames 0 : { *(.debug_typenames) }
439214571Sdim  .debug_varnames  0 : { *(.debug_varnames) }
440214571Sdim
441214571Sdim  ${STACK_ADDR+${STACK}}
442214571Sdim  ${OTHER_SECTIONS}
443214571Sdim  ${RELOCATING+${OTHER_END_SYMBOLS}}
444214571Sdim  ${RELOCATING+${STACKNOTE}}
445214571Sdim}
446214571SdimEOF
447