patches for the mpss gcc
[barrelfish] / tools / k1om / broken / binutils-2.24-barrelfish.patch
1 diff --git a/bfd/config.bfd b/bfd/config.bfd
2 index 5324d39a21cb..3f0119ab2649 100644
3 --- a/bfd/config.bfd
4 +++ b/bfd/config.bfd
5 @@ -630,6 +630,10 @@ case "${targ}" in
6      targ64_selvecs="bfd_elf64_x86_64_nacl_vec bfd_elf32_x86_64_nacl_vec"
7      targ_archs="$targ_archs bfd_arm_arch"
8      ;;
9 +  i[3-7]86-*-barrelfish*)
10 +    targ_defvec=bfd_elf32_i386_vec
11 +    targ_selvecs=bfd_elf32_i386_vec
12 +    ;;
13  #ifdef BFD64
14    x86_64-*-darwin*)
15      targ_defvec=mach_o_x86_64_vec
16 @@ -673,6 +681,16 @@ case "${targ}" in
17      targ_archs="$targ_archs bfd_arm_arch"
18      want64=true
19      ;;
20 +  x86_64-k1om-barrelfish*)
21 +    targ_defvec=bfd_elf64_k1om_vec
22 +    targ_selvecs="bfd_elf32_x86_64_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec bfd_elf64_x86_64_vec"
23 +    want64=true
24 +    ;;
25 +  x86_64-*-barrelfish*)
26 +    targ_defvec=bfd_elf64_x86_64_vec
27 +    targ_selvecs=bfd_elf64_x86_64_vec
28 +    want64=true
29 +    ;;
30    x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin)
31      targ_defvec=x86_64pe_vec
32      targ_selvecs="x86_64pe_vec x86_64pei_vec bfd_elf64_x86_64_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec i386pe_vec i386pei_vec bfd_elf32_i386_vec"
33 diff --git a/config.sub b/config.sub
34 index 61cb4bc22db8..bc3ec8c48906 100755
35 --- a/config.sub
36 +++ b/config.sub
37 @@ -1357,6 +1357,7 @@ case $os in
38               | -sym* | -kopensolaris* | -plan9* \
39               | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
40               | -aos* | -aros* \
41 +             | -barrelfish* \
42               | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
43               | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
44               | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
45 diff --git a/configure b/configure
46 index ee45e1b00f90..5bb841e5899d 100755
47 --- a/configure
48 +++ b/configure
49 @@ -2953,7 +2953,7 @@ case "${ENABLE_GOLD}" in
50        *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
51        | *-*-linux* | *-*-gnu* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
52        | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* \
53 -      | *-*-solaris2* | *-*-nto* | *-*-nacl*)
54 +      | *-*-solaris2* | *-*-nto* | *-*-nacl* | *-*-barrelfish*)
55          case "${target}" in
56            *-*-linux*aout* | *-*-linux*oldld*)
57              ;;
58 diff --git a/gas/configure.tgt b/gas/configure.tgt
59 index 77c1d9b59246..5b32ae8f8a0c 100644
60 --- a/gas/configure.tgt
61 +++ b/gas/configure.tgt
62 @@ -270,6 +270,7 @@ case ${generic_target} in
63    i386-*-chaos)                                fmt=elf ;;
64    i386-*-rdos*)                                fmt=elf ;;
65    i386-*-darwin*)                      fmt=macho ;;
66 +  i386-*-barrelfish*)                  fmt=elf ;;
67
68    i860-*-*)                            fmt=elf endian=little ;;
69
70 diff --git a/ld/Makefile.am b/ld/Makefile.am
71 index b2b2a6ebe362..c01570b158ba 100644
72 --- a/ld/Makefile.am
73 +++ b/ld/Makefile.am
74 @@ -263,6 +263,7 @@ ALL_EMULATION_SOURCES = \
75         eelf32xstormy16.c \
76         eelf32xtensa.c \
77         eelf_i386.c \
78 +       ebarrelfish_i386.c \
79         eelf_i386_be.c \
80         eelf_i386_chaos.c \
81         eelf_i386_fbsd.c \
82 @@ -522,6 +522,8 @@ ALL_64_EMULATION_SOURCES = \
83         eelf_l1om_fbsd.c \
84         eelf_k1om.c \
85         eelf_k1om_fbsd.c \
86 +       ebarrelfish_x86_64.c \
87 +       ebarrelfish_k1om.c \
88         eelf_x86_64.c \
89         eelf_x86_64_fbsd.c \
90         eelf_x86_64_nacl.c \
91 @@ -1268,6 +1269,15 @@ eelf32xtensa.c: $(srcdir)/emulparams/elf32xtensa.sh $(ELF_DEPS) \
92  eelf_i386.c: $(srcdir)/emulparams/elf_i386.sh \
93    $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
94         ${GENSCRIPTS} elf_i386 "$(tdir_elf_i386)"
95 +ebarrelfish_i386.c: $(srcdir)/emulparams/barrelfish_i386.sh \
96 +  $(ELF_DEPS) $(srcdir)/scripttempl/elf-barrelfish.sc ${GEN_DEPENDS}
97 +       ${GENSCRIPTS} barrelfish_i386 "$(tdir_barrelfish_i386)"
98 +ebarrelfish_x86_64.c: $(srcdir)/emulparams/barrelfish_x86_64.sh \
99 +  $(ELF_DEPS) $(srcdir)/scripttempl/elf-barrelfish.sc ${GEN_DEPENDS}
100 +       ${GENSCRIPTS} barrelfish_x86_64 "$(tdir_barrelfish_x86_64)"
101 +ebarrelfish_k1om.c: $(srcdir)/emulparams/barrelfish_k1om.sh \
102 +  $(ELF_DEPS) $(srcdir)/scripttempl/elf-barrelfish.sc ${GEN_DEPENDS}
103 +       ${GENSCRIPTS} barrelfish_k1om "$(tdir_barrelfish_k1om)"
104  eelf_i386_be.c: $(srcdir)/emulparams/elf_i386_be.sh \
105    $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
106         ${GENSCRIPTS} elf_i386_be "$(tdir_elf_i386_be)"
107 diff --git a/ld/Makefile.in b/ld/Makefile.in
108 index b95a3d103de4..d41557b3334c 100644
109 --- a/ld/Makefile.in
110 +++ b/ld/Makefile.in
111 @@ -571,6 +571,7 @@ ALL_EMULATION_SOURCES = \
112         eelf32xstormy16.c \
113         eelf32xtensa.c \
114         eelf_i386.c \
115 +       ebarrelfish_i386.c \
116         eelf_i386_be.c \
117         eelf_i386_chaos.c \
118         eelf_i386_fbsd.c \
119 @@ -830,6 +832,8 @@ ALL_64_EMULATION_SOURCES = \
120         eelf_k1om.c \
121         eelf_k1om_fbsd.c \
122         eelf_x86_64.c \
123 +       ebarrelfish_x86_64.c \
124 +       ebarrelfish_k1om.c \
125         eelf_x86_64_fbsd.c \
126         eelf_x86_64_nacl.c \
127         eelf_x86_64_sol2.c \
128 @@ -3619,6 +3621,15 @@ eelf_k1om_fbsd.c: $(srcdir)/emulparams/elf_k1om_fbsd.sh \
129    $(srcdir)/emulparams/elf_k1om.sh \
130    $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
131         ${GENSCRIPTS} elf_k1om_fbsd "$(tdir_elf_k1om_fbsd)"
132 +ebarrelfish_i386.c: $(srcdir)/emulparams/barrelfish_i386.sh \
133 +  $(ELF_DEPS) $(srcdir)/scripttempl/elf-barrelfish.sc ${GEN_DEPENDS}
134 +       ${GENSCRIPTS} barrelfish_i386 "$(tdir_barrelfish_i386)"
135 +ebarrelfish_x86_64.c: $(srcdir)/emulparams/barrelfish_x86_64.sh \
136 +  $(ELF_DEPS) $(srcdir)/scripttempl/elf-barrelfish.sc ${GEN_DEPENDS}
137 +       ${GENSCRIPTS} barrelfish_x86_64 "$(tdir_barrelfish_x86_64)"
138 +ebarrelfish_k1om.c: $(srcdir)/emulparams/barrelfish_k1om.sh \
139 +  $(ELF_DEPS) $(srcdir)/scripttempl/elf-barrelfish.sc ${GEN_DEPENDS}
140 +       ${GENSCRIPTS} barrelfish_k1om "$(tdir_barrelfish_k1om)"
141  eelf_x86_64.c: $(srcdir)/emulparams/elf_x86_64.sh \
142    $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
143         ${GENSCRIPTS} elf_x86_64 "$(tdir_elf_x86_64)"
144 diff --git a/ld/configure.tgt b/ld/configure.tgt
145 index c50730b9c514..27702cbedc3a 100644
146 --- a/ld/configure.tgt
147 +++ b/ld/configure.tgt
148 @@ -224,6 +224,7 @@ i[3-7]86-*-bsd)             targ_emul=i386bsd ;;
149  i[3-7]86-*-bsd386)     targ_emul=i386bsd ;;
150  i[3-7]86-*-bsdi*)      targ_emul=i386bsd ;;
151  i[3-7]86-*-aout)       targ_emul=i386aout ;;
152 +i[3-7]86-*-barrelfish*)        targ_emul=barrelfish_i386 ;;
153  i[3-7]86-*-linux*aout*)        targ_emul=i386linux
154                         targ_extra_emuls=elf_i386
155                         tdir_elf_i386=`echo ${targ_alias} | sed -e 's/aout//'` ;;
156 @@ -244,6 +248,10 @@ x86_64-*-linux-*)  targ_emul=elf_x86_64
157                         targ_extra_libpath="elf_i386 elf32_x86_64 elf_l1om elf_k1om"
158                         tdir_i386linux=`echo ${targ_alias}aout | sed -e 's/x86_64/i386/'`
159                         tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'` ;;
160 +x86_64-k1om-barrelfish*) targ_emul=elf_k1om 
161 +                       targ_extra_emuls="barrelfish_k1om barrelfish_x86_64 " 
162 +                       targ_extra_libpath="elf_l1om barrelfish_k1om barrelfish_x86_64"         ;;
163 +x86_64-*-barrelfish*)  targ_emul=barrelfish_x86_64 ;;
164  i[3-7]86-*-sysv[45]*)  targ_emul=elf_i386 ;;
165  i[3-7]86-*-solaris2*)  targ_emul=elf_i386_sol2
166                         targ_extra_emuls="elf_i386_ldso elf_i386 elf_x86_64_sol2 elf_x86_64 elf_l1om elf_k1om"
167 diff --git a/ld/emulparams/barrelfish_i386.sh b/ld/emulparams/barrelfish_i386.sh
168 new file mode 100644
169 index 000000000000..032dd5ae18a3
170 --- /dev/null
171 +++ b/ld/emulparams/barrelfish_i386.sh
172 @@ -0,0 +1,14 @@
173 +. ${srcdir}/emulparams/plt_unwind.sh
174 +SCRIPT_NAME=elf-barrelfish
175 +OUTPUT_FORMAT="elf32-i386"
176 +NO_RELA_RELOCS=yes
177 +TEXT_START_ADDR=0x400000
178 +MAXPAGESIZE=0x1000
179 +COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
180 +ARCH=i386
181 +MACHINE=
182 +TEMPLATE_NAME=elf32
183 +GENERATE_SHLIB_SCRIPT=no
184 +GENERATE_PIE_SCRIPT=yes
185 +NO_SMALL_DATA=yes
186 +SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 12 ? 12 : 0"
187 diff --git a/ld/emulparams/barrelfish_x86_64.sh b/ld/emulparams/barrelfish_x86_64.sh
188 new file mode 100644
189 index 000000000000..bf4dafdd6b2b
190 --- /dev/null
191 +++ b/ld/emulparams/barrelfish_x86_64.sh
192 @@ -0,0 +1,16 @@
193 +. ${srcdir}/emulparams/plt_unwind.sh
194 +SCRIPT_NAME=elf-barrelfish
195 +ELFSIZE=64
196 +OUTPUT_FORMAT="elf64-x86-64"
197 +NO_RELA_RELOCS=yes
198 +TEXT_START_ADDR=0x400000
199 +MAXPAGESIZE=0x1000
200 +COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
201 +ARCH="i386:x86-64"
202 +MACHINE=
203 +TEMPLATE_NAME=elf32
204 +GENERATE_SHLIB_SCRIPT=no
205 +GENERATE_PIE_SCRIPT=yes
206 +NO_SMALL_DATA=yes
207 +LARGE_SECTIONS=yes
208 +SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 24 ? 24 : 0"
209 diff --git a/ld/emulparams/barrelfish_k1om.sh b/ld/emulparams/barrelfish_k1om.sh
210 new file mode 100644
211 index 000000000000..bf4dafdd6b2b
212 --- /dev/null
213 +++ b/ld/emulparams/barrelfish_k1om.sh
214 @@ -0,0 +1,17 @@
215 +. ${srcdir}/emulparams/plt_unwind.sh
216 +SCRIPT_NAME=elf-barrelfish
217 +ELFSIZE=64
218 +OUTPUT_FORMAT="elf64-k1om"
219 +NO_RELA_RELOCS=yes
220 +TEXT_START_ADDR=0x400000
221 +MAXPAGESIZE=0x1000
222 +COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
223 +ARCH="k1om"
224 +MACHINE=
225 +COMPILE_IN=yes
226 +TEMPLATE_NAME=elf32
227 +GENERATE_SHLIB_SCRIPT=yes
228 +GENERATE_PIE_SCRIPT=yes
229 +NO_SMALL_DATA=yes
230 +LARGE_SECTIONS=yes
231 +SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 24 ? 24 : 0"
232 diff --git a/ld/scripttempl/elf-barrelfish.sc b/ld/scripttempl/elf-barrelfish.sc
233 new file mode 100644
234 index 000000000000..51a655eed65c
235 --- /dev/null
236 +++ b/ld/scripttempl/elf-barrelfish.sc
237 @@ -0,0 +1,664 @@
238 +#
239 +# Unusual variables checked by this code:
240 +#      NOP - four byte opcode for no-op (defaults to none)
241 +#      NO_SMALL_DATA - no .sbss/.sbss2/.sdata/.sdata2 sections if not
242 +#              empty.
243 +#      SMALL_DATA_CTOR - .ctors contains small data.
244 +#      SMALL_DATA_DTOR - .dtors contains small data.
245 +#      DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
246 +#      INITIAL_READONLY_SECTIONS - at start of text segment
247 +#      OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
248 +#              (e.g., .PARISC.milli)
249 +#      OTHER_TEXT_SECTIONS - these get put in .text when relocating
250 +#      OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
251 +#              (e.g., .PARISC.global)
252 +#      OTHER_RELRO_SECTIONS - other than .data.rel.ro ...
253 +#              (e.g. PPC32 .fixup, .got[12])
254 +#      OTHER_BSS_SECTIONS - other than .bss .sbss ...
255 +#      ATTRS_SECTIONS - at the end
256 +#      OTHER_SECTIONS - at the end
257 +#      EXECUTABLE_SYMBOLS - symbols that must be defined for an
258 +#              executable (e.g., _DYNAMIC_LINK)
259 +#       TEXT_START_ADDR - the first byte of the text segment, after any
260 +#               headers.
261 +#       TEXT_BASE_ADDRESS - the first byte of the text segment.
262 +#      TEXT_START_SYMBOLS - symbols that appear at the start of the
263 +#              .text section.
264 +#      DATA_START_SYMBOLS - symbols that appear at the start of the
265 +#              .data section.
266 +#      DATA_END_SYMBOLS - symbols that appear at the end of the
267 +#              writeable data sections.
268 +#      OTHER_GOT_SYMBOLS - symbols defined just before .got.
269 +#      OTHER_GOT_SECTIONS - sections just after .got.
270 +#      OTHER_SDATA_SECTIONS - sections just after .sdata.
271 +#      OTHER_BSS_SYMBOLS - symbols that appear at the start of the
272 +#              .bss section besides __bss_start.
273 +#      DATA_PLT - .plt should be in data segment, not text segment.
274 +#      PLT_BEFORE_GOT - .plt just before .got when .plt is in data segement.
275 +#      BSS_PLT - .plt should be in bss segment
276 +#      NO_REL_RELOCS - Don't include .rel.* sections in script
277 +#      NO_RELA_RELOCS - Don't include .rela.* sections in script
278 +#      NON_ALLOC_DYN - Place dynamic sections after data segment.
279 +#      TEXT_DYNAMIC - .dynamic in text segment, not data segment.
280 +#      EMBEDDED - whether this is for an embedded system.
281 +#      SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
282 +#              start address of shared library.
283 +#      INPUT_FILES - INPUT command of files to always include
284 +#      WRITABLE_RODATA - if set, the .rodata section should be writable
285 +#      INIT_START, INIT_END -  statements just before and just after
286 +#      combination of .init sections.
287 +#      FINI_START, FINI_END - statements just before and just after
288 +#      combination of .fini sections.
289 +#      STACK_ADDR - start of a .stack section.
290 +#      OTHER_SYMBOLS - symbols to place right at the end of the script.
291 +#      ETEXT_NAME - name of a symbol for the end of the text section,
292 +#              normally etext.
293 +#      SEPARATE_CODE - if set, .text and similar sections containing
294 +#              actual machine instructions must be in wholly disjoint
295 +#              pages from any other data, including headers
296 +#      SEPARATE_GOTPLT - if set, .got.plt should be separate output section,
297 +#              so that .got can be in the RELRO area.  It should be set to
298 +#              the number of bytes in the beginning of .got.plt which can be
299 +#              in the RELRO area as well.
300 +#      USER_LABEL_PREFIX - prefix to add to user-visible symbols.
301 +#      RODATA_NAME, SDATA_NAME, SBSS_NAME, BSS_NAME - base parts of names
302 +#              for standard sections, without initial "." or suffixes.
303 +#
304 +# When adding sections, do note that the names of some sections are used
305 +# when specifying the start address of the next.
306 +#
307 +
308 +#  Many sections come in three flavours.  There is the 'real' section,
309 +#  like ".data".  Then there are the per-procedure or per-variable
310 +#  sections, generated by -ffunction-sections and -fdata-sections in GCC,
311 +#  and useful for --gc-sections, which for a variable "foo" might be
312 +#  ".data.foo".  Then there are the linkonce sections, for which the linker
313 +#  eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
314 +#  The exact correspondences are:
315 +#
316 +#  Section     Linkonce section
317 +#  .text       .gnu.linkonce.t.foo
318 +#  .rodata     .gnu.linkonce.r.foo
319 +#  .data       .gnu.linkonce.d.foo
320 +#  .bss                .gnu.linkonce.b.foo
321 +#  .sdata      .gnu.linkonce.s.foo
322 +#  .sbss       .gnu.linkonce.sb.foo
323 +#  .sdata2     .gnu.linkonce.s2.foo
324 +#  .sbss2      .gnu.linkonce.sb2.foo
325 +#  .debug_info .gnu.linkonce.wi.foo
326 +#  .tdata      .gnu.linkonce.td.foo
327 +#  .tbss       .gnu.linkonce.tb.foo
328 +#  .lrodata    .gnu.linkonce.lr.foo
329 +#  .ldata      .gnu.linkonce.l.foo
330 +#  .lbss       .gnu.linkonce.lb.foo
331 +#
332 +#  Each of these can also have corresponding .rel.* and .rela.* sections.
333 +
334 +if test -n "$NOP"; then
335 +  FILL="=$NOP"
336 +else
337 +  FILL=
338 +fi
339 +
340 +test -z "$RODATA_NAME" && RODATA_NAME=rodata
341 +test -z "$SDATA_NAME" && SDATA_NAME=sdata
342 +test -z "$SBSS_NAME" && SBSS_NAME=sbss
343 +test -z "$BSS_NAME" && BSS_NAME=bss
344 +test -z "$ENTRY" && ENTRY=${USER_LABEL_PREFIX}_start
345 +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
346 +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
347 +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
348 +test -z "${ELFSIZE}" && ELFSIZE=32
349 +test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
350 +test "$LD_FLAG" = "N" && DATA_ADDR=.
351 +test -z "${ETEXT_NAME}" && ETEXT_NAME=${USER_LABEL_PREFIX}etext
352 +test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
353 +test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
354 +test -n "$RELRO_NOW" && unset SEPARATE_GOTPLT
355 +test -z "$ATTRS_SECTIONS" && ATTRS_SECTIONS=".gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }"
356 +DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
357 +DATA_SEGMENT_RELRO_END=""
358 +DATA_SEGMENT_END=""
359 +if test -n "${COMMONPAGESIZE}"; then
360 +  DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
361 +  DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
362 +  DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
363 +fi
364 +if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
365 +  INITIAL_READONLY_SECTIONS=".interp       ${RELOCATING-0} : { *(.interp) }"
366 +fi
367 +if test -z "$PLT"; then
368 +  IPLT=".iplt         ${RELOCATING-0} : { *(.iplt) }"
369 +  PLT=".plt          ${RELOCATING-0} : { *(.plt)${IREL_IN_PLT+ *(.iplt)} }
370 +  ${IREL_IN_PLT-$IPLT}"
371 +fi
372 +test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes
373 +if test -z "$GOT"; then
374 +  if test -z "$SEPARATE_GOTPLT"; then
375 +    GOT=".got          ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }"
376 +  else
377 +    GOT=".got          ${RELOCATING-0} : { *(.got) *(.igot) }"
378 +    GOTPLT=".got.plt      ${RELOCATING-0} : { *(.got.plt)  *(.igot.plt) }"
379 +  fi
380 +fi
381 +REL_IFUNC=".rel.ifunc    ${RELOCATING-0} : { *(.rel.ifunc) }"
382 +RELA_IFUNC=".rela.ifunc   ${RELOCATING-0} : { *(.rela.ifunc) }"
383 +REL_IPLT=".rel.iplt     ${RELOCATING-0} :
384 +    {
385 +      ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}
386 +      *(.rel.iplt)
387 +      ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}
388 +    }"
389 +RELA_IPLT=".rela.iplt    ${RELOCATING-0} :
390 +    {
391 +      ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}
392 +      *(.rela.iplt)
393 +      ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}
394 +    }"
395 +DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
396 +RODATA=".${RODATA_NAME}       ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
397 +DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
398 +DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
399 +if test -z "${NO_SMALL_DATA}"; then
400 +  SBSS=".${SBSS_NAME}         ${RELOCATING-0} :
401 +  {
402 +    ${RELOCATING+${SBSS_START_SYMBOLS}}
403 +    ${CREATE_SHLIB+*(.${SBSS_NAME}2 .${SBSS_NAME}2.* .gnu.linkonce.sb2.*)}
404 +    *(.dyn${SBSS_NAME})
405 +    *(.${SBSS_NAME}${RELOCATING+ .${SBSS_NAME}.* .gnu.linkonce.sb.*})
406 +    *(.scommon)
407 +    ${RELOCATING+${SBSS_END_SYMBOLS}}
408 +  }"
409 +  SBSS2=".${SBSS_NAME}2        ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }"
410 +  SDATA="/* We want the small data sections together, so single-instruction offsets
411 +     can access them all, and initialized data all before uninitialized, so
412 +     we can shorten the on-disk segment size.  */
413 +  .${SDATA_NAME}        ${RELOCATING-0} :
414 +  {
415 +    ${RELOCATING+${SDATA_START_SYMBOLS}}
416 +    ${CREATE_SHLIB+*(.${SDATA_NAME}2 .${SDATA_NAME}2.* .gnu.linkonce.s2.*)}
417 +    *(.${SDATA_NAME}${RELOCATING+ .${SDATA_NAME}.* .gnu.linkonce.s.*})
418 +  }"
419 +  SDATA2=".${SDATA_NAME}2       ${RELOCATING-0} :
420 +  {
421 +    ${RELOCATING+${SDATA2_START_SYMBOLS}}
422 +    *(.${SDATA_NAME}2${RELOCATING+ .${SDATA_NAME}2.* .gnu.linkonce.s2.*})
423 +  }"
424 +  REL_SDATA=".rel.${SDATA_NAME}    ${RELOCATING-0} : { *(.rel.${SDATA_NAME}${RELOCATING+ .rel.${SDATA_NAME}.* .rel.gnu.linkonce.s.*}) }
425 +  .rela.${SDATA_NAME}   ${RELOCATING-0} : { *(.rela.${SDATA_NAME}${RELOCATING+ .rela.${SDATA_NAME}.* .rela.gnu.linkonce.s.*}) }"
426 +  REL_SBSS=".rel.${SBSS_NAME}     ${RELOCATING-0} : { *(.rel.${SBSS_NAME}${RELOCATING+ .rel.${SBSS_NAME}.* .rel.gnu.linkonce.sb.*}) }
427 +  .rela.${SBSS_NAME}    ${RELOCATING-0} : { *(.rela.${SBSS_NAME}${RELOCATING+ .rela.${SBSS_NAME}.* .rela.gnu.linkonce.sb.*}) }"
428 +  REL_SDATA2=".rel.${SDATA_NAME}2   ${RELOCATING-0} : { *(.rel.${SDATA_NAME}2${RELOCATING+ .rel.${SDATA_NAME}2.* .rel.gnu.linkonce.s2.*}) }
429 +  .rela.${SDATA_NAME}2  ${RELOCATING-0} : { *(.rela.${SDATA_NAME}2${RELOCATING+ .rela.${SDATA_NAME}2.* .rela.gnu.linkonce.s2.*}) }"
430 +  REL_SBSS2=".rel.${SBSS_NAME}2    ${RELOCATING-0} : { *(.rel.${SBSS_NAME}2${RELOCATING+ .rel.${SBSS_NAME}2.* .rel.gnu.linkonce.sb2.*}) }
431 +  .rela.${SBSS_NAME}2   ${RELOCATING-0} : { *(.rela.${SBSS_NAME}2${RELOCATING+ .rela.${SBSS_NAME}2.* .rela.gnu.linkonce.sb2.*}) }"
432 +else
433 +  NO_SMALL_DATA=" "
434 +fi
435 +if test -z "${DATA_GOT}"; then
436 +  if test -n "${NO_SMALL_DATA}"; then
437 +    DATA_GOT=" "
438 +  fi
439 +fi
440 +if test -z "${SDATA_GOT}"; then
441 +  if test -z "${NO_SMALL_DATA}"; then
442 +    SDATA_GOT=" "
443 +  fi
444 +fi
445 +test -n "$SEPARATE_GOTPLT" && SEPARATE_GOTPLT=" "
446 +test "${LARGE_SECTIONS}" = "yes" && REL_LARGE="
447 +  .rel.ldata    ${RELOCATING-0} : { *(.rel.ldata${RELOCATING+ .rel.ldata.* .rel.gnu.linkonce.l.*}) }
448 +  .rela.ldata   ${RELOCATING-0} : { *(.rela.ldata${RELOCATING+ .rela.ldata.* .rela.gnu.linkonce.l.*}) }
449 +  .rel.lbss     ${RELOCATING-0} : { *(.rel.lbss${RELOCATING+ .rel.lbss.* .rel.gnu.linkonce.lb.*}) }
450 +  .rela.lbss    ${RELOCATING-0} : { *(.rela.lbss${RELOCATING+ .rela.lbss.* .rela.gnu.linkonce.lb.*}) }
451 +  .rel.lrodata  ${RELOCATING-0} : { *(.rel.lrodata${RELOCATING+ .rel.lrodata.* .rel.gnu.linkonce.lr.*}) }
452 +  .rela.lrodata ${RELOCATING-0} : { *(.rela.lrodata${RELOCATING+ .rela.lrodata.* .rela.gnu.linkonce.lr.*}) }"
453 +test "${LARGE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS="
454 +  ${OTHER_BSS_SECTIONS}
455 +  .lbss ${RELOCATING-0} :
456 +  {
457 +    *(.dynlbss)
458 +    *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*})
459 +    *(LARGE_COMMON)
460 +  }"
461 +test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
462 +  .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
463 +  {
464 +    *(.lrodata${RELOCATING+ .lrodata.* .gnu.linkonce.lr.*})
465 +  }
466 +  .ldata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} :
467 +  {
468 +    *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*})
469 +    ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
470 +  }"
471 +if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then
472 +  SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))"
473 +  SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))"
474 +  CTORS_IN_INIT_ARRAY="KEEP (*(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))"
475 +  DTORS_IN_FINI_ARRAY="KEEP (*(EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))"
476 +else
477 +  SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))"
478 +  SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))"
479 +  CTORS_IN_INIT_ARRAY=
480 +  DTORS_IN_FINI_ARRAY=
481 +fi
482 +INIT_ARRAY=".init_array   ${RELOCATING-0} :
483 +  {
484 +    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
485 +    ${SORT_INIT_ARRAY}
486 +    KEEP (*(.init_array))
487 +    ${CTORS_IN_INIT_ARRAY}
488 +    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
489 +  }"
490 +FINI_ARRAY=".fini_array   ${RELOCATING-0} :
491 +  {
492 +    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
493 +    ${SORT_FINI_ARRAY}
494 +    KEEP (*(.fini_array))
495 +    ${DTORS_IN_FINI_ARRAY}
496 +    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
497 +  }"
498 +CTOR=".ctors        ${CONSTRUCTING-0} :
499 +  {
500 +    ${CONSTRUCTING+${CTOR_START}}
501 +    /* gcc uses crtbegin.o to find the start of
502 +       the constructors, so we make sure it is
503 +       first.  Because this is a wildcard, it
504 +       doesn't matter if the user does not
505 +       actually link against crtbegin.o; the
506 +       linker won't look for a file to match a
507 +       wildcard.  The wildcard also means that it
508 +       doesn't matter which directory crtbegin.o
509 +       is in.  */
510 +
511 +    KEEP (*crtbegin.o(.ctors))
512 +    KEEP (*crtbegin?.o(.ctors))
513 +
514 +    /* We don't want to include the .ctor section from
515 +       the crtend.o file until after the sorted ctors.
516 +       The .ctor section from the crtend file contains the
517 +       end of ctors marker and it must be last */
518 +
519 +    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
520 +    KEEP (*(SORT(.ctors.*)))
521 +    KEEP (*(.ctors))
522 +    ${CONSTRUCTING+${CTOR_END}}
523 +  }"
524 +DTOR=".dtors        ${CONSTRUCTING-0} :
525 +  {
526 +    ${CONSTRUCTING+${DTOR_START}}
527 +    KEEP (*crtbegin.o(.dtors))
528 +    KEEP (*crtbegin?.o(.dtors))
529 +    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
530 +    KEEP (*(SORT(.dtors.*)))
531 +    KEEP (*(.dtors))
532 +    ${CONSTRUCTING+${DTOR_END}}
533 +  }"
534 +STACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
535 +  {
536 +    ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;}
537 +    *(.stack)
538 +  }"
539 +
540 +TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})"
541 +SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})"
542 +
543 +if [ -z "$SEPARATE_CODE" ]; then
544 +  SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS"
545 +else
546 +  SIZEOF_HEADERS_CODE=
547 +fi
548 +
549 +# if this is for an embedded system, don't add SIZEOF_HEADERS.
550 +if [ -z "$EMBEDDED" ]; then
551 +   test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}${SIZEOF_HEADERS_CODE}"
552 +else
553 +   test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
554 +fi
555 +
556 +cat <<EOF
557 +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
558 +             "${LITTLE_OUTPUT_FORMAT}")
559 +OUTPUT_ARCH(${OUTPUT_ARCH})
560 +${RELOCATING+ENTRY(${ENTRY})}
561 +
562 +${RELOCATING+${LIB_SEARCH_DIRS}}
563 +${RELOCATING+${EXECUTABLE_SYMBOLS}}
564 +${RELOCATING+${INPUT_FILES}}
565 +${RELOCATING- /* For some reason, the Solaris linker makes bad executables
566 +  if gld -r is used and the intermediate file has sections starting
567 +  at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld
568 +  bug.  But for now assigning the zero vmas works.  */}
569 +
570 +SECTIONS
571 +{
572 +  /* Read-only sections, merged into text segment: */
573 +  ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
574 +  ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
575 +  ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
576 +EOF
577 +
578 +emit_early_ro()
579 +{
580 +  cat <<EOF
581 +  ${INITIAL_READONLY_SECTIONS}
582 +  .note.gnu.build-id : { *(.note.gnu.build-id) }
583 +EOF
584 +}
585 +
586 +test -n "${SEPARATE_CODE}" || emit_early_ro
587 +
588 +test -n "${RELOCATING+0}" || unset NON_ALLOC_DYN
589 +test -z "${NON_ALLOC_DYN}" || TEXT_DYNAMIC=
590 +cat > ldscripts/dyntmp.$$ <<EOF
591 +  ${TEXT_DYNAMIC+${DYNAMIC}}
592 +  .hash         ${RELOCATING-0} : { *(.hash) }
593 +  .gnu.hash     ${RELOCATING-0} : { *(.gnu.hash) }
594 +  .dynsym       ${RELOCATING-0} : { *(.dynsym) }
595 +  .dynstr       ${RELOCATING-0} : { *(.dynstr) }
596 +  .gnu.version  ${RELOCATING-0} : { *(.gnu.version) }
597 +  .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
598 +  .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
599 +EOF
600 +
601 +if [ "x$COMBRELOC" = x ]; then
602 +  COMBRELOCCAT="cat >> ldscripts/dyntmp.$$"
603 +else
604 +  COMBRELOCCAT="cat > $COMBRELOC"
605 +fi
606 +eval $COMBRELOCCAT <<EOF
607 +  ${INITIAL_RELOC_SECTIONS}
608 +  .rel.init     ${RELOCATING-0} : { *(.rel.init) }
609 +  .rela.init    ${RELOCATING-0} : { *(.rela.init) }
610 +  .rel.text     ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
611 +  .rela.text    ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
612 +  .rel.fini     ${RELOCATING-0} : { *(.rel.fini) }
613 +  .rela.fini    ${RELOCATING-0} : { *(.rela.fini) }
614 +  .rel.${RODATA_NAME}   ${RELOCATING-0} : { *(.rel.${RODATA_NAME}${RELOCATING+ .rel.${RODATA_NAME}.* .rel.gnu.linkonce.r.*}) }
615 +  .rela.${RODATA_NAME}  ${RELOCATING-0} : { *(.rela.${RODATA_NAME}${RELOCATING+ .rela.${RODATA_NAME}.* .rela.gnu.linkonce.r.*}) }
616 +  ${OTHER_READONLY_RELOC_SECTIONS}
617 +  .rel.data.rel.ro ${RELOCATING-0} : { *(.rel.data.rel.ro${RELOCATING+ .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*}) }
618 +  .rela.data.rel.ro ${RELOCATING-0} : { *(.rela.data.rel.ro${RELOCATING+ .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*}) }
619 +  .rel.data     ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
620 +  .rela.data    ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
621 +  ${OTHER_READWRITE_RELOC_SECTIONS}
622 +  .rel.tdata   ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
623 +  .rela.tdata  ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
624 +  .rel.tbss    ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
625 +  .rela.tbss   ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
626 +  .rel.ctors    ${RELOCATING-0} : { *(.rel.ctors) }
627 +  .rela.ctors   ${RELOCATING-0} : { *(.rela.ctors) }
628 +  .rel.dtors    ${RELOCATING-0} : { *(.rel.dtors) }
629 +  .rela.dtors   ${RELOCATING-0} : { *(.rela.dtors) }
630 +  .rel.got      ${RELOCATING-0} : { *(.rel.got) }
631 +  .rela.got     ${RELOCATING-0} : { *(.rela.got) }
632 +  ${OTHER_GOT_RELOC_SECTIONS}
633 +  ${REL_SDATA}
634 +  ${REL_SBSS}
635 +  ${REL_SDATA2}
636 +  ${REL_SBSS2}
637 +  .rel.${BSS_NAME}      ${RELOCATING-0} : { *(.rel.${BSS_NAME}${RELOCATING+ .rel.${BSS_NAME}.* .rel.gnu.linkonce.b.*}) }
638 +  .rela.${BSS_NAME}     ${RELOCATING-0} : { *(.rela.${BSS_NAME}${RELOCATING+ .rela.${BSS_NAME}.* .rela.gnu.linkonce.b.*}) }
639 +  ${REL_LARGE}
640 +  ${IREL_IN_PLT+$REL_IFUNC}
641 +  ${IREL_IN_PLT+$RELA_IFUNC}
642 +  ${IREL_IN_PLT-$REL_IPLT}
643 +  ${IREL_IN_PLT-$RELA_IPLT}
644 +EOF
645 +
646 +if [ -n "$COMBRELOC" ]; then
647 +cat >> ldscripts/dyntmp.$$ <<EOF
648 +  .rel.dyn      ${RELOCATING-0} :
649 +    {
650 +EOF
651 +sed -e '/^[    ]*[{}][         ]*$/d;/:[       ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/      \1/' $COMBRELOC >> ldscripts/dyntmp.$$
652 +cat >> ldscripts/dyntmp.$$ <<EOF
653 +    }
654 +  .rela.dyn     ${RELOCATING-0} :
655 +    {
656 +EOF
657 +sed -e '/^[    ]*[{}][         ]*$/d;/:[       ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/      \1/' $COMBRELOC >> ldscripts/dyntmp.$$
658 +cat >> ldscripts/dyntmp.$$ <<EOF
659 +    }
660 +EOF
661 +fi
662 +
663 +cat >> ldscripts/dyntmp.$$ <<EOF
664 +  .rel.plt      ${RELOCATING-0} :
665 +    {
666 +      *(.rel.plt)
667 +      ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_start = .);}}}
668 +      ${IREL_IN_PLT+${RELOCATING+*(.rel.iplt)}}
669 +      ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rel_iplt_end = .);}}}
670 +    }
671 +  .rela.plt     ${RELOCATING-0} :
672 +    {
673 +      *(.rela.plt)
674 +      ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_start = .);}}}
675 +      ${IREL_IN_PLT+${RELOCATING+*(.rela.iplt)}}
676 +      ${IREL_IN_PLT+${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__rela_iplt_end = .);}}}
677 +    }
678 +  ${OTHER_PLT_RELOC_SECTIONS}
679 +EOF
680 +
681 +emit_dyn()
682 +{
683 +  if test -z "${NO_REL_RELOCS}${NO_RELA_RELOCS}"; then
684 +    cat ldscripts/dyntmp.$$
685 +  else
686 +    if test -z "${NO_REL_RELOCS}"; then
687 +      sed -e '/^[      ]*\.rela\.[^}]*$/,/}/d' -e '/^[         ]*\.rela\./d' ldscripts/dyntmp.$$
688 +    fi
689 +    if test -z "${NO_RELA_RELOCS}"; then
690 +      sed -e '/^[      ]*\.rel\.[^}]*$/,/}/d' -e '/^[  ]*\.rel\./d' ldscripts/dyntmp.$$
691 +    fi
692 +  fi
693 +  rm -f ldscripts/dyntmp.$$
694 +}
695 +
696 +test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn
697 +
698 +cat <<EOF
699 +  .init         ${RELOCATING-0} :
700 +  {
701 +    ${RELOCATING+${INIT_START}}
702 +    KEEP (*(SORT_NONE(.init)))
703 +    ${RELOCATING+${INIT_END}}
704 +  } ${FILL}
705 +
706 +  ${TEXT_PLT+${PLT}}
707 +  ${TINY_READONLY_SECTION}
708 +  .text         ${RELOCATING-0} :
709 +  {
710 +    ${RELOCATING+${TEXT_START_SYMBOLS}}
711 +    ${RELOCATING+*(.text.unlikely .text.*_unlikely)}
712 +    ${RELOCATING+*(.text.exit .text.exit.*)}
713 +    ${RELOCATING+*(.text.startup .text.startup.*)}
714 +    ${RELOCATING+*(.text.hot .text.hot.*)}
715 +    *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
716 +    /* .gnu.warning sections are handled specially by elf32.em.  */
717 +    *(.gnu.warning)
718 +    ${RELOCATING+${OTHER_TEXT_SECTIONS}}
719 +  } ${FILL}
720 +  .fini         ${RELOCATING-0} :
721 +  {
722 +    ${RELOCATING+${FINI_START}}
723 +    KEEP (*(SORT_NONE(.fini)))
724 +    ${RELOCATING+${FINI_END}}
725 +  } ${FILL}
726 +  ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}
727 +  ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);}
728 +  ${RELOCATING+PROVIDE (${ETEXT_NAME} = .);}
729 +EOF
730 +
731 +if test -n "${SEPARATE_CODE}"; then
732 +  cat <<EOF
733 +  /* Adjust the address for the rodata segment.  We want to adjust up to
734 +     the same address within the page on the next page up.  */
735 +  ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${RODATA_ADDR-ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))};}}}
736 +  ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_RODATA_ADDR-ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
737 +  ${CREATE_PIE+${RELOCATING+. = ${SHLIB_RODATA_ADDR-ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
738 +EOF
739 +  emit_early_ro
740 +  emit_dyn
741 +fi
742 +
743 +cat <<EOF
744 +  ${WRITABLE_RODATA-${RODATA}}
745 +  .${RODATA_NAME}1      ${RELOCATING-0} : { *(.${RODATA_NAME}1) }
746 +  ${CREATE_SHLIB-${SDATA2}}
747 +  ${CREATE_SHLIB-${SBSS2}}
748 +  ${OTHER_READONLY_SECTIONS}
749 +  .eh_frame_hdr : { *(.eh_frame_hdr) }
750 +  .eh_frame     ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
751 +  .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table
752 +  .gcc_except_table.*) }
753 +  /* These sections are generated by the Sun/Oracle C++ compiler.  */
754 +  .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges
755 +  .exception_ranges*) }
756 +
757 +  /* Adjust the address for the data segment.  We want to adjust up to
758 +     the same address within the page on the next page up.  */
759 +  ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
760 +  ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
761 +  ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
762 +
763 +  /* Exception handling  */
764 +  .eh_frame     ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
765 +  .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
766 +  .exception_ranges ${RELOCATING-0} : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
767 +
768 +  /* Thread Local Storage sections  */
769 +  .tdata       ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
770 +  .tbss                ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
771 +
772 +  .preinit_array   ${RELOCATING-0} :
773 +  {
774 +    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
775 +    KEEP (*(.preinit_array))
776 +    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
777 +  }
778 +  ${RELOCATING+${INIT_ARRAY}}
779 +  ${RELOCATING+${FINI_ARRAY}}
780 +  ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
781 +  ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
782 +  .jcr          ${RELOCATING-0} : { KEEP (*(.jcr)) }
783 +
784 +  ${RELOCATING+${DATARELRO}}
785 +  ${OTHER_RELRO_SECTIONS}
786 +  ${TEXT_DYNAMIC-${DYNAMIC}}
787 +  ${DATA_GOT+${RELRO_NOW+${GOT}}}
788 +  ${DATA_GOT+${RELRO_NOW+${GOTPLT}}}
789 +  ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT+${GOT}}}}
790 +  ${RELOCATING+${DATA_SEGMENT_RELRO_END}}
791 +  ${DATA_GOT+${RELRO_NOW-${SEPARATE_GOTPLT-${GOT}}}}
792 +  ${DATA_GOT+${RELRO_NOW-${GOTPLT}}}
793 +
794 +  ${DATA_PLT+${PLT_BEFORE_GOT-${PLT}}}
795 +
796 +  .data         ${RELOCATING-0} :
797 +  {
798 +    ${RELOCATING+${DATA_START_SYMBOLS}}
799 +    *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
800 +    ${CONSTRUCTING+SORT(CONSTRUCTORS)}
801 +  }
802 +  .data1        ${RELOCATING-0} : { *(.data1) }
803 +  ${WRITABLE_RODATA+${RODATA}}
804 +  ${OTHER_READWRITE_SECTIONS}
805 +  ${SMALL_DATA_CTOR+${RELOCATING+${CTOR}}}
806 +  ${SMALL_DATA_DTOR+${RELOCATING+${DTOR}}}
807 +  ${DATA_PLT+${PLT_BEFORE_GOT+${PLT}}}
808 +  ${SDATA_GOT+${RELOCATING+${OTHER_GOT_SYMBOLS+. = .; ${OTHER_GOT_SYMBOLS}}}}
809 +  ${SDATA_GOT+${GOT}}
810 +  ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
811 +  ${SDATA}
812 +  ${OTHER_SDATA_SECTIONS}
813 +  ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
814 +  ${RELOCATING+. = .;}
815 +  ${RELOCATING+${USER_LABEL_PREFIX}__bss_start = .;}
816 +  ${RELOCATING+${OTHER_BSS_SYMBOLS}}
817 +  ${SBSS}
818 +  ${BSS_PLT+${PLT}}
819 +  .${BSS_NAME}          ${RELOCATING-0} :
820 +  {
821 +   *(.dyn${BSS_NAME})
822 +   *(.${BSS_NAME}${RELOCATING+ .${BSS_NAME}.* .gnu.linkonce.b.*})
823 +   *(COMMON)
824 +   /* Align here to ensure that the .bss section occupies space up to
825 +      _end.  Align after .bss to ensure correct alignment even if the
826 +      .bss section disappears because there are no input sections.
827 +      FIXME: Why do we need it? When there is no .bss section, we don't
828 +      pad the .data section.  */
829 +   ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);}
830 +  }
831 +  ${OTHER_BSS_SECTIONS}
832 +  ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
833 +  ${RELOCATING+. = ALIGN(${ALIGNMENT});}
834 +  ${LARGE_SECTIONS}
835 +  ${RELOCATING+. = ALIGN(${ALIGNMENT});}
836 +  ${RELOCATING+${OTHER_END_SYMBOLS}}
837 +  ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
838 +  ${RELOCATING+${DATA_SEGMENT_END}}
839 +EOF
840 +
841 +test -z "${NON_ALLOC_DYN}" || emit_dyn
842 +
843 +cat <<EOF
844 +  /* Stabs debugging sections.  */
845 +  .stab          0 : { *(.stab) }
846 +  .stabstr       0 : { *(.stabstr) }
847 +  .stab.excl     0 : { *(.stab.excl) }
848 +  .stab.exclstr  0 : { *(.stab.exclstr) }
849 +  .stab.index    0 : { *(.stab.index) }
850 +  .stab.indexstr 0 : { *(.stab.indexstr) }
851 +
852 +  .comment       0 : { *(.comment) }
853 +
854 +  /* DWARF debug sections.
855 +     Symbols in the DWARF debugging sections are relative to the beginning
856 +     of the section so we begin them at 0.  */
857 +
858 +  /* DWARF 1 */
859 +  .debug          0 : { *(.debug) }
860 +  .line           0 : { *(.line) }
861 +
862 +  /* GNU DWARF 1 extensions */
863 +  .debug_srcinfo  0 : { *(.debug_srcinfo) }
864 +  .debug_sfnames  0 : { *(.debug_sfnames) }
865 +
866 +  /* DWARF 1.1 and DWARF 2 */
867 +  .debug_aranges  0 : { *(.debug_aranges) }
868 +  .debug_pubnames 0 : { *(.debug_pubnames) }
869 +
870 +  /* DWARF 2 */
871 +  .debug_info     0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*}) }
872 +  .debug_abbrev   0 : { *(.debug_abbrev) }
873 +  .debug_line     0 : { *(.debug_line) }
874 +  .debug_frame    0 : { *(.debug_frame) }
875 +  .debug_str      0 : { *(.debug_str) }
876 +  .debug_loc      0 : { *(.debug_loc) }
877 +  .debug_macinfo  0 : { *(.debug_macinfo) }
878 +
879 +  /* SGI/MIPS DWARF 2 extensions */
880 +  .debug_weaknames 0 : { *(.debug_weaknames) }
881 +  .debug_funcnames 0 : { *(.debug_funcnames) }
882 +  .debug_typenames 0 : { *(.debug_typenames) }
883 +  .debug_varnames  0 : { *(.debug_varnames) }
884 +
885 +  /* DWARF 3 */
886 +  .debug_pubtypes 0 : { *(.debug_pubtypes) }
887 +  .debug_ranges   0 : { *(.debug_ranges) }
888 +
889 +  /* DWARF Extension.  */
890 +  .debug_macro    0 : { *(.debug_macro) } 
891 +  
892 +  ${TINY_DATA_SECTION}
893 +  ${TINY_BSS_SECTION}
894 +
895 +  ${STACK_ADDR+${STACK}}
896 +  ${ATTRS_SECTIONS}
897 +  ${OTHER_SECTIONS}
898 +  ${RELOCATING+${OTHER_SYMBOLS}}
899 +  ${RELOCATING+${DISCARDED}}
900 +}
901 +EOF