From 2bf2bf23da5237f465fdbb759657aeb7825a08a3 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 12 Oct 2018 12:06:40 +1030 Subject: [PATCH] ELF ld -r scripts "ld -r" generally should not combine object file sections with different names. For example, "ld -r" should not combine ".text", ".text.hot" and ".text.cold" into an output ".text" section. An exception needs to be made for linker created sections, for example, branch trampoline sections that might be created even for ld -r. "ld -r" also should not define symbols in linker scripts. Any definitions are likely to conflict with those defined at final link. A MEMORY spec is also not needed for ld -r. * Makefile.am (eelf32btsmip_fbsd.c, eelf32btsmipn32_fbsd.c), (eelf32epiphany.c, eelf32epiphany_4x4.c, eelf32ltsmip_fbsd.c), (eelf32ltsmipn32_fbsd.c, eelf32xc16x.c, eelf32xc16xl.c), (eelf32xc16xs.c, emcorepe.c, enios2elf.c, enios2linux.c), (eelf64btsmip_fbsd.c, eelf64ltsmip_fbsd.c): Correct dependencies. * Makefile.in: Regenerate. * emulparams/aarch64cloudabi.sh, * emulparams/aarch64fbsd.sh, * emulparams/aarch64linux.sh, * emulparams/aarch64linux32.sh, * emulparams/arc-nps.sh, * emulparams/elf32_spu.sh, * emulparams/elf32_tic6x_le.sh, * emulparams/elf32bmip.sh, * emulparams/elf32btsmipn32.sh, * emulparams/elf32lr5900n32.sh, * emulparams/elf32mep.sh, * emulparams/elf32metag.sh, * emulparams/elf64btsmip.sh, * emulparams/shelf_vxworks.sh, * emulparams/shlelf_fd.sh, * scripttempl/DWARF.sc, * scripttempl/alpha.sc, * scripttempl/alphavms.sc, * scripttempl/arclinux.sc, * scripttempl/armbpabi.sc, * scripttempl/avr.sc, * scripttempl/dlx.sc, * scripttempl/elf.sc, * scripttempl/elf32cr16.sc, * scripttempl/elf32cr16c.sc, * scripttempl/elf32crx.sc, * scripttempl/elf32msp430.sc, * scripttempl/elf32msp430_3.sc, * scripttempl/elf32xc16x.sc, * scripttempl/elf32xc16xl.sc, * scripttempl/elf32xc16xs.sc, * scripttempl/elf64hppa.sc, * scripttempl/elf_chaos.sc, * scripttempl/elfarc.sc, * scripttempl/elfarcv2.sc, * scripttempl/elfd10v.sc, * scripttempl/elfd30v.sc, * scripttempl/elfm68hc11.sc, * scripttempl/elfm68hc12.sc, * scripttempl/elfm9s12z.sc, * scripttempl/elfmicroblaze.sc, * scripttempl/elfxgate.sc, * scripttempl/elfxtensa.sc, * scripttempl/epiphany_4x4.sc, * scripttempl/ft32.sc, * scripttempl/hppaelf.sc, * scripttempl/ia64vms.sc, * scripttempl/ip2k.sc, * scripttempl/iq2000.sc, * scripttempl/mep.sc, * scripttempl/mmo.sc, * scripttempl/nds32elf.sc, * scripttempl/pru.sc, * scripttempl/sh.sc, * scripttempl/v850.sc, * scripttempl/v850_rh850.sc, * scripttempl/visium.sc, * scripttempl/xstormy16.sc: Condition various parts of scripts on ${RELOCATABLE} in order to prevent ld -r merging sections or defining symbols. Remove MEMORY and VERSION definitions from ld -r scripts too. * testsuite/ld-elf/group2.d, * testsuite/ld-elf/group4.d, * testsuite/ld-elf/group5.d, * testsuite/ld-elf/group6.d, * testsuite/ld-elf/group7.d, * testsuite/ld-elf/group8a.d, * testsuite/ld-elf/group8b.d, * testsuite/ld-elf/group9a.d, * testsuite/ld-elf/group9b.d, * testsuite/ld-elf/pr17550a.d, * testsuite/ld-elf/pr17550b.d, * testsuite/ld-elf/pr17550d.d: Don't xfail cr16 and crx. * testsuite/ld-elf/init-fini-arrays.d, * testsuite/ld-elf/pr22677.d: Likewise, and dont' xfail mep. --- ld/ChangeLog | 50 +++++++++++++++ ld/Makefile.am | 26 +++++--- ld/Makefile.in | 26 +++++--- ld/emulparams/aarch64cloudabi.sh | 2 +- ld/emulparams/aarch64fbsd.sh | 2 +- ld/emulparams/aarch64linux.sh | 2 +- ld/emulparams/aarch64linux32.sh | 2 +- ld/emulparams/arc-nps.sh | 2 + ld/emulparams/elf32_spu.sh | 4 +- ld/emulparams/elf32_tic6x_le.sh | 4 +- ld/emulparams/elf32bmip.sh | 8 +-- ld/emulparams/elf32btsmipn32.sh | 8 +-- ld/emulparams/elf32lr5900n32.sh | 8 +-- ld/emulparams/elf32mep.sh | 3 + ld/emulparams/elf32metag.sh | 2 +- ld/emulparams/elf64btsmip.sh | 8 +-- ld/emulparams/shelf_vxworks.sh | 4 +- ld/emulparams/shlelf_fd.sh | 2 +- ld/scripttempl/DWARF.sc | 2 +- ld/scripttempl/alpha.sc | 16 ++--- ld/scripttempl/alphavms.sc | 12 ++-- ld/scripttempl/arclinux.sc | 44 ++++++------- ld/scripttempl/armbpabi.sc | 36 ++++++----- ld/scripttempl/avr.sc | 68 ++++++++++---------- ld/scripttempl/dlx.sc | 6 +- ld/scripttempl/elf.sc | 88 +++++++++++++------------- ld/scripttempl/elf32cr16.sc | 38 +++++++---- ld/scripttempl/elf32cr16c.sc | 40 +++++++----- ld/scripttempl/elf32crx.sc | 4 ++ ld/scripttempl/elf32msp430.sc | 73 +++++++++++---------- ld/scripttempl/elf32msp430_3.sc | 37 +++++++---- ld/scripttempl/elf32xc16x.sc | 16 +++-- ld/scripttempl/elf32xc16xl.sc | 16 +++-- ld/scripttempl/elf32xc16xs.sc | 17 +++-- ld/scripttempl/elf64hppa.sc | 28 ++++---- ld/scripttempl/elf_chaos.sc | 28 ++++---- ld/scripttempl/elfarc.sc | 52 ++++++++------- ld/scripttempl/elfarcv2.sc | 25 ++++---- ld/scripttempl/elfd10v.sc | 52 ++++++++------- ld/scripttempl/elfd30v.sc | 29 +++++---- ld/scripttempl/elfm68hc11.sc | 7 +- ld/scripttempl/elfm68hc12.sc | 7 +- ld/scripttempl/elfm9s12z.sc | 9 ++- ld/scripttempl/elfmicroblaze.sc | 41 ++++++------ ld/scripttempl/elfxgate.sc | 7 +- ld/scripttempl/elfxtensa.sc | 26 ++++---- ld/scripttempl/epiphany_4x4.sc | 72 +++++++++++---------- ld/scripttempl/ft32.sc | 26 ++++---- ld/scripttempl/hppaelf.sc | 22 +++---- ld/scripttempl/ia64vms.sc | 4 ++ ld/scripttempl/ip2k.sc | 3 + ld/scripttempl/iq2000.sc | 16 ++--- ld/scripttempl/mep.sc | 16 ++--- ld/scripttempl/mmo.sc | 4 +- ld/scripttempl/nds32elf.sc | 36 +++++------ ld/scripttempl/pru.sc | 23 ++++--- ld/scripttempl/sh.sc | 8 ++- ld/scripttempl/v850.sc | 38 +++++------ ld/scripttempl/v850_rh850.sc | 48 +++++++------- ld/scripttempl/visium.sc | 25 ++++---- ld/scripttempl/xstormy16.sc | 45 ++++++------- ld/testsuite/ld-elf/group2.d | 6 +- ld/testsuite/ld-elf/group4.d | 6 +- ld/testsuite/ld-elf/group5.d | 6 +- ld/testsuite/ld-elf/group6.d | 6 +- ld/testsuite/ld-elf/group7.d | 3 - ld/testsuite/ld-elf/group8a.d | 6 +- ld/testsuite/ld-elf/group8b.d | 6 +- ld/testsuite/ld-elf/group9a.d | 6 +- ld/testsuite/ld-elf/group9b.d | 6 +- ld/testsuite/ld-elf/init-fini-arrays.d | 4 -- ld/testsuite/ld-elf/pr17550a.d | 4 +- ld/testsuite/ld-elf/pr17550b.d | 4 +- ld/testsuite/ld-elf/pr17550d.d | 6 +- ld/testsuite/ld-elf/pr22677.d | 7 +- 75 files changed, 790 insertions(+), 659 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 3580a2b7e5c..0f28a2eeef2 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,53 @@ +2018-10-13 Alan Modra + + * Makefile.am (eelf32btsmip_fbsd.c, eelf32btsmipn32_fbsd.c), + (eelf32epiphany.c, eelf32epiphany_4x4.c, eelf32ltsmip_fbsd.c), + (eelf32ltsmipn32_fbsd.c, eelf32xc16x.c, eelf32xc16xl.c), + (eelf32xc16xs.c, emcorepe.c, enios2elf.c, enios2linux.c), + (eelf64btsmip_fbsd.c, eelf64ltsmip_fbsd.c): Correct dependencies. + * Makefile.in: Regenerate. + * emulparams/aarch64cloudabi.sh, * emulparams/aarch64fbsd.sh, + * emulparams/aarch64linux.sh, * emulparams/aarch64linux32.sh, + * emulparams/arc-nps.sh, * emulparams/elf32_spu.sh, + * emulparams/elf32_tic6x_le.sh, * emulparams/elf32bmip.sh, + * emulparams/elf32btsmipn32.sh, * emulparams/elf32lr5900n32.sh, + * emulparams/elf32mep.sh, * emulparams/elf32metag.sh, + * emulparams/elf64btsmip.sh, * emulparams/shelf_vxworks.sh, + * emulparams/shlelf_fd.sh, * scripttempl/DWARF.sc, + * scripttempl/alpha.sc, * scripttempl/alphavms.sc, + * scripttempl/arclinux.sc, * scripttempl/armbpabi.sc, + * scripttempl/avr.sc, * scripttempl/dlx.sc, * scripttempl/elf.sc, + * scripttempl/elf32cr16.sc, * scripttempl/elf32cr16c.sc, + * scripttempl/elf32crx.sc, * scripttempl/elf32msp430.sc, + * scripttempl/elf32msp430_3.sc, * scripttempl/elf32xc16x.sc, + * scripttempl/elf32xc16xl.sc, * scripttempl/elf32xc16xs.sc, + * scripttempl/elf64hppa.sc, * scripttempl/elf_chaos.sc, + * scripttempl/elfarc.sc, * scripttempl/elfarcv2.sc, + * scripttempl/elfd10v.sc, * scripttempl/elfd30v.sc, + * scripttempl/elfm68hc11.sc, * scripttempl/elfm68hc12.sc, + * scripttempl/elfm9s12z.sc, * scripttempl/elfmicroblaze.sc, + * scripttempl/elfxgate.sc, * scripttempl/elfxtensa.sc, + * scripttempl/epiphany_4x4.sc, * scripttempl/ft32.sc, + * scripttempl/hppaelf.sc, * scripttempl/ia64vms.sc, + * scripttempl/ip2k.sc, * scripttempl/iq2000.sc, + * scripttempl/mep.sc, * scripttempl/mmo.sc, + * scripttempl/nds32elf.sc, * scripttempl/pru.sc, + * scripttempl/sh.sc, * scripttempl/v850.sc, + * scripttempl/v850_rh850.sc, * scripttempl/visium.sc, + * scripttempl/xstormy16.sc: Condition various parts of scripts on + ${RELOCATABLE} in order to prevent ld -r merging sections or + defining symbols. Remove MEMORY and VERSION definitions from + ld -r scripts too. + * testsuite/ld-elf/group2.d, * testsuite/ld-elf/group4.d, + * testsuite/ld-elf/group5.d, * testsuite/ld-elf/group6.d, + * testsuite/ld-elf/group7.d, * testsuite/ld-elf/group8a.d, + * testsuite/ld-elf/group8b.d, * testsuite/ld-elf/group9a.d, + * testsuite/ld-elf/group9b.d, * testsuite/ld-elf/pr17550a.d, + * testsuite/ld-elf/pr17550b.d, + * testsuite/ld-elf/pr17550d.d: Don't xfail cr16 and crx. + * testsuite/ld-elf/init-fini-arrays.d, + * testsuite/ld-elf/pr22677.d: Likewise, and dont' xfail mep. + 2018-10-08 H.J. Lu PR ld/23428 diff --git a/ld/Makefile.am b/ld/Makefile.am index 9884110d26e..98ba096268f 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -990,6 +990,7 @@ eelf32btsmip.c: $(srcdir)/emulparams/elf32btsmip.sh \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf32btsmip_fbsd.c: $(srcdir)/emulparams/elf32btsmip_fbsd.sh \ + ${srcdir}/emulparams/elf32btsmip.sh ${srcdir}/emulparams/elf_fbsd.sh \ $(srcdir)/emulparams/elf32bmip.sh $(ELF_DEPS) \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} @@ -998,6 +999,8 @@ eelf32btsmipn32.c: $(srcdir)/emulparams/elf32btsmipn32.sh \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf32btsmipn32_fbsd.c: $(srcdir)/emulparams/elf32btsmipn32_fbsd.sh \ + ${srcdir}/emulparams/elf32ltsmipn32.sh ${srcdir}/emulparams/elf_fbsd.sh \ + ${srcdir}/emulparams/elf32btsmipn32.sh \ $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} @@ -1042,10 +1045,9 @@ eelf32lr5900n32.c: $(srcdir)/emulparams/elf32lr5900n32.sh \ ${GEN_DEPENDS} eelf32epiphany.c: $(srcdir)/emulparams/elf32epiphany.sh \ - $(ELF_DEPS) ${GEN_DEPENDS} + $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf32epiphany_4x4.c: $(srcdir)/emulparams/elf32epiphany_4x4.sh \ - $(srcdir)/emultempl/elf32.em \ $(ELF_DEPS) $(srcdir)/scripttempl/epiphany_4x4.sc ${GEN_DEPENDS} eelf32fr30.c: $(srcdir)/emulparams/elf32fr30.sh \ @@ -1059,7 +1061,7 @@ eelf32frvfd.c: $(srcdir)/emulparams/elf32frvfd.sh \ $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf32ft32.c: $(srcdir)/emulparams/elf32ft32.sh \ - $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + $(ELF_GEN_DEPS) $(srcdir)/scripttempl/ft32.sc ${GEN_DEPENDS} eelf32ip2k.c: $(srcdir)/emulparams/elf32ip2k.sh \ $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} @@ -1139,6 +1141,7 @@ eelf32ltsmip.c: $(srcdir)/emulparams/elf32ltsmip.sh \ ${GEN_DEPENDS} eelf32ltsmip_fbsd.c: $(srcdir)/emulparams/elf32ltsmip_fbsd.sh \ + ${srcdir}/emulparams/elf32ltsmip.sh ${srcdir}/emulparams/elf_fbsd.sh \ $(srcdir)/emulparams/elf32btsmip.sh $(srcdir)/emulparams/elf32bmip.sh \ $(ELF_DEPS) $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc \ ${GEN_DEPENDS} @@ -1149,6 +1152,7 @@ eelf32ltsmipn32.c: $(srcdir)/emulparams/elf32ltsmipn32.sh \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf32ltsmipn32_fbsd.c: $(srcdir)/emulparams/elf32ltsmipn32_fbsd.sh \ + ${srcdir}/emulparams/elf32ltsmipn32.sh ${srcdir}/emulparams/elf_fbsd.sh \ $(srcdir)/emulparams/elf32btsmipn32.sh \ $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} @@ -1263,15 +1267,15 @@ eelf32visium.c: $(srcdir)/emulparams/elf32visium.sh \ eelf32xc16x.c: $(srcdir)/emulparams/elf32xc16x.sh \ $(ELF_DEPS) $(srcdir)/emultempl/needrelax.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + $(srcdir)/scripttempl/elf32xc16x.sc ${GEN_DEPENDS} eelf32xc16xl.c: $(srcdir)/emulparams/elf32xc16xl.sh \ $(ELF_DEPS) $(srcdir)/emultempl/needrelax.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + $(srcdir)/scripttempl/elf32xc16xl.sc ${GEN_DEPENDS} eelf32xc16xs.c: $(srcdir)/emulparams/elf32xc16xs.sh \ $(ELF_DEPS) $(srcdir)/emultempl/needrelax.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + $(srcdir)/scripttempl/elf32xc16xs.sc ${GEN_DEPENDS} eelf32xstormy16.c: $(srcdir)/emulparams/elf32xstormy16.sh \ $(ELF_DEPS) $(srcdir)/emultempl/needrelax.em \ @@ -1449,7 +1453,7 @@ em9s12zelf.c: $(srcdir)/emulparams/m9s12zelf.sh \ $(srcdir)/scripttempl/elfm9s12z.sc ${GEN_DEPENDS} emcorepe.c: $(srcdir)/emulparams/mcorepe.sh \ - $(srcdir)/emultempl/pe.em $(srcdir)/scripttempl/pe.sc ${GEN_DEPENDS} + $(srcdir)/emultempl/pe.em $(srcdir)/scripttempl/mcorepe.sc ${GEN_DEPENDS} emn10200.c: $(srcdir)/emulparams/mn10200.sh \ $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} @@ -1492,11 +1496,11 @@ ends32belf_linux.c: $(srcdir)/emulparams/nds32belf_linux.sh \ enios2elf.c: $(srcdir)/emulparams/nios2elf.sh \ $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/nios2elf.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + $(srcdir)/scripttempl/elf.sc $(srcdir)/scripttempl/DWARF.sc ${GEN_DEPENDS} enios2linux.c: $(srcdir)/emulparams/nios2linux.sh \ $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/nios2elf.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + $(srcdir)/scripttempl/elf.sc $(srcdir)/scripttempl/DWARF.sc ${GEN_DEPENDS} ens32knbsd.c: $(srcdir)/emulparams/ns32knbsd.sh \ $(srcdir)/emultempl/generic.em $(srcdir)/emultempl/netbsd.em \ @@ -1758,6 +1762,7 @@ eelf64btsmip.c: $(srcdir)/emulparams/elf64btsmip.sh \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf64btsmip_fbsd.c: $(srcdir)/emulparams/elf64btsmip_fbsd.sh \ + ${srcdir}/emulparams/elf64btsmip.sh ${srcdir}/emulparams/elf_fbsd.sh \ $(srcdir)/emulparams/elf64bmip-defs.sh \ $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} @@ -1795,7 +1800,8 @@ eelf64ltsmip.c: $(srcdir)/emulparams/elf64ltsmip.sh \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf64ltsmip_fbsd.c: $(srcdir)/emulparams/elf64ltsmip_fbsd.sh \ - $(srcdir)/emulparams/elf64btsmip_fbsd.sh $(srcdir)/emulparams/elf64bmip-defs.sh \ + ${srcdir}/emulparams/elf64ltsmip.sh ${srcdir}/emulparams/elf_fbsd.sh \ + $(srcdir)/emulparams/elf64btsmip.sh $(srcdir)/emulparams/elf64bmip-defs.sh \ $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} diff --git a/ld/Makefile.in b/ld/Makefile.in index 3ddd581e6d5..e2fc6741536 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -2594,6 +2594,7 @@ eelf32btsmip.c: $(srcdir)/emulparams/elf32btsmip.sh \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf32btsmip_fbsd.c: $(srcdir)/emulparams/elf32btsmip_fbsd.sh \ + ${srcdir}/emulparams/elf32btsmip.sh ${srcdir}/emulparams/elf_fbsd.sh \ $(srcdir)/emulparams/elf32bmip.sh $(ELF_DEPS) \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} @@ -2602,6 +2603,8 @@ eelf32btsmipn32.c: $(srcdir)/emulparams/elf32btsmipn32.sh \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf32btsmipn32_fbsd.c: $(srcdir)/emulparams/elf32btsmipn32_fbsd.sh \ + ${srcdir}/emulparams/elf32ltsmipn32.sh ${srcdir}/emulparams/elf_fbsd.sh \ + ${srcdir}/emulparams/elf32btsmipn32.sh \ $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} @@ -2646,10 +2649,9 @@ eelf32lr5900n32.c: $(srcdir)/emulparams/elf32lr5900n32.sh \ ${GEN_DEPENDS} eelf32epiphany.c: $(srcdir)/emulparams/elf32epiphany.sh \ - $(ELF_DEPS) ${GEN_DEPENDS} + $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf32epiphany_4x4.c: $(srcdir)/emulparams/elf32epiphany_4x4.sh \ - $(srcdir)/emultempl/elf32.em \ $(ELF_DEPS) $(srcdir)/scripttempl/epiphany_4x4.sc ${GEN_DEPENDS} eelf32fr30.c: $(srcdir)/emulparams/elf32fr30.sh \ @@ -2663,7 +2665,7 @@ eelf32frvfd.c: $(srcdir)/emulparams/elf32frvfd.sh \ $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf32ft32.c: $(srcdir)/emulparams/elf32ft32.sh \ - $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + $(ELF_GEN_DEPS) $(srcdir)/scripttempl/ft32.sc ${GEN_DEPENDS} eelf32ip2k.c: $(srcdir)/emulparams/elf32ip2k.sh \ $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} @@ -2743,6 +2745,7 @@ eelf32ltsmip.c: $(srcdir)/emulparams/elf32ltsmip.sh \ ${GEN_DEPENDS} eelf32ltsmip_fbsd.c: $(srcdir)/emulparams/elf32ltsmip_fbsd.sh \ + ${srcdir}/emulparams/elf32ltsmip.sh ${srcdir}/emulparams/elf_fbsd.sh \ $(srcdir)/emulparams/elf32btsmip.sh $(srcdir)/emulparams/elf32bmip.sh \ $(ELF_DEPS) $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc \ ${GEN_DEPENDS} @@ -2753,6 +2756,7 @@ eelf32ltsmipn32.c: $(srcdir)/emulparams/elf32ltsmipn32.sh \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf32ltsmipn32_fbsd.c: $(srcdir)/emulparams/elf32ltsmipn32_fbsd.sh \ + ${srcdir}/emulparams/elf32ltsmipn32.sh ${srcdir}/emulparams/elf_fbsd.sh \ $(srcdir)/emulparams/elf32btsmipn32.sh \ $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} @@ -2867,15 +2871,15 @@ eelf32visium.c: $(srcdir)/emulparams/elf32visium.sh \ eelf32xc16x.c: $(srcdir)/emulparams/elf32xc16x.sh \ $(ELF_DEPS) $(srcdir)/emultempl/needrelax.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + $(srcdir)/scripttempl/elf32xc16x.sc ${GEN_DEPENDS} eelf32xc16xl.c: $(srcdir)/emulparams/elf32xc16xl.sh \ $(ELF_DEPS) $(srcdir)/emultempl/needrelax.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + $(srcdir)/scripttempl/elf32xc16xl.sc ${GEN_DEPENDS} eelf32xc16xs.c: $(srcdir)/emulparams/elf32xc16xs.sh \ $(ELF_DEPS) $(srcdir)/emultempl/needrelax.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + $(srcdir)/scripttempl/elf32xc16xs.sc ${GEN_DEPENDS} eelf32xstormy16.c: $(srcdir)/emulparams/elf32xstormy16.sh \ $(ELF_DEPS) $(srcdir)/emultempl/needrelax.em \ @@ -3053,7 +3057,7 @@ em9s12zelf.c: $(srcdir)/emulparams/m9s12zelf.sh \ $(srcdir)/scripttempl/elfm9s12z.sc ${GEN_DEPENDS} emcorepe.c: $(srcdir)/emulparams/mcorepe.sh \ - $(srcdir)/emultempl/pe.em $(srcdir)/scripttempl/pe.sc ${GEN_DEPENDS} + $(srcdir)/emultempl/pe.em $(srcdir)/scripttempl/mcorepe.sc ${GEN_DEPENDS} emn10200.c: $(srcdir)/emulparams/mn10200.sh \ $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} @@ -3096,11 +3100,11 @@ ends32belf_linux.c: $(srcdir)/emulparams/nds32belf_linux.sh \ enios2elf.c: $(srcdir)/emulparams/nios2elf.sh \ $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/nios2elf.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + $(srcdir)/scripttempl/elf.sc $(srcdir)/scripttempl/DWARF.sc ${GEN_DEPENDS} enios2linux.c: $(srcdir)/emulparams/nios2linux.sh \ $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/nios2elf.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + $(srcdir)/scripttempl/elf.sc $(srcdir)/scripttempl/DWARF.sc ${GEN_DEPENDS} ens32knbsd.c: $(srcdir)/emulparams/ns32knbsd.sh \ $(srcdir)/emultempl/generic.em $(srcdir)/emultempl/netbsd.em \ @@ -3362,6 +3366,7 @@ eelf64btsmip.c: $(srcdir)/emulparams/elf64btsmip.sh \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf64btsmip_fbsd.c: $(srcdir)/emulparams/elf64btsmip_fbsd.sh \ + ${srcdir}/emulparams/elf64btsmip.sh ${srcdir}/emulparams/elf_fbsd.sh \ $(srcdir)/emulparams/elf64bmip-defs.sh \ $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} @@ -3399,7 +3404,8 @@ eelf64ltsmip.c: $(srcdir)/emulparams/elf64ltsmip.sh \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} eelf64ltsmip_fbsd.c: $(srcdir)/emulparams/elf64ltsmip_fbsd.sh \ - $(srcdir)/emulparams/elf64btsmip_fbsd.sh $(srcdir)/emulparams/elf64bmip-defs.sh \ + ${srcdir}/emulparams/elf64ltsmip.sh ${srcdir}/emulparams/elf_fbsd.sh \ + $(srcdir)/emulparams/elf64btsmip.sh $(srcdir)/emulparams/elf64bmip-defs.sh \ $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} diff --git a/ld/emulparams/aarch64cloudabi.sh b/ld/emulparams/aarch64cloudabi.sh index 1b8ca158687..983a92b50eb 100644 --- a/ld/emulparams/aarch64cloudabi.sh +++ b/ld/emulparams/aarch64cloudabi.sh @@ -34,4 +34,4 @@ OTHER_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__end__ = .${CREATE_SHLIB+)};" OTHER_SECTIONS='.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }' ATTRS_SECTIONS='.ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }' # Ensure each PLT entry is aligned to a cache line. -PLT=".plt ${RELOCATING-0} : ALIGN(16) { *(.plt)${IREL_IN_PLT+ *(.iplt)} }" +PLT=".plt ${RELOCATING-0} : ALIGN(16) { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} }" diff --git a/ld/emulparams/aarch64fbsd.sh b/ld/emulparams/aarch64fbsd.sh index 4a307cd5790..3a7a2e18aa9 100644 --- a/ld/emulparams/aarch64fbsd.sh +++ b/ld/emulparams/aarch64fbsd.sh @@ -34,4 +34,4 @@ OTHER_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__end__ = .${CREATE_SHLIB+)};" OTHER_SECTIONS='.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }' ATTRS_SECTIONS='.ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }' # Ensure each PLT entry is aligned to a cache line. -PLT=".plt ${RELOCATING-0} : ALIGN(16) { *(.plt)${IREL_IN_PLT+ *(.iplt)} }" +PLT=".plt ${RELOCATING-0} : ALIGN(16) { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} }" diff --git a/ld/emulparams/aarch64linux.sh b/ld/emulparams/aarch64linux.sh index 2ba1d790434..5df6ae18d81 100644 --- a/ld/emulparams/aarch64linux.sh +++ b/ld/emulparams/aarch64linux.sh @@ -34,7 +34,7 @@ OTHER_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__end__ = .${CREATE_SHLIB+)};" OTHER_SECTIONS='.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }' ATTRS_SECTIONS='.ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }' # Ensure each PLT entry is aligned to a cache line. -PLT=".plt ${RELOCATING-0} : ALIGN(16) { *(.plt)${IREL_IN_PLT+ *(.iplt)} }" +PLT=".plt ${RELOCATING-0} : ALIGN(16) { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} }" # Linux modifies the default library search path to first include # a 64-bit specific directory. diff --git a/ld/emulparams/aarch64linux32.sh b/ld/emulparams/aarch64linux32.sh index 0b4d4c93f7f..3c60de0cac1 100644 --- a/ld/emulparams/aarch64linux32.sh +++ b/ld/emulparams/aarch64linux32.sh @@ -34,7 +34,7 @@ OTHER_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__end__ = .${CREATE_SHLIB+)};" OTHER_SECTIONS='.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }' ATTRS_SECTIONS='.ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }' # Ensure each PLT entry is aligned to a cache line. -PLT=".plt ${RELOCATING-0} : ALIGN(16) { *(.plt)${IREL_IN_PLT+ *(.iplt)} }" +PLT=".plt ${RELOCATING-0} : ALIGN(16) { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} }" # Linux modifies the default library search path to first include # a 32-bit specific directory. diff --git a/ld/emulparams/arc-nps.sh b/ld/emulparams/arc-nps.sh index 615e6d53337..ecca2fe7a96 100644 --- a/ld/emulparams/arc-nps.sh +++ b/ld/emulparams/arc-nps.sh @@ -1,3 +1,4 @@ +if test -n "${RELOCATING}"; then OTHER_SECTIONS=" /* Start of symbols and sections required to support CMEM instructions on NPS targets. */ @@ -76,3 +77,4 @@ OTHER_SECTIONS=" /* End of nps specific sections and symbols. */ ${OTHER_SECTIONS}" +fi diff --git a/ld/emulparams/elf32_spu.sh b/ld/emulparams/elf32_spu.sh index 6993ca734cf..235455f8b96 100644 --- a/ld/emulparams/elf32_spu.sh +++ b/ld/emulparams/elf32_spu.sh @@ -19,9 +19,9 @@ MAXPAGESIZE=0x80 DATA_ADDR="ALIGN(${MAXPAGESIZE})" OTHER_BSS_SECTIONS=".toe ALIGN(128) : { *(.toe) } = 0" OTHER_SECTIONS=".note.spu_name 0 : { KEEP(*(.note.spu_name)) } - ._ea 0 : { KEEP(*(._ea)) KEEP(*(._ea.*)) }" + ._ea 0 : { KEEP(*(._ea))${RELOCATING+ KEEP(*(._ea.*))} }" OTHER_READONLY_SECTIONS=" .fixup ${RELOCATING-0} : { - PROVIDE (__fixup_start = .); + ${RELOCATING+PROVIDE (__fixup_start = .);} KEEP(*(.fixup)) }" diff --git a/ld/emulparams/elf32_tic6x_le.sh b/ld/emulparams/elf32_tic6x_le.sh index d9ebe584a34..62ea9eb920f 100644 --- a/ld/emulparams/elf32_tic6x_le.sh +++ b/ld/emulparams/elf32_tic6x_le.sh @@ -15,8 +15,8 @@ case ${target} in TEXT_START_ADDR=0x0 GOT=" .got ${RELOCATING-0} : { - *(.dsbt) - *(.got.plt) *(.igot.plt) *(.got) *(.igot) + ${RELOCATING+*(.dsbt) + *(.got.plt) *(.igot.plt) }*(.got)${RELOCATING+ *(.igot)} }" ;; esac diff --git a/ld/emulparams/elf32bmip.sh b/ld/emulparams/elf32bmip.sh index da5e7fbeced..abbcb5be35c 100644 --- a/ld/emulparams/elf32bmip.sh +++ b/ld/emulparams/elf32bmip.sh @@ -58,9 +58,9 @@ OTHER_SDATA_SECTIONS=" TEXT_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_ftext = .${CREATE_SHLIB+)};" DATA_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_fdata = .${CREATE_SHLIB+)};" OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_fbss = .${CREATE_SHLIB+)};" -OTHER_SECTIONS=' - .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } - .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } +OTHER_SECTIONS=" + .gptab.sdata : {${RELOCATING+ *(.gptab.data)} *(.gptab.sdata) } + .gptab.sbss : {${RELOCATING+ *(.gptab.bss)} *(.gptab.sbss) } .mdebug.abi32 0 : { KEEP(*(.mdebug.abi32)) } .mdebug.abiN32 0 : { KEEP(*(.mdebug.abiN32)) } .mdebug.abi64 0 : { KEEP(*(.mdebug.abi64)) } @@ -69,7 +69,7 @@ OTHER_SECTIONS=' .mdebug.eabi64 0 : { KEEP(*(.mdebug.eabi64)) } .gcc_compiled_long32 0 : { KEEP(*(.gcc_compiled_long32)) } .gcc_compiled_long64 0 : { KEEP(*(.gcc_compiled_long64)) } -' +" ARCH=mips MACHINE= TEMPLATE_NAME=elf32 diff --git a/ld/emulparams/elf32btsmipn32.sh b/ld/emulparams/elf32btsmipn32.sh index 10c5565cc43..5fc325f50f4 100644 --- a/ld/emulparams/elf32btsmipn32.sh +++ b/ld/emulparams/elf32btsmipn32.sh @@ -9,7 +9,7 @@ COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" # Magic sections. OTHER_TEXT_SECTIONS='*(.mips16.fn.*) *(.mips16.call.*)' -OTHER_SECTIONS=' - .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } - .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } -' +OTHER_SECTIONS=" + .gptab.sdata : {${RELOCATING+ *(.gptab.data)} *(.gptab.sdata) } + .gptab.sbss : {${RELOCATING+ *(.gptab.bss)} *(.gptab.sbss) } +" diff --git a/ld/emulparams/elf32lr5900n32.sh b/ld/emulparams/elf32lr5900n32.sh index 69f7afbb469..7a3c6d78597 100644 --- a/ld/emulparams/elf32lr5900n32.sh +++ b/ld/emulparams/elf32lr5900n32.sh @@ -12,10 +12,10 @@ EMBEDDED=yes DYNAMIC_LINK=FALSE OTHER_TEXT_SECTIONS='*(.mips16.fn.*) *(.mips16.call.*)' -OTHER_SECTIONS=' - .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } - .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } -' +OTHER_SECTIONS=" + .gptab.sdata : {${RELOCATING+ *(.gptab.data)} *(.gptab.sdata) } + .gptab.sbss : {${RELOCATING+ *(.gptab.bss)} *(.gptab.sbss) } +" unset DATA_ADDR SHLIB_TEXT_START_ADDR=0 diff --git a/ld/emulparams/elf32mep.sh b/ld/emulparams/elf32mep.sh index 2ebbda1bdc4..7d93abab1ea 100644 --- a/ld/emulparams/elf32mep.sh +++ b/ld/emulparams/elf32mep.sh @@ -7,6 +7,8 @@ MAXPAGESIZE=256 ENTRY=_start EMBEDDED=yes TEMPLATE_NAME=elf32 + +if test -n "${RELOCATING}"; then DATA_START_SYMBOLS='__data_start = . ;' OTHER_GOT_SYMBOLS=' . = ALIGN(4); @@ -53,3 +55,4 @@ OTHER_BSS_SECTIONS=' __assert_near_size = ASSERT (. <= 0x1000000, "near section overflow"); .farbss : { PROVIDE (__farbss_start = .); *(.farbss) *(.farbss.*) PROVIDE (__farbss_end = .); } ' +fi diff --git a/ld/emulparams/elf32metag.sh b/ld/emulparams/elf32metag.sh index 2a1d072da3c..9d71d7a9157 100644 --- a/ld/emulparams/elf32metag.sh +++ b/ld/emulparams/elf32metag.sh @@ -12,7 +12,7 @@ ENTRY=__start NOP=0xa0fffffe EXTRA_EM_FILE=metagelf USER_LABEL_PREFIX=_ -OTHER_SECTIONS=" +test -n "${RELOCATING}" && OTHER_SECTIONS=" .core_text 0x80000000 : { *(.core_text) diff --git a/ld/emulparams/elf64btsmip.sh b/ld/emulparams/elf64btsmip.sh index b9e80bb17b3..202585fbfe1 100644 --- a/ld/emulparams/elf64btsmip.sh +++ b/ld/emulparams/elf64btsmip.sh @@ -8,9 +8,9 @@ LITTLE_OUTPUT_FORMAT="elf64-tradlittlemips" # Magic sections. OTHER_TEXT_SECTIONS='*(.mips16.fn.*) *(.mips16.call.*)' -OTHER_SECTIONS=' - .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } - .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } -' +OTHER_SECTIONS=" + .gptab.sdata : {${RELOCATING+ *(.gptab.data)} *(.gptab.sdata) } + .gptab.sbss : {${RELOCATING+ *(.gptab.bss)} *(.gptab.sbss) } +" TEXT_START_ADDR="0x120000000" diff --git a/ld/emulparams/shelf_vxworks.sh b/ld/emulparams/shelf_vxworks.sh index c45099046e8..4b82e36e6e8 100644 --- a/ld/emulparams/shelf_vxworks.sh +++ b/ld/emulparams/shelf_vxworks.sh @@ -16,6 +16,6 @@ ENTRY=__start SYMPREFIX=_ GOT=".got ${RELOCATING-0} : { - PROVIDE(__GLOBAL_OFFSET_TABLE_ = .); - *(.got.plt) *(.got) }" + ${RELOCATING+PROVIDE(__GLOBAL_OFFSET_TABLE_ = .); + *(.got.plt) }*(.got) }" . ${srcdir}/emulparams/vxworks.sh diff --git a/ld/emulparams/shlelf_fd.sh b/ld/emulparams/shlelf_fd.sh index f1f41071854..cf827e5a903 100644 --- a/ld/emulparams/shlelf_fd.sh +++ b/ld/emulparams/shlelf_fd.sh @@ -3,7 +3,7 @@ . ${srcdir}/emulparams/shlelf_linux.sh OUTPUT_FORMAT="elf32-sh-fdpic" -GOT=".got ${RELOCATING-0} : { *(.got.funcdesc) *(.got.plt) *(.got) }" +GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.funcdesc) *(.got.plt)} *(.got) }" OTHER_GOT_RELOC_SECTIONS=" .rela.got.funcdesc ${RELOCATING-0} : { *(.rela.got.funcdesc) } " diff --git a/ld/scripttempl/DWARF.sc b/ld/scripttempl/DWARF.sc index f8b6f2229fc..e6396eca732 100644 --- a/ld/scripttempl/DWARF.sc +++ b/ld/scripttempl/DWARF.sc @@ -24,7 +24,7 @@ cat < text} EOF @@ -218,8 +222,8 @@ if test -n "$RODATA_PM_OFFSET"; then .rodata ${RELOCATING+ ADDR(.text) + SIZEOF (.text) + __RODATA_PM_OFFSET__ } ${RELOCATING-0} : { *(.rodata) - ${RELOCATING+ *(.rodata*)} - *(.gnu.linkonce.r*) + ${RELOCATING+ *(.rodata*) + *(.gnu.linkonce.r*)} } ${RELOCATING+AT> text} EOF fi @@ -229,18 +233,18 @@ cat < data} @@ -292,9 +296,9 @@ cat < fuse} EOF fi diff --git a/ld/scripttempl/dlx.sc b/ld/scripttempl/dlx.sc index 175ceb38109..0741893b41c 100644 --- a/ld/scripttempl/dlx.sc +++ b/ld/scripttempl/dlx.sc @@ -21,7 +21,7 @@ SECTIONS ${RELOCATING+. = ${TEXT_START_ADDR};} .text : { - CREATE_OBJECT_SYMBOLS + ${RELOCATING+CREATE_OBJECT_SYMBOLS} *(.text) ${RELOCATING+etext = ${DATA_ALIGNMENT};} } @@ -35,8 +35,8 @@ SECTIONS .bss : { *(.bss) - *(COMMON) - ${RELOCATING+end = . }; + ${RELOCATING+*(COMMON)} + ${RELOCATING+end = .;} } } EOF diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index b10e330f7f1..d3e1828f071 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -144,16 +144,16 @@ if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then fi if test -z "$PLT"; then IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }" - PLT=".plt ${RELOCATING-0} : { *(.plt)${IREL_IN_PLT+ *(.iplt)} } + PLT=".plt ${RELOCATING-0} : { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} } ${IREL_IN_PLT-$IPLT}" fi test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT= if test -z "$GOT"; then if test -z "$SEPARATE_GOTPLT"; then - GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }" + GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt) *(.igot.plt)} *(.got)${RELOCATING+ *(.igot)} }" else - GOT=".got ${RELOCATING-0} : { *(.got) *(.igot) }" - GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) *(.igot.plt) }" + GOT=".got ${RELOCATING-0} : { *(.got)${RELOCATING+ *(.igot)} }" + GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt)${RELOCATING+ *(.igot.plt)} }" fi fi REL_IFUNC=".rel.ifunc ${RELOCATING-0} : { *(.rel.ifunc) }" @@ -179,9 +179,9 @@ if test -z "${NO_SMALL_DATA}"; then { ${RELOCATING+${SBSS_START_SYMBOLS}} ${CREATE_SHLIB+*(.${SBSS_NAME}2 .${SBSS_NAME}2.* .gnu.linkonce.sb2.*)} - *(.dyn${SBSS_NAME}) + ${RELOCATING+*(.dyn${SBSS_NAME})} *(.${SBSS_NAME}${RELOCATING+ .${SBSS_NAME}.* .gnu.linkonce.sb.*}) - *(.scommon) + ${RELOCATING+*(.scommon)} ${RELOCATING+${SBSS_END_SYMBOLS}} }" SBSS2=".${SBSS_NAME}2 ${RELOCATING-0} : { *(.${SBSS_NAME}2${RELOCATING+ .${SBSS_NAME}2.* .gnu.linkonce.sb2.*}) }" @@ -231,9 +231,9 @@ test "${LARGE_SECTIONS}" = "yes" && REL_LARGE=" test "${LARGE_SECTIONS}" = "yes" && LARGE_BSS=" .lbss ${RELOCATING-0} : { - *(.dynlbss) + ${RELOCATING+*(.dynlbss)} *(.lbss${RELOCATING+ .lbss.* .gnu.linkonce.lb.*}) - *(LARGE_COMMON) + ${RELOCATING+*(LARGE_COMMON)} }" test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" .lrodata ${RELOCATING-0} ${RELOCATING+ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))} : @@ -245,12 +245,6 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" *(.ldata${RELOCATING+ .ldata.* .gnu.linkonce.l.*}) ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} }" -PREINIT_ARRAY=".preinit_array ${RELOCATING-0} : - { - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} - KEEP (*(.preinit_array)) - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} - }" if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" @@ -262,19 +256,25 @@ else CTORS_IN_INIT_ARRAY= DTORS_IN_FINI_ARRAY= fi -INIT_ARRAY=".init_array ${RELOCATING-0} : +PREINIT_ARRAY=".preinit_array : { - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} + ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);} + KEEP (*(.preinit_array)) + ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);} + }" +INIT_ARRAY=".init_array : + { + ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);} ${SORT_INIT_ARRAY} KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY})) - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} + ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);} }" -FINI_ARRAY=".fini_array ${RELOCATING-0} : +FINI_ARRAY=".fini_array : { - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} + ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);} ${SORT_FINI_ARRAY} KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY})) - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} + ${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);} }" CTOR=".ctors ${CONSTRUCTING-0} : { @@ -327,7 +327,7 @@ SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:- if test -z "$TINY_READONLY_SECTION"; then case "$LD_FLAG" in *textonly*) - SEPARATE_TEXT=yes + SEPARATE_TEXT=" " TEXT_SEGMENT_ALIGN=". = ALIGN(${MAXPAGESIZE});" ;; esac @@ -368,7 +368,7 @@ ${RELOCATING- /* For some reason, the Solaris linker makes bad executables SECTIONS { - /* Read-only sections, merged into text segment: */ + ${RELOCATING+${SEPARATE_TEXT-/* Read-only sections, merged into text segment: */}} ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}} ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} ${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}} @@ -546,11 +546,11 @@ SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS" SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})" fi cat < rom + }${RELOCATING+ > rom} .fini : { __FINI_START = .; KEEP (*(.fini)) __FINI_END = .; - } > rom + }${RELOCATING+ > rom} .jcr : { KEEP (*(.jcr)) - } > rom + }${RELOCATING+ > rom} .text : { __TEXT_START = .; *(.text) *(.text.*) *(.gnu.linkonce.t.*) __TEXT_END = .; - } > rom + }${RELOCATING+ > rom} .rdata : { __RDATA_START = .; *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata*) __RDATA_END = .; - } > rom + }${RELOCATING+ > rom} .ctor ALIGN(4) : { @@ -106,7 +116,7 @@ SECTIONS KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors)) __CTOR_END = .; - } > rom + }${RELOCATING+ > rom} .dtor ALIGN(4) : { @@ -116,21 +126,21 @@ SECTIONS KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) __DTOR_END = .; - } > rom + }${RELOCATING+ > rom} .data : { __DATA_START = .; *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*) __DATA_END = .; - } > ram AT > rom + }${RELOCATING+ > ram AT > rom} .bss (NOLOAD) : { __BSS_START = .; *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*) __BSS_END = .; - } > ram + }${RELOCATING+ > ram} /* You may change the sizes of the following sections to fit the actual size your program requires. @@ -143,21 +153,21 @@ SECTIONS . = ALIGN(4); __HEAP_START = .; . += 0x2000; __HEAP_MAX = .; - } > ram + }${RELOCATING+ > ram} .stack (NOLOAD) : { . = ALIGN(4); . += 0x6000; __STACK_START = .; - } > ram + }${RELOCATING+ > ram} .istack (NOLOAD) : { . = ALIGN(4); . += 0x100; __ISTACK_START = .; - } > ram + }${RELOCATING+ > ram} .comment 0 : { *(.comment) } @@ -168,5 +178,5 @@ EOF cat < rom - .rdata : { __RDATA_START = .; *(.rdata_4) *(.rdata_2) *(.rdata_1) __RDATA_END = .; } > near_rom - .ctor ALIGN(4) : { __CTOR_LIST = .; *(.ctors) __CTOR_END = .; } > near_rom - .dtor ALIGN(4) : { __DTOR_LIST = .; *(.dtors) __DTOR_END = .; } > near_rom - .data : { __DATA_START = .; *(.data_4) *(.data_2) *(.data_1) *(.data) __DATA_END = .; } > ram AT > rom - .bss (NOLOAD) : { __BSS_START = .; *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) __BSS_END = .; } > ram - .nrdata : { __NRDATA_START = .; *(.nrdat_4) *(.nrdat_2) *(.nrdat_1) __NRDATA_END = .; } > near_rom - .ndata : { __NDATA_START = .; *(.ndata_4) *(.ndata_2) *(.ndata_1) __NDATA_END = .; } > near_ram AT > rom - .nbss (NOLOAD) : { __NBSS_START = .; *(.nbss_4) *(.nbss_2) *(.nbss_1) *(.ncommon) __NBSS_END = .; } > near_ram - .heap (NOLOAD) : { . = ALIGN(4); __HEAP_START = .; . += 0x2000; __HEAP_MAX = .; } > near_ram - .stack (NOLOAD) : { . = ALIGN(4); . += 0x6000; __STACK_START = .; } > ram - .istack (NOLOAD) : { . = ALIGN(2); . += 0x100; __ISTACK_START = .; } > ram + .text : { __TEXT_START = .; *(.text) __TEXT_END = .; }${RELOCATING+ > rom} + .rdata : { __RDATA_START = .; *(.rdata_4) *(.rdata_2) *(.rdata_1) __RDATA_END = .; }${RELOCATING+ > near_rom} + .ctor ALIGN(4) : { __CTOR_LIST = .; *(.ctors) __CTOR_END = .; }${RELOCATING+ > near_rom} + .dtor ALIGN(4) : { __DTOR_LIST = .; *(.dtors) __DTOR_END = .; }${RELOCATING+ > near_rom} + .data : { __DATA_START = .; *(.data_4) *(.data_2) *(.data_1) *(.data) __DATA_END = .; }${RELOCATING+ > ram AT > rom} + .bss (NOLOAD) : { __BSS_START = .; *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) __BSS_END = .; }${RELOCATING+ > ram} + .nrdata : { __NRDATA_START = .; *(.nrdat_4) *(.nrdat_2) *(.nrdat_1) __NRDATA_END = .; }${RELOCATING+ > near_rom} + .ndata : { __NDATA_START = .; *(.ndata_4) *(.ndata_2) *(.ndata_1) __NDATA_END = .; }${RELOCATING+ > near_ram AT > rom} + .nbss (NOLOAD) : { __NBSS_START = .; *(.nbss_4) *(.nbss_2) *(.nbss_1) *(.ncommon) __NBSS_END = .; }${RELOCATING+ > near_ram} + .heap (NOLOAD) : { . = ALIGN(4); __HEAP_START = .; . += 0x2000; __HEAP_MAX = .; }${RELOCATING+ > near_ram} + .stack (NOLOAD) : { . = ALIGN(4); . += 0x6000; __STACK_START = .; }${RELOCATING+ > ram} + .istack (NOLOAD) : { . = ALIGN(2); . += 0x100; __ISTACK_START = .; }${RELOCATING+ > ram} } -__DATA_IMAGE_START = LOADADDR(.data); -__NDATA_IMAGE_START = LOADADDR(.ndata); +${RELOCATING+__DATA_IMAGE_START = LOADADDR(.data);} +${RELOCATING+__NDATA_IMAGE_START = LOADADDR(.ndata);} EOF diff --git a/ld/scripttempl/elf32crx.sc b/ld/scripttempl/elf32crx.sc index 89aafa64fd6..319a867783f 100644 --- a/ld/scripttempl/elf32crx.sc +++ b/ld/scripttempl/elf32crx.sc @@ -6,6 +6,10 @@ # are permitted in any medium without royalty provided the copyright # notice and this notice are preserved. +# Using an empty script for ld -r is better than mashing together +# sections. This hack likely leaves ld -Ur broken. +test -n "${RELOCATING}" || exit 0 + # The next line should be uncommented if it is desired to link # without libstart.o and directly enter main. diff --git a/ld/scripttempl/elf32msp430.sc b/ld/scripttempl/elf32msp430.sc index 1f69a1242e6..b35f0ef012d 100644 --- a/ld/scripttempl/elf32msp430.sc +++ b/ld/scripttempl/elf32msp430.sc @@ -32,6 +32,9 @@ cat < bootloader} /* Information memory. */ @@ -59,7 +65,7 @@ SECTIONS { *(.infomem) ${RELOCATING+. = ALIGN(2);} - *(.infomem.*) + ${RELOCATING+*(.infomem.*)} } ${RELOCATING+ > infomem} /* Information memory (not loaded into MPU). */ @@ -67,7 +73,7 @@ SECTIONS { *(.infomemnobits) ${RELOCATING+. = ALIGN(2);} - *(.infomemnobits.*) + ${RELOCATING+*(.infomemnobits.*)} } ${RELOCATING+ > infomemnobits} /* Read-only sections, merged into text segment. */ @@ -133,7 +139,7 @@ SECTIONS /* Internal text space. */ .text : { - ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+. = ALIGN(2); *(SORT_NONE(.init)) *(SORT_NONE(.init0)) /* Start here after reset. */ *(SORT_NONE(.init1)) @@ -144,7 +150,7 @@ SECTIONS *(SORT_NONE(.init6)) /* C++ constructors. */ *(SORT_NONE(.init7)) *(SORT_NONE(.init8)) - *(SORT_NONE(.init9)) /* Call main(). */ + *(SORT_NONE(.init9)) /* Call main(). */} ${CONSTRUCTING+ __ctors_start = . ; } ${CONSTRUCTING+ *(.ctors) } @@ -153,19 +159,19 @@ SECTIONS ${CONSTRUCTING+ *(.dtors) } ${CONSTRUCTING+ __dtors_end = . ; } - ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+. = ALIGN(2); *(.lower.text.* .lower.text) - ${RELOCATING+. = ALIGN(2);} + . = ALIGN(2);} *(.text) - ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+. = ALIGN(2); *(.text.*) - ${RELOCATING+. = ALIGN(2);} + . = ALIGN(2); *(.text:*) *(.either.text.* .either.text) - ${RELOCATING+. = ALIGN(2);} + . = ALIGN(2); *(SORT_NONE(.fini9)) *(SORT_NONE(.fini8)) *(SORT_NONE(.fini7)) @@ -178,18 +184,18 @@ SECTIONS *(SORT_NONE(.fini0)) /* Infinite loop after program termination. */ *(SORT_NONE(.fini)) - _etext = .; + _etext = .;} } ${RELOCATING+ > text} .rodata : { - ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+. = ALIGN(2); *(.lower.rodata.* .lower.rodata) . = ALIGN(2); - *(.plt) - *(.rodata .rodata.* .gnu.linkonce.r.* .const .const:*) - *(.rodata1) + *(.plt)} + *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.* .const .const:*}) + ${RELOCATING+*(.rodata1) *(.either.rodata.*) *(.either.rodata) *(.eh_frame_hdr) @@ -230,13 +236,13 @@ SECTIONS KEEP (*crtbegin*.o(.dtors)) KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors)) KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) + KEEP (*(.dtors))} } ${RELOCATING+ > text} .vectors ${RELOCATING-0}: { ${RELOCATING+ PROVIDE (__vectors_start = .) ; } - *(.vectors*) + *(.vectors${RELOCATING+*}) ${RELOCATING+ _vectors_end = . ; } } ${RELOCATING+ > vectors} @@ -244,17 +250,17 @@ SECTIONS { ${RELOCATING+ PROVIDE (__data_start = .) ; } ${RELOCATING+ PROVIDE (__datastart = .) ; } - ${RELOCATING+. = ALIGN(2);} + ${RELOCATING+. = ALIGN(2); KEEP (*(.jcr)) *(.data.rel.ro.local) *(.data.rel.ro*) *(.dynamic) - ${RELOCATING+. = ALIGN(2);} - *(.lower.data.* .lower.data) + . = ALIGN(2); + *(.lower.data.* .lower.data)} *(.data) - *(.data.*) + ${RELOCATING+*(.data.*) *(.gnu.linkonce.d*) KEEP (*(.gnu.linkonce.d.*personality*)) *(.data1) @@ -262,26 +268,26 @@ SECTIONS *(.either.data.* .either.data) *(.got.plt) *(.got) - ${RELOCATING+. = ALIGN(2);} + . = ALIGN(2); *(.sdata .sdata.* .gnu.linkonce.s.*) - ${RELOCATING+. = ALIGN(2);} - ${RELOCATING+ _edata = . ; } - } ${RELOCATING+ > data ${RELOCATING+AT> text}} + . = ALIGN(2); + _edata = .;} + } ${RELOCATING+ > data AT> text} - __romdatastart = LOADADDR(.data); - __romdatacopysize = SIZEOF(.data); + ${RELOCATING+__romdatastart = LOADADDR(.data); + __romdatacopysize = SIZEOF(.data);} .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : { ${RELOCATING+. = ALIGN(2);} ${RELOCATING+ PROVIDE (__bss_start = .); } - ${RELOCATING+ PROVIDE (__bssstart = .); } + ${RELOCATING+ PROVIDE (__bssstart = .); *(.lower.bss.* .lower.bss) - ${RELOCATING+. = ALIGN(2);} + . = ALIGN(2);} *(.bss) - *(.either.bss.* .either.bss) + ${RELOCATING+*(.either.bss.* .either.bss) *(COMMON) - ${RELOCATING+ PROVIDE (__bss_end = .) ; } + PROVIDE (__bss_end = .);} } ${RELOCATING+ > data} ${RELOCATING+ PROVIDE (__bsssize = SIZEOF(.bss)); } @@ -317,7 +323,7 @@ EOF . $srcdir/scripttempl/DWARF.sc -cat < text} .rodata : { - *(.rodata .rodata.* .gnu.linkonce.r.*) - *(.const) - *(.const:*) + *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) + ${RELOCATING+*(.const)} + ${RELOCATING+*(.const:*)} } ${RELOCATING+ > text} .data ${RELOCATING-0} : @@ -141,11 +147,11 @@ SECTIONS ${RELOCATING+ PROVIDE (__data_start = .) ; } ${RELOCATING+. = ALIGN(2);} *(.data) - *(.data.*) - *(.gnu.linkonce.d*) + ${RELOCATING+*(.data.*)} + ${RELOCATING+*(.gnu.linkonce.d*)} ${RELOCATING+. = ALIGN(2);} ${RELOCATING+ _edata = . ; } - } ${RELOCATING+ > data ${RELOCATING+AT> text}} + } ${RELOCATING+ > data AT> text} __romdatastart = LOADADDR(.data); __romdatacopysize = SIZEOF(.data); @@ -181,7 +187,7 @@ SECTIONS .vectors ${RELOCATING-0}: { ${RELOCATING+ PROVIDE (__vectors_start = .) ; } - *(.vectors*) + *(.vectors${RELOCATING+*}) ${RELOCATING+ _vectors_end = . ; } } ${RELOCATING+ > vectors} @@ -205,11 +211,14 @@ EOF . $srcdir/scripttempl/DWARF.sc -cat < introm} .data : { *(.data) - *(.data.*) + ${RELOCATING+*(.data.*)} ${RELOCATING+ _edata = . ; } } ${RELOCATING+ > dram} @@ -54,7 +60,7 @@ SECTIONS { ${RELOCATING+ _bss_start = . ;} *(.bss) - *(COMMON) + ${RELOCATING+*(COMMON)} ${RELOCATING+ _end = . ; } } ${RELOCATING+ > dram} diff --git a/ld/scripttempl/elf32xc16xl.sc b/ld/scripttempl/elf32xc16xl.sc index 545df6747c3..0b473194264 100644 --- a/ld/scripttempl/elf32xc16xl.sc +++ b/ld/scripttempl/elf32xc16xl.sc @@ -13,7 +13,10 @@ cat < introm} .data : { *(.data) - *(.data.*) + ${RELOCATING+*(.data.*)} ${RELOCATING+ _edata = . ; } } ${RELOCATING+ > dram} @@ -56,7 +62,7 @@ SECTIONS { ${RELOCATING+ _bss_start = . ;} *(.bss) - *(COMMON) + ${RELOCATING+*(COMMON)} ${RELOCATING+ _end = . ; } } ${RELOCATING+ > dram} diff --git a/ld/scripttempl/elf32xc16xs.sc b/ld/scripttempl/elf32xc16xs.sc index 545df6747c3..89672f9e4b2 100644 --- a/ld/scripttempl/elf32xc16xs.sc +++ b/ld/scripttempl/elf32xc16xs.sc @@ -13,7 +13,10 @@ cat < introm} .data : { *(.data) - *(.data.*) + ${RELOCATING+*(.data.*)} ${RELOCATING+ _edata = . ; } } ${RELOCATING+ > dram} @@ -56,7 +63,7 @@ SECTIONS { ${RELOCATING+ _bss_start = . ;} *(.bss) - *(COMMON) + ${RELOCATING+*(COMMON)} ${RELOCATING+ _end = . ; } } ${RELOCATING+ > dram} diff --git a/ld/scripttempl/elf64hppa.sc b/ld/scripttempl/elf64hppa.sc index 9b1d34ebe5d..1bed6743c50 100644 --- a/ld/scripttempl/elf64hppa.sc +++ b/ld/scripttempl/elf64hppa.sc @@ -123,7 +123,7 @@ fi test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes if test -z "$GOT"; then if test -z "$SEPARATE_GOTPLT"; then - GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) }" + GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt)} *(.got) }" else GOT=".got ${RELOCATING-0} : { *(.got) }" GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) }" @@ -138,9 +138,9 @@ if test -z "${NO_SMALL_DATA}"; then { ${RELOCATING+${SBSS_START_SYMBOLS}} ${CREATE_SHLIB+*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)} - *(.dynsbss) + ${RELOCATING+*(.dynsbss)} *(.sbss${RELOCATING+ .sbss.* .gnu.linkonce.sb.*}) - *(.scommon) + ${RELOCATING+*(.scommon)} ${RELOCATING+${SBSS_END_SYMBOLS}} }" SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2${RELOCATING+ .sbss2.* .gnu.linkonce.sb2.*}) }" @@ -433,7 +433,7 @@ cat < ${TEXT_MEMORY}} .eh_frame : { KEEP (*(.eh_frame)) } ${RELOCATING+> ${TEXT_MEMORY}} - .gcc_except_table : { *(.gcc_except_table) *(.gcc_except_table.*) } ${RELOCATING+> ${TEXT_MEMORY}} + .gcc_except_table : { *(.gcc_except_table${RELOCATING+ .gcc_except_table.*}) } ${RELOCATING+> ${TEXT_MEMORY}} .plt : { *(.plt) } ${RELOCATING+> ${TEXT_MEMORY}} .jlitab : { ${RELOCATING+${JLI_START_TABLE}} - jlitab*.o:(.jlitab*) *(.jlitab*) + ${RELOCATING+jlitab*.o:(.jlitab*)} + *(.jlitab${RELOCATING+*}) } ${RELOCATING+> ${TEXT_MEMORY}} .rodata ${RELOCATING-0} : @@ -236,7 +237,7 @@ SECTIONS line will have no effect, see PR13697. Thus, keep .data */ KEEP (*(.data)) ${RELOCATING+${DATA_START_SYMBOLS}} - *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*}) + ${RELOCATING+*(.data.* .gnu.linkonce.d.*)} ${CONSTRUCTING+SORT(CONSTRUCTORS)} } ${RELOCATING+ > ${DATA_MEMORY}} @@ -251,13 +252,13 @@ SECTIONS ${RELOCATING+${SBSS2}} .bss ${RELOCATING-0} : { - *(.dynbss) - *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*}) - *(COMMON) - /* Align here to ensure that the .bss section occupies space up to - _end. Align after .bss to ensure correct alignment even if the - .bss section disappears because there are no input sections. */ - ${RELOCATING+. = ALIGN(${ALIGNMENT});} + ${RELOCATING+*(.dynbss)} + *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*}) + ${RELOCATING+*(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + . = ALIGN(${ALIGNMENT});} ${RELOCATING+_end = .;} ${RELOCATING+PROVIDE (end = .);} } ${RELOCATING+ > ${DATA_MEMORY}} @@ -298,7 +299,7 @@ SECTIONS .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ - .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } + .debug_info 0 : { *(.debug_info${RELOCATING+ .gnu.linkonce.wi.*}) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } diff --git a/ld/scripttempl/elfd10v.sc b/ld/scripttempl/elfd10v.sc index d21f580f44f..b79e95eef11 100644 --- a/ld/scripttempl/elfd10v.sc +++ b/ld/scripttempl/elfd10v.sc @@ -70,12 +70,15 @@ cat <INSN} =${NOP-0} .rodata ${RELOCATING+${READONLY_START_ADDR}} : { *(.rodata) - *(.gnu.linkonce.r*) - *(.rodata.*) + ${RELOCATING+*(.gnu.linkonce.r*) + *(.rodata.*)} } ${RELOCATING+ >DATA} .rodata1 ${RELOCATING-0} : { *(.rodata1) - *(.rodata1.*) + ${RELOCATING+*(.rodata1.*)} } ${RELOCATING+ >DATA} .data ${RELOCATING-0} : { ${RELOCATING+${DATA_START_SYMBOLS}} *(.data) - *(.data.*) - *(.gnu.linkonce.d*) + ${RELOCATING+*(.data.*) + *(.gnu.linkonce.d*)} ${CONSTRUCTING+CONSTRUCTORS} } ${RELOCATING+ >DATA} .data1 ${RELOCATING-0} : { *(.data1) - *(.data1.*) + ${RELOCATING+*(.data1.*)} } ${RELOCATING+ >DATA} ${RELOCATING+${CTOR} >DATA} @@ -145,20 +151,20 @@ SECTIONS we can shorten the on-disk segment size. */ .sdata ${RELOCATING-0} : { *(.sdata) - *(.sdata.*) + ${RELOCATING+*(.sdata.*)} } ${RELOCATING+ >DATA} ${RELOCATING+_edata = .;} ${RELOCATING+PROVIDE (edata = .);} ${RELOCATING+__bss_start = .;} - .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } ${RELOCATING+ >DATA} + .sbss ${RELOCATING-0} : { *(.sbss)${RELOCATING+ *(.scommon)} } ${RELOCATING+ >DATA} .bss ${RELOCATING-0} : { - *(.dynbss) - *(.dynbss.*) + ${RELOCATING+*(.dynbss) + *(.dynbss.*)} *(.bss) - *(.bss.*) - *(COMMON) + ${RELOCATING+*(.bss.*) + *(COMMON)} } ${RELOCATING+ >DATA} ${RELOCATING+_end = . ;} diff --git a/ld/scripttempl/elfd30v.sc b/ld/scripttempl/elfd30v.sc index 388a578eed1..8e306ca70ce 100644 --- a/ld/scripttempl/elfd30v.sc +++ b/ld/scripttempl/elfd30v.sc @@ -52,6 +52,9 @@ cat < ${TEXT_MEMORY}} /* Internal data space */ @@ -146,7 +152,7 @@ SECTIONS .data ${RELOCATING-0} : { *(.data) - *(.gnu.linkonce.d*) + ${RELOCATING+*(.gnu.linkonce.d*)} ${CONSTRUCTING+CONSTRUCTORS} ${RELOCATING+ _edata = . ; } } ${RELOCATING+ > ${DATA_MEMORY}} @@ -180,7 +186,7 @@ SECTIONS { ${RELOCATING+ PROVIDE (__bss_start = .) ; } *(.bss) - *(COMMON) + ${RELOCATING+*(COMMON)} ${RELOCATING+ PROVIDE (__bss_end = .) ; } ${RELOCATING+ _end = . ; } } ${RELOCATING+ > ${DATA_MEMORY}} @@ -207,10 +213,9 @@ EOF . $srcdir/scripttempl/DWARF.sc cat < ${DATA_MEMORY}} ${RELOCATING+__bss_size = SIZEOF(.bss);} @@ -424,7 +423,7 @@ SECTIONS .eeprom ${RELOCATING-0} : { *(.eeprom) - *(.eeprom.*) + ${RELOCATING+*(.eeprom.*)} } ${RELOCATING+ > ${EEPROM_MEMORY}} ${RELOCATING+${VECTORS}} diff --git a/ld/scripttempl/elfm68hc12.sc b/ld/scripttempl/elfm68hc12.sc index 4b8154ac52b..4690ab664ba 100644 --- a/ld/scripttempl/elfm68hc12.sc +++ b/ld/scripttempl/elfm68hc12.sc @@ -413,12 +413,11 @@ SECTIONS ${RELOCATING+*(.softregs)} ${RELOCATING+*(.sbss)} ${RELOCATING+*(.scommon)} - - *(.dynbss) + ${RELOCATING+*(.dynbss)} *(.bss) ${RELOCATING+*(.bss.*)} ${RELOCATING+*(.gnu.linkonce.b.*)} - *(COMMON) + ${RELOCATING+*(COMMON)} ${RELOCATING+PROVIDE (_end = .);} } ${RELOCATING+ > ${DATA_MEMORY}} ${RELOCATING+__bss_size = SIZEOF(.bss);} @@ -427,7 +426,7 @@ SECTIONS .eeprom ${RELOCATING-0} : { *(.eeprom) - *(.eeprom.*) + ${RELOCATING+*(.eeprom.*)} } ${RELOCATING+ > ${EEPROM_MEMORY}} ${RELOCATING+${VECTORS}} diff --git a/ld/scripttempl/elfm9s12z.sc b/ld/scripttempl/elfm9s12z.sc index 5553aeb7caa..b14c68b0893 100644 --- a/ld/scripttempl/elfm9s12z.sc +++ b/ld/scripttempl/elfm9s12z.sc @@ -173,7 +173,7 @@ ${RELOCATING+${LIB_SEARCH_DIRS}} ${RELOCATING+${EXECUTABLE_SYMBOLS}} ${RELOCATING+${MEMORY_DEF}} -PROVIDE (_start = $[$ROM_TOP - $ROM_SIZE + 1]); +${RELOCATING+PROVIDE (_start = $[$ROM_TOP - $ROM_SIZE + 1]);} SECTIONS { .hash ${RELOCATING-0} : { *(.hash) } @@ -403,12 +403,11 @@ SECTIONS ${RELOCATING+*(.sbss)} ${RELOCATING+*(.common)} ${RELOCATING+*(.scommon)} - - *(.dynbss) + ${RELOCATING+*(.dynbss)} *(.bss) ${RELOCATING+*(.bss.*)} ${RELOCATING+*(.gnu.linkonce.b.*)} - *(COMMON) + ${RELOCATING+*(COMMON)} ${RELOCATING+PROVIDE (_end = .);} } ${RELOCATING+ > ${DATA_MEMORY}} ${RELOCATING+__bss_size = SIZEOF(.bss);} @@ -417,7 +416,7 @@ SECTIONS .eeprom ${RELOCATING-0} : { *(.eeprom) - *(.eeprom.*) + ${RELOCATING+*(.eeprom.*)} } ${RELOCATING+ > ${EEPROM_MEMORY}} ${RELOCATING+${VECTORS}} diff --git a/ld/scripttempl/elfmicroblaze.sc b/ld/scripttempl/elfmicroblaze.sc index d8f7569aade..4a7c196659a 100644 --- a/ld/scripttempl/elfmicroblaze.sc +++ b/ld/scripttempl/elfmicroblaze.sc @@ -63,9 +63,9 @@ ${RELOCATING+${LIB_SEARCH_DIRS}} ${RELOCATING+ENTRY (${ENTRY})} -_TEXT_START_ADDR = DEFINED(_TEXT_START_ADDR) ? _TEXT_START_ADDR : 0x50; +${RELOCATING+_TEXT_START_ADDR = DEFINED(_TEXT_START_ADDR) ? _TEXT_START_ADDR : 0x50; _HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x0; -_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x400; +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x400;} SECTIONS { @@ -79,7 +79,7 @@ SECTIONS ${RELOCATING+ _ftext = .;} .text : { - ${RELOCATING+*(.text)} + *(.text) ${RELOCATING+*(.text.*)} ${RELOCATING+*(.gnu.linkonce.t.*)} } @@ -103,10 +103,10 @@ SECTIONS ${RELOCATING+ . = ALIGN(4);} ${RELOCATING+ _frodata = . ;} .rodata : { - ${RELOCATING+*(.rodata)} + *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} - ${CONSTRUCTING+CONSTRUCTORS}; /* Is this needed? */ + ${CONSTRUCTING+CONSTRUCTORS;} /* Is this needed? */ } ${RELOCATING+ _erodata = .;} @@ -115,14 +115,14 @@ SECTIONS ${RELOCATING+. = ALIGN(8);} ${RELOCATING+ _ssrw = .;} .sdata2 : { - ${RELOCATING+*(.sdata2)} + *(.sdata2) ${RELOCATING+*(.sdata2.*)} ${RELOCATING+*(.gnu.linkonce.s2.*)} } ${RELOCATING+. = ALIGN(4);} .sbss2 : { ${RELOCATING+PROVIDE (__sbss2_start = .);} - ${RELOCATING+*(.sbss2)} + *(.sbss2) ${RELOCATING+*(.sbss2.*)} ${RELOCATING+*(.gnu.linkonce.sb2.*)} ${RELOCATING+PROVIDE (__sbss2_end = .);} @@ -135,36 +135,36 @@ SECTIONS ${RELOCATING+ . = ALIGN(4);} ${RELOCATING+ _fdata = .;} .data : { - ${RELOCATING+*(.data)} + *(.data) ${RELOCATING+*(.gnu.linkonce.d.*)} - ${CONSTRUCTING+CONSTRUCTORS}; /* Is this needed? */ + ${CONSTRUCTING+CONSTRUCTORS;} /* Is this needed? */ } ${RELOCATING+ _edata = . ;} /* Added to handle pic code */ .got : { - ${RELOCATING+*(.got)} + *(.got) } .got1 : { - ${RELOCATING+*(.got1)} + *(.got1) } .got2 : { - ${RELOCATING+*(.got2)} + *(.got2) } /* Added by Sathya to handle C++ exceptions */ .eh_frame : { - ${RELOCATING+*(.eh_frame)} + *(.eh_frame) } .jcr : { - ${RELOCATING+*(.jcr)} + *(.jcr) } .gcc_except_table : { - ${RELOCATING+*(.gcc_except_table)} + *(.gcc_except_table) } /* Alignments by 8 to ensure that _SDA_BASE_ on a word boundary */ @@ -172,14 +172,14 @@ SECTIONS ${RELOCATING+. = ALIGN(8);} ${RELOCATING+ _ssro = .;} .sdata : { - ${RELOCATING+*(.sdata)} + *(.sdata) ${RELOCATING+*(.sdata.*)} ${RELOCATING+*(.gnu.linkonce.s.*)} } ${RELOCATING+. = ALIGN(4);} .sbss : { ${RELOCATING+PROVIDE (__sbss_start = .);} - ${RELOCATING+*(.sbss)} + *(.sbss) ${RELOCATING+*(.sbss.*)} ${RELOCATING+*(.gnu.linkonce.sb.*)} ${RELOCATING+PROVIDE (__sbss_end = .);} @@ -193,14 +193,13 @@ SECTIONS ${RELOCATING+ _fbss = .;} .bss : { ${RELOCATING+PROVIDE (__bss_start = .);} - ${RELOCATING+*(.bss)} + *(.bss) ${RELOCATING+*(.bss.*)} ${RELOCATING+*(.gnu.linkonce.b.*)} ${RELOCATING+*(COMMON)} ${RELOCATING+. = ALIGN(. != 0 ? 4 : 1);} ${RELOCATING+PROVIDE (__bss_end = .);} - } ${RELOCATING+ . = ALIGN(4);} @@ -223,12 +222,12 @@ SECTIONS } .tdata : { - ${RELOCATING+*(.tdata)} + *(.tdata) ${RELOCATING+*(.tdata.*)} ${RELOCATING+*(.gnu.linkonce.td.*)} } .tbss : { - ${RELOCATING+*(.tbss)} + *(.tbss) ${RELOCATING+*(.tbss.*)} ${RELOCATING+*(.gnu.linkonce.tb.*)} } diff --git a/ld/scripttempl/elfxgate.sc b/ld/scripttempl/elfxgate.sc index f5d491119dd..083876a8154 100644 --- a/ld/scripttempl/elfxgate.sc +++ b/ld/scripttempl/elfxgate.sc @@ -413,12 +413,11 @@ SECTIONS ${RELOCATING+*(.softregs)} ${RELOCATING+*(.sbss)} ${RELOCATING+*(.scommon)} - - *(.dynbss) + ${RELOCATING+*(.dynbss)} *(.bss) ${RELOCATING+*(.bss.*)} ${RELOCATING+*(.gnu.linkonce.b.*)} - *(COMMON) + ${RELOCATING+*(COMMON)} ${RELOCATING+PROVIDE (_end = .);} } ${RELOCATING+ > ${DATA_MEMORY}} ${RELOCATING+__bss_size = SIZEOF(.bss);} @@ -427,7 +426,7 @@ SECTIONS .eeprom ${RELOCATING-0} : { *(.eeprom) - *(.eeprom.*) + ${RELOCATING+*(.eeprom.*)} } ${RELOCATING+ > ${EEPROM_MEMORY}} ${RELOCATING+${VECTORS}} diff --git a/ld/scripttempl/elfxtensa.sc b/ld/scripttempl/elfxtensa.sc index 7350d2de3f3..63448e1dd90 100644 --- a/ld/scripttempl/elfxtensa.sc +++ b/ld/scripttempl/elfxtensa.sc @@ -136,7 +136,7 @@ fi test -n "${DATA_PLT-${BSS_PLT-text}}" && TEXT_PLT=yes if test -z "$GOT"; then if test -z "$SEPARATE_GOTPLT"; then - GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) }" + GOT=".got ${RELOCATING-0} : {${RELOCATING+ *(.got.plt)} *(.got) }" else GOT=".got ${RELOCATING-0} : { *(.got) }" GOTPLT=".got.plt ${RELOCATING-0} : { *(.got.plt) }" @@ -410,7 +410,7 @@ cat < RESERVED_CRT0_RAM RESERVED_CRT0 : {*.o(RESERVED_CRT0) } > RESERVED_CRT0_RAM RESERVED_CRT0 : {*.o(reserved_crt0) } > RESERVED_CRT0_RAM @@ -354,7 +355,7 @@ SECTIONS __new_lib_start_external_ = ( ORIGIN(EXTERNAL_DRAM_0) + __PROG_SIZE_FOR_CORE__ *__CORE_NUM_ ); __new_lib_start_ = DEFINED(__USE_INTERNAL_MEM_FOR_NEW_LIB_) ? ORIGIN(BANK1_SRAM) : __new_lib_start_external_ ; - NEW_LIB_RO ${RELOCATING+__new_lib_start_} : { lib_a-*.o(.text .rodata ) *.o(libgloss_epiphany) } /* > INTERNAL_RAM*/ + NEW_LIB_RO __new_lib_start_ : { lib_a-*.o(.text .rodata) *.o(libgloss_epiphany) } /* > INTERNAL_RAM */ GNU_C_BUILTIN_LIB_RO ADDR(NEW_LIB_RO) + SIZEOF(NEW_LIB_RO) : { *mulsi3.o(.text .rodata) *modsi3.o(.text .rodata) *divsi3.o(.text .rodata) *udivsi3.o(.text .rodata) @@ -366,8 +367,9 @@ SECTIONS __init_start = DEFINED(__USE_INTERNAL_MEM_) ? ORIGIN(BANK1_SRAM) : (ADDR(NEW_LIB_WR) + SIZEOF(NEW_LIB_WR) ) ; __init_start = DEFINED(__USE_INTERNAL_MEM_FOR_NEW_LIB_) ? ADDR(NEW_LIB_WR) + SIZEOF(NEW_LIB_WR) : __init_start; +EOF - +cat < INTERNAL_RAM*/ =${NOP-0} + } /* ${RELOCATING+ > INTERNAL_RAM} */ =${NOP-0} ${TEXT_PLT+${PLT}} ${TINY_READONLY_SECTION} @@ -482,7 +484,7 @@ cat < INTERNAL_RAM*/ =${NOP-0} + } /* ${RELOCATING+ > INTERNAL_RAM} */ =${NOP-0} .text ${RELOCATING+ADDR(.fini)+SIZEOF(.fini)} ${RELOCATING-0} : { @@ -491,7 +493,7 @@ cat < INTERNAL_RAM */ =${NOP-0} + } /* ${RELOCATING+ > INTERNAL_RAM} */ =${NOP-0} ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);} ${RELOCATING+PROVIDE (_${ETEXT_NAME} = .);} @@ -503,7 +505,7 @@ cat < INTERNAL_RAM*/ + } /* ${RELOCATING+ > INTERNAL_RAM} */ .data1 ${RELOCATING-0} : { *(.data1) } ${WRITABLE_RODATA+${RODATA}} ${OTHER_READWRITE_SECTIONS} @@ -583,16 +585,16 @@ cat < INTERNAL_RAM*/ + . = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} + } /* ${RELOCATING+ > INTERNAL_RAM} */ ${OTHER_BSS_SECTIONS} ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} ${RELOCATING+. = ALIGN(${ALIGNMENT});} @@ -603,11 +605,11 @@ cat < ram}" cat < flash} ${CONSTRUCTING+${TORS}} .data : ${RELOCATING+ AT (ADDR (.text) + SIZEOF (.text))} { *(.data) - *(.rodata) + ${RELOCATING+*(.rodata) *(.rodata*) - ${RELOCATING+ _edata = . ; } - . = ALIGN(4); + _edata = .; + . = ALIGN(4);} } ${RELOCATING+ > ram} .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : { ${RELOCATING+ _bss_start = . ; } *(.bss) - *(COMMON) - ${RELOCATING+ _end = . ; } - . = ALIGN(4); + ${RELOCATING+*(COMMON) + _end = .; + . = ALIGN(4);} } ${RELOCATING+ > ram} ${RELOCATING+ __data_load_start = LOADADDR(.data); } diff --git a/ld/scripttempl/hppaelf.sc b/ld/scripttempl/hppaelf.sc index c06a4936408..c74f6d0cad3 100644 --- a/ld/scripttempl/hppaelf.sc +++ b/ld/scripttempl/hppaelf.sc @@ -22,30 +22,30 @@ SECTIONS { .text 0x1000 ${RELOCATING++${TEXT_START_ADDR}}: { - ${RELOCATING+__text_start = .}; - CREATE_OBJECT_SYMBOLS + ${RELOCATING+__text_start = .; + CREATE_OBJECT_SYMBOLS} *(.PARISC.stubs) *(.text) - ${RELOCATING+etext = .}; - ${RELOCATING+_etext = .}; + ${RELOCATING+etext = .; + _etext = .;} } ${RELOCATING+. = ${DATA_ADDR};} .data : { - ${RELOCATING+ . = . + 0x1000 }; - ${RELOCATING+__data_start = .}; + ${RELOCATING+. = . + 0x1000; + __data_start = .;} *(.data) ${CONSTRUCTING+CONSTRUCTORS} - ${RELOCATING+edata = .}; - ${RELOCATING+_edata = .}; + ${RELOCATING+edata = .; + _edata = .;} } ${RELOCATING+. = ${DATA_ADDR} + SIZEOF(.data);} .bss : { *(.bss) - *(COMMON) - ${RELOCATING+end = . }; - ${RELOCATING+_end = . }; + ${RELOCATING+*(COMMON) + end = .; + _end = .;} } } EOF diff --git a/ld/scripttempl/ia64vms.sc b/ld/scripttempl/ia64vms.sc index 11c95bd433d..9b83ffaf4e5 100644 --- a/ld/scripttempl/ia64vms.sc +++ b/ld/scripttempl/ia64vms.sc @@ -7,6 +7,10 @@ # are permitted in any medium without royalty provided the copyright # notice and this notice are preserved. +# Using an empty script for ld -r is better than mashing together +# sections. This hack likely leaves ld -Ur broken. +test -n "${RELOCATING}" || exit 0 + PAGESIZE=0x10000 BLOCKSIZE=0x200 diff --git a/ld/scripttempl/ip2k.sc b/ld/scripttempl/ip2k.sc index 53ec8290f98..6aa1f42f532 100644 --- a/ld/scripttempl/ip2k.sc +++ b/ld/scripttempl/ip2k.sc @@ -4,6 +4,9 @@ # are permitted in any medium without royalty provided the copyright # notice and this notice are preserved. +# Using an empty script for ld -r is better than mashing together +# sections. This hack likely leaves ld -Ur broken. +test -n "${RELOCATING}" || exit 0 cat << EOF /* Copyright (C) 2014-2018 Free Software Foundation, Inc. diff --git a/ld/scripttempl/iq2000.sc b/ld/scripttempl/iq2000.sc index 58f9c29f34f..e5f5c77ca89 100644 --- a/ld/scripttempl/iq2000.sc +++ b/ld/scripttempl/iq2000.sc @@ -333,9 +333,9 @@ cat < dmem + } ${RELOCATING+ > dmem} .bss ${RELOCATING-0} : { @@ -154,7 +159,7 @@ SECTIONS ${RELOCATING+ *(.bss.*)} ${RELOCATING+ *(.bss:*)} ${RELOCATING+*(.gnu.linkonce.b*)} - *(COMMON) + ${RELOCATING+*(COMMON)} ${RELOCATING+ PROVIDE (_bss_end = .) ; } } ${RELOCATING+ > dmem} @@ -166,9 +171,9 @@ SECTIONS ${RELOCATING+ PROVIDE (_noinit_end = .) ; } ${RELOCATING+ PROVIDE (_heap_start = .) ; } ${RELOCATING+ . += __HEAP_SIZE ; } - /* Stack is not here really. It will be put at the end of DMEM. + ${RELOCATING+/* Stack is not here really. It will be put at the end of DMEM. But we take into account its size here, in order to allow - for MEMORY overflow checking during link time. */ + for MEMORY overflow checking during link time. */} ${RELOCATING+ . += __STACK_SIZE ; } } ${RELOCATING+ > dmem} diff --git a/ld/scripttempl/sh.sc b/ld/scripttempl/sh.sc index 7d1e3dbf5f0..0a500b3f2b0 100644 --- a/ld/scripttempl/sh.sc +++ b/ld/scripttempl/sh.sc @@ -12,7 +12,7 @@ TORS=".tors : ___dtors = . ; *(.dtors) ___dtors_end = . ; - } > ram" + }${RELOCATING+ > ram}" cat < init} @@ -91,7 +94,7 @@ SECTIONS end of ctors marker and it must be last. */ KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors)) - KEEP (*(SORT(.ctors.*))) + ${RELOCATING+KEEP (*(SORT(.ctors.*)))} KEEP (*(.ctors)) ${CONSTRUCTING+ __CTOR_END__ = .;} } ${RELOCATING+ > rom} @@ -100,14 +103,14 @@ SECTIONS ${CONSTRUCTING+ __DTOR_LIST__ = .;} KEEP (*crtbegin*.o(.dtors)) KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors)) - KEEP (*(SORT(.dtors.*))) + ${RELOCATING+KEEP (*(SORT(.dtors.*)))} KEEP (*(.dtors)) ${CONSTRUCTING+ __DTOR_END__ = .;} } ${RELOCATING+ > rom} .rodata ${RELOCATING-0} : { ${RELOCATING+ . = ALIGN(4);} ${RELOCATING+ _srdata = .;} - *(.rdata) + ${RELOCATING+*(.rdata)} *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} @@ -140,7 +143,7 @@ SECTIONS *(.bss) ${RELOCATING+*(.bss.*)} ${RELOCATING+*(.gnu.linkonce.b.*)} - *(COMMON) + ${RELOCATING+*(COMMON)} ${RELOCATING+ . = ALIGN(4);} ${RELOCATING+ __bss_end = .;} ${RELOCATING+ _sheap = .;} @@ -168,7 +171,7 @@ EOF cat < RAM + }${RELOCATING+ > RAM} ${RELOCATING+${OTHER_READWRITE_SECTIONS}} ${RELOCATING+${OTHER_GOT_SYMBOLS}} ${RELOCATING+${OTHER_GOT_SECTIONS}} @@ -146,16 +147,16 @@ SECTIONS ${RELOCATING+${OTHER_BSS_SYMBOLS}} .bss ${RELOCATING-0} : { - *(.dynbss) + ${RELOCATING+*(.dynbss)} *(.bss) ${RELOCATING+*(.bss.*)} ${RELOCATING+*(.gnu.linkonce.b.*)} - *(COMMON) + ${RELOCATING+*(COMMON) /* Align here to ensure that the .bss section occupies space up to _end. Align after .bss to ensure correct alignment even if the .bss section disappears because there are no input sections. */ - ${RELOCATING+. = ALIGN(${ALIGNMENT});} - } > RAM + . = ALIGN(${ALIGNMENT});} + }${RELOCATING+ > RAM} ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} ${RELOCATING+. = ALIGN(${ALIGNMENT});} ${RELOCATING+${OTHER_END_SYMBOLS}} @@ -164,15 +165,15 @@ SECTIONS ${RELOCATING+PROVIDE (end = .);} /* Read-only sections in ROM. */ - .int_vec ${RELOCATING-0} : { *(.int_vec) } ${RELOCATING+> ROM} + .int_vec ${RELOCATING-0} : { *(.int_vec) }${RELOCATING+ > ROM} - .rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} } ${RELOCATING+> ROM} + .rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} }${RELOCATING+ > ROM} ${RELOCATING+${CTOR}} ${RELOCATING+${DTOR}} - .jcr : { KEEP (*(.jcr)) } ${RELOCATING+> ROM} - .eh_frame : { KEEP (*(.eh_frame)) } ${RELOCATING+> ROM} - .gcc_except_table : { *(.gcc_except_table) *(.gcc_except_table.*) } ${RELOCATING+> ROM} - .plt : { *(.plt) } ${RELOCATING+> ROM} + .jcr : { KEEP (*(.jcr)) }${RELOCATING+ > ROM} + .eh_frame : { KEEP (*(.eh_frame)) }${RELOCATING+ > ROM} + .gcc_except_table : { *(.gcc_except_table)${RELOCATING+ *(.gcc_except_table.*)} }${RELOCATING+ > ROM} + .plt : { *(.plt) }${RELOCATING+ > ROM} .text ${RELOCATING-0} : { @@ -184,19 +185,19 @@ SECTIONS *(.gnu.warning) ${RELOCATING+*(.gnu.linkonce.t.*)} ${RELOCATING+${OTHER_TEXT_SECTIONS}} - } ${RELOCATING+> ROM =${NOP-0}} + }${RELOCATING+ > ROM =${NOP-0}} .init ${RELOCATING-0} : { ${RELOCATING+${INIT_START}} KEEP (*(.init)) ${RELOCATING+${INIT_END}} - } ${RELOCATING+> ROM =${NOP-0}} + }${RELOCATING+ > ROM =${NOP-0}} .fini ${RELOCATING-0} : { ${RELOCATING+${FINI_START}} KEEP (*(.fini)) ${RELOCATING+${FINI_END}} - } ${RELOCATING+> ROM =${NOP-0}} + }${RELOCATING+ > ROM =${NOP-0}} ${RELOCATING+PROVIDE (__etext = .);} ${RELOCATING+PROVIDE (_etext = .);} ${RELOCATING+PROVIDE (etext = .);} diff --git a/ld/testsuite/ld-elf/group2.d b/ld/testsuite/ld-elf/group2.d index d127d4d93fc..604c685b606 100644 --- a/ld/testsuite/ld-elf/group2.d +++ b/ld/testsuite/ld-elf/group2.d @@ -1,10 +1,8 @@ #source: ../../../binutils/testsuite/binutils-all/group.s #ld: -r #readelf: -Sg --wide -#xfail: cr16-*-* crx-*-* xstormy*-*-* -# cr16 and crx use non-standard scripts with memory regions, which don't play -# well with unique group sections under ld -r. -# xstormy also uses a non-standard script, putting .data before .text. +# xstormy uses a non-standard script, putting .data before .text. +#xfail: xstormy*-*-* #... \[[ 0-9]+\] \.group[ \t]+GROUP[ \t]+.* diff --git a/ld/testsuite/ld-elf/group4.d b/ld/testsuite/ld-elf/group4.d index 2e400cdcf6b..9530300766e 100644 --- a/ld/testsuite/ld-elf/group4.d +++ b/ld/testsuite/ld-elf/group4.d @@ -1,10 +1,8 @@ #source: ../../../binutils/testsuite/binutils-all/group-2.s #ld: -r #readelf: -Sg --wide -#xfail: cr16-*-* crx-*-* xstormy*-*-* -# cr16 and crx use non-standard scripts with memory regions, which don't play -# well with unique group sections under ld -r. -# xstormy also uses a non-standard script, putting .data before .text. +# xstormy uses a non-standard script, putting .data before .text. +#xfail: xstormy*-*-* #... \[[ 0-9]+\] .group[ \t]+GROUP[ \t]+.* diff --git a/ld/testsuite/ld-elf/group5.d b/ld/testsuite/ld-elf/group5.d index b41dce6dd54..b39c5690cc5 100644 --- a/ld/testsuite/ld-elf/group5.d +++ b/ld/testsuite/ld-elf/group5.d @@ -1,10 +1,8 @@ #source: ../../../binutils/testsuite/binutils-all/group-3.s #ld: -r #readelf: -Sg --wide -#xfail: cr16-*-* crx-*-* xstormy*-*-* -# cr16 and crx use non-standard scripts with memory regions, which don't play -# well with unique group sections under ld -r. -# xstormy also uses a non-standard script, putting .data before .text. +# xstormy uses a non-standard script, putting .data before .text. +#xfail: xstormy*-*-* #... \[[ 0-9]+\] .group[ \t]+GROUP[ \t]+.* diff --git a/ld/testsuite/ld-elf/group6.d b/ld/testsuite/ld-elf/group6.d index eef05853796..a495eac733e 100644 --- a/ld/testsuite/ld-elf/group6.d +++ b/ld/testsuite/ld-elf/group6.d @@ -1,10 +1,8 @@ #source: ../../../binutils/testsuite/binutils-all/group-4.s #ld: -r #readelf: -Sg --wide -#xfail: cr16-*-* crx-*-* xstormy*-*-* -# cr16 and crx use non-standard scripts with memory regions, which don't play -# well with unique group sections under ld -r. -# xstormy also uses a non-standard script, putting .data before .text. +# xstormy uses a non-standard script, putting .data before .text. +#xfail: xstormy*-*-* #... \[[ 0-9]+\] .group[ \t]+GROUP[ \t]+.* diff --git a/ld/testsuite/ld-elf/group7.d b/ld/testsuite/ld-elf/group7.d index 47c2b7b8083..e4ee270ef47 100644 --- a/ld/testsuite/ld-elf/group7.d +++ b/ld/testsuite/ld-elf/group7.d @@ -4,9 +4,6 @@ #source: ../../../binutils/testsuite/binutils-all/group-4.s #ld: -r #readelf: -g --wide -#xfail: cr16-*-* crx-*-* -# cr16 and crx use non-standard scripts with memory regions, which don't play -# well with unique group sections under ld -r. #... COMDAT group section \[[ 0-9]+\] `\.group' \[foo_group\] contains . sections: diff --git a/ld/testsuite/ld-elf/group8a.d b/ld/testsuite/ld-elf/group8a.d index 303346274d1..32740855f21 100644 --- a/ld/testsuite/ld-elf/group8a.d +++ b/ld/testsuite/ld-elf/group8a.d @@ -1,11 +1,9 @@ #source: group8.s #ld: -r --gc-sections --entry foo #readelf: -g --wide -#xfail: cr16-*-* crx-*-* d30v-*-* dlx-*-* hppa64-*-* -#xfail: mep-*-* mn10200-*-* pj*-*-* pru-*-* xgate-*-* # generic linker targets don't support --gc-sections, nor do a bunch of others -# cr16 and crx use non-standard scripts with memory regions, which don't play -# well with unique group sections under ld -r. +#xfail: d30v-*-* dlx-*-* hppa64-*-* +#xfail: mep-*-* mn10200-*-* pj*-*-* pru-*-* xgate-*-* COMDAT group section \[[ 0-9]+\] `.group' \[foo\] contains . sections: \[Index\] Name diff --git a/ld/testsuite/ld-elf/group8b.d b/ld/testsuite/ld-elf/group8b.d index bfe4b77594b..9c6ad50e725 100644 --- a/ld/testsuite/ld-elf/group8b.d +++ b/ld/testsuite/ld-elf/group8b.d @@ -1,11 +1,9 @@ #source: group8.s #ld: -r --gc-sections --entry bar #readelf: -g --wide -#xfail: cr16-*-* crx-*-* d30v-*-* dlx-*-* hppa64-*-* mep-*-* mn10200-*-* -#xfail: pj*-*-* pru-*-* xgate-*-* # generic linker targets don't support --gc-sections, nor do a bunch of others -# cr16 and crx use non-standard scripts with memory regions, which don't play -# well with unique group sections under ld -r. +#xfail: d30v-*-* dlx-*-* hppa64-*-* mep-*-* mn10200-*-* +#xfail: pj*-*-* pru-*-* xgate-*-* COMDAT group section \[[ 0-9]+\] `.group' \[bar\] contains . sections: \[Index\] Name diff --git a/ld/testsuite/ld-elf/group9a.d b/ld/testsuite/ld-elf/group9a.d index 08a1c267c02..8246d0dc940 100644 --- a/ld/testsuite/ld-elf/group9a.d +++ b/ld/testsuite/ld-elf/group9a.d @@ -1,11 +1,9 @@ #source: group9.s #ld: -r --gc-sections --entry foo #readelf: -g --wide -#xfail: cr16-*-* crx-*-* d30v-*-* dlx-*-* hppa64-*-* mep-*-* mn10200-*-* -#xfail: pj*-*-* pru-*-* xgate-*-* # generic linker targets don't support --gc-sections, nor do a bunch of others -# cr16 and crx use non-standard scripts with memory regions, which don't play -# well with unique group sections under ld -r. +#xfail: d30v-*-* dlx-*-* hppa64-*-* mep-*-* mn10200-*-* +#xfail: pj*-*-* pru-*-* xgate-*-* COMDAT group section \[[ 0-9]+\] `.group' \[foo\] contains . sections: \[Index\] Name diff --git a/ld/testsuite/ld-elf/group9b.d b/ld/testsuite/ld-elf/group9b.d index 11676991ae9..66a17320872 100644 --- a/ld/testsuite/ld-elf/group9b.d +++ b/ld/testsuite/ld-elf/group9b.d @@ -1,11 +1,9 @@ #source: group9.s #ld: -r --gc-sections --entry bar #readelf: -g --wide -#xfail: cr16-*-* crx-*-* d30v-*-* dlx-*-* hppa64-*-* mep-*-* mn10200-*-* -#xfail: pj*-*-* pru-*-* xgate-*-* # generic linker targets don't support --gc-sections, nor do a bunch of others -# cr16 and crx use non-standard scripts with memory regions, which don't play -# well with unique group sections under ld -r. +#xfail: d30v-*-* dlx-*-* hppa64-*-* mep-*-* mn10200-*-* +#xfail: pj*-*-* pru-*-* xgate-*-* COMDAT group section \[[ 0-9]+\] `.group' \[foo\] contains . sections: \[Index\] Name diff --git a/ld/testsuite/ld-elf/init-fini-arrays.d b/ld/testsuite/ld-elf/init-fini-arrays.d index 912373d3769..83be9a415a6 100644 --- a/ld/testsuite/ld-elf/init-fini-arrays.d +++ b/ld/testsuite/ld-elf/init-fini-arrays.d @@ -1,10 +1,6 @@ #source: init-fini-arrays.s #ld: -r #readelf: -S --wide -#xfail: cr16-*-* crx-*-* msp430-*-* -# msp430 puts the init_array and fini_array inside the .rodata section. -# cr16 and crx use non-standard scripts with memory regions, which don't play -# well with unique group sections under ld -r. #... \[[ 0-9]+\] \.init_array\.01000[ \t]+INIT_ARRAY[ \t0-9a-f]+WA?.* diff --git a/ld/testsuite/ld-elf/pr17550a.d b/ld/testsuite/ld-elf/pr17550a.d index a6f2a2b4043..752c3ad64dd 100644 --- a/ld/testsuite/ld-elf/pr17550a.d +++ b/ld/testsuite/ld-elf/pr17550a.d @@ -2,10 +2,8 @@ #source: pr17550-2.s #ld: -r #readelf: -s --wide -#xfail: alpha-*-* cr16-*-* crx-*-* # Disabled on alpha because alpha has a different .set directive. -# cr16 and crx use non-standard scripts with memory regions, which don't -# play well with comdat group sections under ld -r. +#xfail: alpha-*-* #failif #... diff --git a/ld/testsuite/ld-elf/pr17550b.d b/ld/testsuite/ld-elf/pr17550b.d index 4e424f10b16..09e7ddfef78 100644 --- a/ld/testsuite/ld-elf/pr17550b.d +++ b/ld/testsuite/ld-elf/pr17550b.d @@ -2,10 +2,8 @@ #source: pr17550-1.s #ld: -r #readelf: -s --wide -#xfail: alpha-*-* cr16-*-* crx-*-* # Disabled on alpha because alpha has a different .set directive. -# cr16 and crx use non-standard scripts with memory regions, which don't -# play well with comdat group sections under ld -r. +#xfail: alpha-*-* #failif #... diff --git a/ld/testsuite/ld-elf/pr17550d.d b/ld/testsuite/ld-elf/pr17550d.d index 70ef97171a4..3fbcb87dcb8 100644 --- a/ld/testsuite/ld-elf/pr17550d.d +++ b/ld/testsuite/ld-elf/pr17550d.d @@ -2,11 +2,9 @@ #source: pr17550-4.s #ld: -r #readelf: -s --wide -#xfail: alpha-*-* cr16-*-* crx-*-* d30v-*-* dlx-*-* pj*-*-* xgate-*-* # Disabled on alpha because alpha has a different .set directive. -# cr16 and crx use non-standard scripts with memory regions, which don't -# play well with comdat group sections under ld -r. Generic linker -# targets don't support comdat group sections. +# Generic linker targets don't support comdat group sections. +#xfail: alpha-*-* d30v-*-* dlx-*-* pj*-*-* xgate-*-* #... +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +UND y diff --git a/ld/testsuite/ld-elf/pr22677.d b/ld/testsuite/ld-elf/pr22677.d index 983fda8859d..38e2be1898b 100644 --- a/ld/testsuite/ld-elf/pr22677.d +++ b/ld/testsuite/ld-elf/pr22677.d @@ -1,12 +1,9 @@ #ld: -r --gc-sections -u foo #readelf: -S --wide -#xfail: cr16-*-* crx-*-* d30v-*-* dlx-*-* hppa64-*-* -#xfail: mep-*-* mn10200-*-* msp430-*-* pj*-*-* pru-*-* xgate-*-* -# msp430 puts the init_array and fini_array inside the .rodata section. # generic linker targets don't support --gc-sections, nor do a bunch of # others. -# cr16 and crx use non-standard scripts with memory regions, which don't -# play well with unique group sections under ld -r. +#xfail: d30v-*-* dlx-*-* hppa64-*-* +#xfail: mep-*-* mn10200-*-* pj*-*-* pru-*-* xgate-*-* #... \[[ 0-9]+\] \.preinit_array\.01000[ \t]+PREINIT_ARRAY[ \t0-9a-f]+WA?.*