From fd161d860f1df7140153eab4726705cc3e2727b0 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 8 Jun 2018 20:17:34 +0930 Subject: Define various symbols conditionally in shared libraries The values of symbols in shared libraries like _end, _edata, and __bss_start are generally not that useful outside of the shared library. This patch defines them conditionally with PROVIDE, since a shared library might need the local value. An example is glibc ld.so local access to "_begin", "_etext" and "_end". (ld.so gains access to the local values by making the references using hidden visibility. That makes the definitions hidden too.) We can't use PROVIDE_HIDDEN in the linker scripts because the shared library might need the value of the symbol in the executable. An example is freebsd libc dynamic access to "_end". PR ld/23161 * emulparams/aarch64cloudabi.sh: PROVIDE __bss_start__, _bss_end__, and __end__ in shared libraries. * emulparams/aarch64fbsd.sh: Likewise. * emulparams/aarch64linux.sh: Likewise. * emulparams/aarch64linux32.sh: Likewise. * emulparams/armelf_fuchsia.sh: Likewise. * emulparams/armelf_linux.sh: Likewise. * emulparams/armelf_phoenix.sh: Likewise. * emulparams/aarch64elf.sh: Likewise, and __data_start * emulparams/aarch64elf32.sh: Likewise. * emulparams/armelf.sh: Likewise. * emulparams/armnto.sh: Likewise. * emulparams/elf32bmip.sh: Remove duplicate ". = ." from OTHER_GOT_SYMBOLS. PROVIDE _ftext, _fdata, and _fbss in shared libs. * emulparams/elf32bmipn32-defs.sh: Likewise. * emulparams/elf32frv.sh: PROVIDE __end and __data_start in shared libs. * emulparams/elf32lriscv-defs.sh: Tidy. * emulparams/elf32mcore.sh: PROVIDE __bss_start and _bss_end in shared libs * emulparams/elf32ppccommon.sh: PROVIDE __end in shared libs. * emulparams/elf32rl78.sh: Tidy. * emulparams/i386nto.sh: PROVIDE _btext in shared libs. * emulparams/shelf_nto.sh: Likewise. * emulparams/shlelf_nto.sh: Likewise. * emulparams/score3_elf.sh: PROVIDE _gp, _bss_start__, _bss_end__, __bss_end__, __end__, _fdata, _sdata_begin, and _bss_start in shared libs. * scripttempl/elf.sc: Don't use EXECUTABLE_SYMBOLS for shared libraries. PROVIDE _edata, edata, __bss_start, and _end in shared libraries. * testsuite/ld-elf/pr23161.map, * testsuite/ld-elf/pr23161a.c, * testsuite/ld-elf/pr23161b.c, * testsuite/ld-elf/pr23161c.c, * testsuite/ld-elf/pr23161a.rd, * testsuite/ld-elf/pr23161b.rd, * testsuite/ld-elf/pr23161c.rd, * testsuite/ld-elf/pr23161d.rd: New tests. * testsuite/ld-elf/shared.exp: Run ld/23161 tests. * testsuite/ld-elf/pr23162.rd, * testsuite/ld-aarch64/ifunc-1-local.d, * testsuite/ld-aarch64/ifunc-1.d, * testsuite/ld-aarch64/ifunc-2-local.d, * testsuite/ld-aarch64/ifunc-2.d, * testsuite/ld-aarch64/ifunc-21.d, * testsuite/ld-aarch64/ifunc-3a.d, * testsuite/ld-alpha/tlsbin.rd, * testsuite/ld-alpha/tlsbin.sd, * testsuite/ld-alpha/tlsbinr.rd, * testsuite/ld-alpha/tlspic.rd, * testsuite/ld-alpha/tlspic.sd, * testsuite/ld-cris/dso-pltdis1.d, * testsuite/ld-cris/dso-pltdis2.d, * testsuite/ld-cris/dso12-pltdis.d, * testsuite/ld-cris/gotplt1.d, * testsuite/ld-cris/gotplt2.d, * testsuite/ld-cris/gotplt3.d, * testsuite/ld-cris/hiddef1.d, * testsuite/ld-cris/libdso-1.d, * testsuite/ld-cris/libdso-10.d, * testsuite/ld-cris/libdso-11.d, * testsuite/ld-cris/libdso-12.d, * testsuite/ld-cris/libdso-12b.d, * testsuite/ld-cris/libdso-12c.d, * testsuite/ld-cris/libdso-13.d, * testsuite/ld-cris/libdso-13b.d, * testsuite/ld-cris/libdso-14.d, * testsuite/ld-cris/libdso-15.d, * testsuite/ld-cris/libdso-15b.d, * testsuite/ld-cris/libdso-1c.d, * testsuite/ld-cris/libdso-1d.d, * testsuite/ld-cris/libdso-2.d, * testsuite/ld-cris/pic-gc-72.d, * testsuite/ld-cris/pic-gc-73.d, * testsuite/ld-cris/pr16044.d, * testsuite/ld-cris/pv32-1.d, * testsuite/ld-cris/tls-dso-dtpoffd2.d, * testsuite/ld-cris/tls-dso-dtpoffd4.d, * testsuite/ld-cris/tls-dso-tpoffgotcomm1.d, * testsuite/ld-cris/tls-gc-71.d, * testsuite/ld-cris/tls-gd-1.d, * testsuite/ld-cris/tls-gd-1h.d, * testsuite/ld-cris/tls-gd-2.d, * testsuite/ld-cris/tls-gd-2h.d, * testsuite/ld-cris/tls-ie-10.d, * testsuite/ld-cris/tls-ie-11.d, * testsuite/ld-cris/tls-ie-78.d, * testsuite/ld-cris/tls-ie-8.d, * testsuite/ld-cris/tls-ie-9.d, * testsuite/ld-cris/tls-js1.d, * testsuite/ld-cris/tls-ld-4.d, * testsuite/ld-cris/tls-ld-5.d, * testsuite/ld-cris/tls-ld-6.d, * testsuite/ld-cris/tls-ld-7.d, * testsuite/ld-cris/tls-ldgd-14.d, * testsuite/ld-cris/tls-ldgd-15.d, * testsuite/ld-cris/tls-ldgdex-14.d, * testsuite/ld-cris/tls-ldgdex-15.d, * testsuite/ld-cris/tls-ldgdx-14.d, * testsuite/ld-cris/tls-ldgdx-15.d, * testsuite/ld-cris/tls-legdx-16.d, * testsuite/ld-cris/tls-legdx-17.d, * testsuite/ld-cris/tls-local-54.d, * testsuite/ld-cris/tls-local-60.d, * testsuite/ld-cris/tls-local-61.d, * testsuite/ld-cris/tls-local-63.d, * testsuite/ld-cris/tls-local-64.d, * testsuite/ld-cris/tls-ok-30.d, * testsuite/ld-cris/tls-ok-32.d, * testsuite/ld-cris/tls-ok-34.d, * testsuite/ld-cris/tls-und-38.d, * testsuite/ld-cris/tls-und-42.d, * testsuite/ld-cris/tls-und-46.d, * testsuite/ld-cris/tls-und-50.d, * testsuite/ld-cris/weakhiddso.d, * testsuite/ld-cris/weakref2.d, * testsuite/ld-frv/fdpic-shared-1.d, * testsuite/ld-frv/fdpic-shared-2.d, * testsuite/ld-frv/fdpic-shared-3.d, * testsuite/ld-frv/fdpic-shared-4.d, * testsuite/ld-frv/fdpic-shared-5.d, * testsuite/ld-frv/fdpic-shared-7.d, * testsuite/ld-frv/fdpic-shared-8.d, * testsuite/ld-frv/tls-dynamic-2.d, * testsuite/ld-i386/ibt-plt-1.d, * testsuite/ld-i386/ibt-plt-2a.d, * testsuite/ld-i386/ibt-plt-2b.d, * testsuite/ld-i386/ibt-plt-2c.d, * testsuite/ld-i386/ibt-plt-2d.d, * testsuite/ld-i386/ibt-plt-3a.d, * testsuite/ld-i386/ibt-plt-3b.d, * testsuite/ld-i386/ibt-plt-3c.d, * testsuite/ld-i386/ibt-plt-3d.d, * testsuite/ld-i386/plt2.dd, * testsuite/ld-i386/pr20830.d, * testsuite/ld-i386/tlsbin-nacl.rd, * testsuite/ld-i386/tlsbin.rd, * testsuite/ld-i386/tlsbin2-nacl.rd, * testsuite/ld-i386/tlsbin2.rd, * testsuite/ld-i386/tlsbindesc-nacl.rd, * testsuite/ld-i386/tlsbindesc.rd, * testsuite/ld-i386/tlsdesc-nacl.rd, * testsuite/ld-i386/tlsdesc.rd, * testsuite/ld-i386/tlsgdesc-nacl.rd, * testsuite/ld-i386/tlsgdesc.rd, * testsuite/ld-i386/tlsnopic-nacl.rd, * testsuite/ld-i386/tlsnopic.dd, * testsuite/ld-i386/tlsnopic.rd, * testsuite/ld-i386/tlsnopic.sd, * testsuite/ld-i386/tlspic-nacl.rd, * testsuite/ld-i386/tlspic.rd, * testsuite/ld-i386/tlspic2-nacl.rd, * testsuite/ld-i386/tlspic2.rd, * testsuite/ld-ia64/merge1.d, * testsuite/ld-ia64/merge2.d, * testsuite/ld-ia64/merge3.d, * testsuite/ld-ia64/merge4.d, * testsuite/ld-ia64/merge5.d, * testsuite/ld-ia64/tlsbin.rd, * testsuite/ld-ia64/tlspic.rd, * testsuite/ld-ifunc/ifunc-2-i386-now.d, * testsuite/ld-ifunc/ifunc-2-local-i386-now.d, * testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d, * testsuite/ld-ifunc/ifunc-2-local-x86-64.d, * testsuite/ld-ifunc/ifunc-2-x86-64-now.d, * testsuite/ld-ifunc/ifunc-2-x86-64.d, * testsuite/ld-ifunc/pr17154-i386-now.d, * testsuite/ld-ifunc/pr17154-i386.d, * testsuite/ld-ifunc/pr17154-x86-64-now.d, * testsuite/ld-ifunc/pr17154-x86-64.d, * testsuite/ld-m68k/tls-def-1.d, * testsuite/ld-m68k/tls-gd-1.d2, * testsuite/ld-metag/shared.d, * testsuite/ld-metag/stub_pic_app.d, * testsuite/ld-mips-elf/rel32-n32.d, * testsuite/ld-mips-elf/rel32-o32.d, * testsuite/ld-mips-elf/rel64.d, * testsuite/ld-powerpc/ambiguousv1.d, * testsuite/ld-powerpc/ambiguousv1b.d, * testsuite/ld-powerpc/ambiguousv2.d, * testsuite/ld-powerpc/ambiguousv2b.d, * testsuite/ld-powerpc/tlsexe.d, * testsuite/ld-powerpc/tlsexe.r, * testsuite/ld-powerpc/tlsexe32.d, * testsuite/ld-powerpc/tlsexe32.g, * testsuite/ld-powerpc/tlsexe32.r, * testsuite/ld-powerpc/tlsexetoc.d, * testsuite/ld-powerpc/tlsexetoc.r, * testsuite/ld-powerpc/tlsso.d, * testsuite/ld-powerpc/tlsso.r, * testsuite/ld-powerpc/tlsso32.g, * testsuite/ld-powerpc/tlsso32.r, * testsuite/ld-powerpc/tlstocso.d, * testsuite/ld-powerpc/tlstocso.g, * testsuite/ld-powerpc/tlstocso.r, * testsuite/ld-s390/gotreloc_31-1.dd, * testsuite/ld-s390/tlsbin.dd, * testsuite/ld-s390/tlsbin.rd, * testsuite/ld-s390/tlsbin_64.dd, * testsuite/ld-s390/tlsbin_64.rd, * testsuite/ld-s390/tlspic.rd, * testsuite/ld-s390/tlspic_64.rd, * testsuite/ld-sh/tlsbin-2.d, * testsuite/ld-sh/tlspic-2.d, * testsuite/ld-sparc/gotop32.rd, * testsuite/ld-sparc/gotop64.rd, * testsuite/ld-sparc/tlssunbin32.rd, * testsuite/ld-sparc/tlssunbin64.rd, * testsuite/ld-sparc/tlssunnopic32.rd, * testsuite/ld-sparc/tlssunnopic64.rd, * testsuite/ld-sparc/tlssunpic32.rd, * testsuite/ld-sparc/tlssunpic64.rd, * testsuite/ld-x86-64/bnd-branch-1-now.d, * testsuite/ld-x86-64/bnd-ifunc-1-now.d, * testsuite/ld-x86-64/bnd-ifunc-2-now.d, * testsuite/ld-x86-64/bnd-ifunc-2.d, * testsuite/ld-x86-64/bnd-plt-1-now.d, * testsuite/ld-x86-64/bnd-plt-1.d, * testsuite/ld-x86-64/ibt-plt-1-x32.d, * testsuite/ld-x86-64/ibt-plt-1.d, * testsuite/ld-x86-64/ibt-plt-2a-x32.d, * testsuite/ld-x86-64/ibt-plt-2a.d, * testsuite/ld-x86-64/ibt-plt-2b-x32.d, * testsuite/ld-x86-64/ibt-plt-2b.d, * testsuite/ld-x86-64/ibt-plt-2c-x32.d, * testsuite/ld-x86-64/ibt-plt-2c.d, * testsuite/ld-x86-64/ibt-plt-2d-x32.d, * testsuite/ld-x86-64/ibt-plt-2d.d, * testsuite/ld-x86-64/ibt-plt-3a-x32.d, * testsuite/ld-x86-64/ibt-plt-3a.d, * testsuite/ld-x86-64/ibt-plt-3b-x32.d, * testsuite/ld-x86-64/ibt-plt-3b.d, * testsuite/ld-x86-64/ibt-plt-3c-x32.d, * testsuite/ld-x86-64/ibt-plt-3c.d, * testsuite/ld-x86-64/ibt-plt-3d-x32.d, * testsuite/ld-x86-64/ibt-plt-3d.d, * testsuite/ld-x86-64/ilp32-4-nacl.d, * testsuite/ld-x86-64/ilp32-4.d, * testsuite/ld-x86-64/load1c-nacl.d, * testsuite/ld-x86-64/load1c.d, * testsuite/ld-x86-64/load1d-nacl.d, * testsuite/ld-x86-64/load1d.d, * testsuite/ld-x86-64/mpx3n.dd, * testsuite/ld-x86-64/mpx4.dd, * testsuite/ld-x86-64/mpx4n.dd, * testsuite/ld-x86-64/plt2.dd, * testsuite/ld-x86-64/pr14207.d, * testsuite/ld-x86-64/pr19162.d, * testsuite/ld-x86-64/pr20253-1f.d, * testsuite/ld-x86-64/pr20253-1l.d, * testsuite/ld-x86-64/pr20830a-now.d, * testsuite/ld-x86-64/pr20830a.d, * testsuite/ld-x86-64/pr20830b-now.d, * testsuite/ld-x86-64/pr20830b.d, * testsuite/ld-x86-64/pr21038a-now.d, * testsuite/ld-x86-64/pr21038a.d, * testsuite/ld-x86-64/pr21038b-now.d, * testsuite/ld-x86-64/pr21038b.d, * testsuite/ld-x86-64/pr21038c-now.d, * testsuite/ld-x86-64/pr21038c.d, * testsuite/ld-x86-64/tlsbin-nacl.rd, * testsuite/ld-x86-64/tlsbin.rd, * testsuite/ld-x86-64/tlsbin2-nacl.rd, * testsuite/ld-x86-64/tlsbin2.rd, * testsuite/ld-x86-64/tlsbindesc-nacl.rd, * testsuite/ld-x86-64/tlsbindesc.rd, * testsuite/ld-x86-64/tlsdesc-nacl.rd, * testsuite/ld-x86-64/tlsdesc.rd, * testsuite/ld-x86-64/tlsgdesc-nacl.rd, * testsuite/ld-x86-64/tlsgdesc.rd, * testsuite/ld-x86-64/tlspic-nacl.rd, * testsuite/ld-x86-64/tlspic.rd, * testsuite/ld-x86-64/tlspic2-nacl.rd, * testsuite/ld-x86-64/tlspic2.rd: Update. --- ld/emulparams/aarch64cloudabi.sh | 6 +++--- ld/emulparams/aarch64elf.sh | 8 ++++---- ld/emulparams/aarch64elf32.sh | 8 ++++---- ld/emulparams/aarch64fbsd.sh | 6 +++--- ld/emulparams/aarch64linux.sh | 6 +++--- ld/emulparams/aarch64linux32.sh | 6 +++--- ld/emulparams/armelf.sh | 8 ++++---- ld/emulparams/armelf_fuchsia.sh | 6 +++--- ld/emulparams/armelf_linux.sh | 6 +++--- ld/emulparams/armelf_phoenix.sh | 6 +++--- ld/emulparams/armnto.sh | 8 ++++---- ld/emulparams/elf32bmip.sh | 16 ++++++---------- ld/emulparams/elf32bmipn32-defs.sh | 16 ++++++---------- ld/emulparams/elf32frv.sh | 4 ++-- ld/emulparams/elf32lriscv-defs.sh | 3 +-- ld/emulparams/elf32mcore.sh | 4 ++-- ld/emulparams/elf32ppccommon.sh | 2 +- ld/emulparams/elf32rl78.sh | 8 ++------ ld/emulparams/i386nto.sh | 2 +- ld/emulparams/score3_elf.sh | 16 ++++++---------- ld/emulparams/shelf_nto.sh | 2 +- ld/emulparams/shlelf_nto.sh | 2 +- 22 files changed, 66 insertions(+), 83 deletions(-) (limited to 'ld/emulparams') diff --git a/ld/emulparams/aarch64cloudabi.sh b/ld/emulparams/aarch64cloudabi.sh index 6223f26..1b8ca15 100644 --- a/ld/emulparams/aarch64cloudabi.sh +++ b/ld/emulparams/aarch64cloudabi.sh @@ -27,9 +27,9 @@ DATA_START_SYMBOLS='PROVIDE (__data_start = .);'; # AArch64 does not support .s* sections. NO_SMALL_DATA=yes -OTHER_BSS_SYMBOLS='__bss_start__ = .;' -OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ;' -OTHER_END_SYMBOLS='__end__ = . ;' +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)};" +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)) }' diff --git a/ld/emulparams/aarch64elf.sh b/ld/emulparams/aarch64elf.sh index 952f262..deea7b4 100644 --- a/ld/emulparams/aarch64elf.sh +++ b/ld/emulparams/aarch64elf.sh @@ -23,14 +23,14 @@ SEPARATE_GOTPLT=24 IREL_IN_PLT= TEXT_START_ADDR=0x00400000 -DATA_START_SYMBOLS='__data_start = . ;'; +DATA_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__data_start = .${CREATE_SHLIB+)};" # AArch64 does not support .s* sections. NO_SMALL_DATA=yes -OTHER_BSS_SYMBOLS='__bss_start__ = .;' -OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ;' -OTHER_END_SYMBOLS='__end__ = . ;' +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; __bss_end__ = .${CREATE_SHLIB+)};" +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)) }' diff --git a/ld/emulparams/aarch64elf32.sh b/ld/emulparams/aarch64elf32.sh index ae96f02..38bcd4b 100644 --- a/ld/emulparams/aarch64elf32.sh +++ b/ld/emulparams/aarch64elf32.sh @@ -23,14 +23,14 @@ SEPARATE_GOTPLT=12 IREL_IN_PLT= TEXT_START_ADDR=0x00400000 -DATA_START_SYMBOLS='__data_start = . ;'; +DATA_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__data_start = .${CREATE_SHLIB+)};" # AArch64 does not support .s* sections. NO_SMALL_DATA=yes -OTHER_BSS_SYMBOLS='__bss_start__ = .;' -OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ;' -OTHER_END_SYMBOLS='__end__ = . ;' +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)};" +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)) }' diff --git a/ld/emulparams/aarch64fbsd.sh b/ld/emulparams/aarch64fbsd.sh index ff36787..4a307cd 100644 --- a/ld/emulparams/aarch64fbsd.sh +++ b/ld/emulparams/aarch64fbsd.sh @@ -27,9 +27,9 @@ DATA_START_SYMBOLS='PROVIDE (__data_start = .);'; # AArch64 does not support .s* sections. NO_SMALL_DATA=yes -OTHER_BSS_SYMBOLS='__bss_start__ = .;' -OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ;' -OTHER_END_SYMBOLS='__end__ = . ;' +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)};" +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)) }' diff --git a/ld/emulparams/aarch64linux.sh b/ld/emulparams/aarch64linux.sh index 9a78828..2ba1d79 100644 --- a/ld/emulparams/aarch64linux.sh +++ b/ld/emulparams/aarch64linux.sh @@ -27,9 +27,9 @@ DATA_START_SYMBOLS='PROVIDE (__data_start = .);'; # AArch64 does not support .s* sections. NO_SMALL_DATA=yes -OTHER_BSS_SYMBOLS='__bss_start__ = .;' -OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ;' -OTHER_END_SYMBOLS='__end__ = . ;' +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)};" +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)) }' diff --git a/ld/emulparams/aarch64linux32.sh b/ld/emulparams/aarch64linux32.sh index 45f84e9..0b4d4c9 100644 --- a/ld/emulparams/aarch64linux32.sh +++ b/ld/emulparams/aarch64linux32.sh @@ -27,9 +27,9 @@ DATA_START_SYMBOLS='PROVIDE (__data_start = .);'; # AArch64 does not support .s* sections. NO_SMALL_DATA=yes -OTHER_BSS_SYMBOLS='__bss_start__ = .;' -OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ;' -OTHER_END_SYMBOLS='__end__ = . ;' +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)};" +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)) }' diff --git a/ld/emulparams/armelf.sh b/ld/emulparams/armelf.sh index f581c68..272a8bc 100644 --- a/ld/emulparams/armelf.sh +++ b/ld/emulparams/armelf.sh @@ -7,9 +7,9 @@ TEXT_START_ADDR=0x8000 TEMPLATE_NAME=elf32 EXTRA_EM_FILE=armelf OTHER_TEXT_SECTIONS='*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)' -OTHER_BSS_SYMBOLS='__bss_start__ = .;' -OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ;' -OTHER_END_SYMBOLS='__end__ = . ;' +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)};" +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)) }' OTHER_READONLY_SECTIONS=" @@ -18,7 +18,7 @@ OTHER_READONLY_SECTIONS=" .ARM.exidx ${RELOCATING-0} : { *(.ARM.exidx${RELOCATING+* .gnu.linkonce.armexidx.*}) } ${RELOCATING+ PROVIDE_HIDDEN (__exidx_end = .); }" -DATA_START_SYMBOLS='__data_start = . ;'; +DATA_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__data_start = .${CREATE_SHLIB+)};" GENERATE_SHLIB_SCRIPT=yes GENERATE_PIE_SCRIPT=yes diff --git a/ld/emulparams/armelf_fuchsia.sh b/ld/emulparams/armelf_fuchsia.sh index 8626b0e..36392f1 100644 --- a/ld/emulparams/armelf_fuchsia.sh +++ b/ld/emulparams/armelf_fuchsia.sh @@ -12,9 +12,9 @@ GENERATE_PIE_SCRIPT=yes DATA_START_SYMBOLS='PROVIDE (__data_start = .);'; OTHER_TEXT_SECTIONS='*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)' -OTHER_BSS_SYMBOLS='__bss_start__ = .;' -OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ;' -OTHER_END_SYMBOLS='__end__ = . ;' +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)};" +OTHER_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__end__ = .${CREATE_SHLIB+)};" OTHER_SECTIONS='.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }' TEXT_START_ADDR=0x00001000 diff --git a/ld/emulparams/armelf_linux.sh b/ld/emulparams/armelf_linux.sh index 280db84..d726d63 100644 --- a/ld/emulparams/armelf_linux.sh +++ b/ld/emulparams/armelf_linux.sh @@ -12,9 +12,9 @@ GENERATE_PIE_SCRIPT=yes DATA_START_SYMBOLS='PROVIDE (__data_start = .);'; OTHER_TEXT_SECTIONS='*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)' -OTHER_BSS_SYMBOLS='__bss_start__ = .;' -OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ;' -OTHER_END_SYMBOLS='__end__ = . ;' +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)};" +OTHER_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__end__ = .${CREATE_SHLIB+)};" OTHER_SECTIONS='.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }' TEXT_START_ADDR=0x00010000 diff --git a/ld/emulparams/armelf_phoenix.sh b/ld/emulparams/armelf_phoenix.sh index d78edaf..7fb1e2d 100644 --- a/ld/emulparams/armelf_phoenix.sh +++ b/ld/emulparams/armelf_phoenix.sh @@ -12,9 +12,9 @@ GENERATE_PIE_SCRIPT=yes DATA_START_SYMBOLS='PROVIDE (__data_start = .);'; OTHER_TEXT_SECTIONS='*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)' -OTHER_BSS_SYMBOLS='__bss_start__ = .;' -OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ;' -OTHER_END_SYMBOLS='__end__ = . ;' +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)};" +OTHER_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__end__ = .${CREATE_SHLIB+)};" OTHER_SECTIONS='.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }' TEXT_START_ADDR=0x00001000 diff --git a/ld/emulparams/armnto.sh b/ld/emulparams/armnto.sh index f89f14f..79be999 100644 --- a/ld/emulparams/armnto.sh +++ b/ld/emulparams/armnto.sh @@ -7,11 +7,11 @@ TEXT_START_ADDR=0x00100000 TEMPLATE_NAME=elf32 EXTRA_EM_FILE=armelf OTHER_TEXT_SECTIONS='*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)' -OTHER_BSS_SYMBOLS='__bss_start__ = .;' -OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ;' -OTHER_END_SYMBOLS='__end__ = . ;' +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)};" +OTHER_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__end__ = .${CREATE_SHLIB+)};" -DATA_START_SYMBOLS='__data_start = . ;'; +DATA_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__data_start = .${CREATE_SHLIB+)};" GENERATE_SHLIB_SCRIPT=yes diff --git a/ld/emulparams/elf32bmip.sh b/ld/emulparams/elf32bmip.sh index 8da0f8f..da5e7fb 100644 --- a/ld/emulparams/elf32bmip.sh +++ b/ld/emulparams/elf32bmip.sh @@ -29,13 +29,9 @@ OTHER_GOT_RELOC_SECTIONS=" .rel.dyn ${RELOCATING-0} : { *(.rel.dyn) } " # If the output has a GOT section, there must be exactly 0x7ff0 bytes -# between .got and _gp. The ". = ." below stops the orphan code from -# inserting other sections between the assignment to _gp and the start -# of .got. -OTHER_GOT_SYMBOLS=' - . = .; - HIDDEN (_gp = ALIGN (16) + 0x7ff0); -' +# between .got and _gp. +OTHER_GOT_SYMBOLS='HIDDEN (_gp = ALIGN (16) + 0x7ff0);' + # .got.plt is only used for the PLT psABI extension. It should not be # included in the .sdata block with .got, as there is no need to access # the section from _gp. Note that the traditional: @@ -59,9 +55,9 @@ OTHER_SDATA_SECTIONS=" .lit8 ${RELOCATING-0} : { *(.lit8) } .lit4 ${RELOCATING-0} : { *(.lit4) } " -TEXT_START_SYMBOLS='_ftext = . ;' -DATA_START_SYMBOLS='_fdata = . ;' -OTHER_BSS_SYMBOLS='_fbss = .;' +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) } diff --git a/ld/emulparams/elf32bmipn32-defs.sh b/ld/emulparams/elf32bmipn32-defs.sh index 46b3f83..bd01790 100644 --- a/ld/emulparams/elf32bmipn32-defs.sh +++ b/ld/emulparams/elf32bmipn32-defs.sh @@ -48,13 +48,9 @@ OTHER_GOT_RELOC_SECTIONS=" " # GOT-related settings. # If the output has a GOT section, there must be exactly 0x7ff0 bytes -# between .got and _gp. The ". = ." below stops the orphan code from -# inserting other sections between the assignment to _gp and the start -# of .got. -OTHER_GOT_SYMBOLS=' - . = .; - HIDDEN (_gp = ALIGN (16) + 0x7ff0); -' +# between .got and _gp. +OTHER_GOT_SYMBOLS='HIDDEN (_gp = ALIGN (16) + 0x7ff0);' + # .got.plt is only used for the PLT psABI extension. It should not be # included in the .sdata block with .got, as there is no need to access # the section from _gp. Note that the traditional: @@ -81,9 +77,9 @@ OTHER_SDATA_SECTIONS=" " # Magic symbols. -TEXT_START_SYMBOLS='_ftext = . ;' -DATA_START_SYMBOLS='_fdata = . ;' -OTHER_BSS_SYMBOLS='_fbss = .;' +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+)};" INITIAL_READONLY_SECTIONS= if test -z "${CREATE_SHLIB}"; then diff --git a/ld/emulparams/elf32frv.sh b/ld/emulparams/elf32frv.sh index 9037072..581b7bc 100644 --- a/ld/emulparams/elf32frv.sh +++ b/ld/emulparams/elf32frv.sh @@ -9,8 +9,8 @@ MAXPAGESIZE=256 ENTRY=_start EMBEDDED=yes OTHER_EXCLUDE_FILES='*frvend.o' -OTHER_END_SYMBOLS='__end = .;' -DATA_START_SYMBOLS='__data_start = . ;' +OTHER_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__end = .${CREATE_SHLIB+)};" +DATA_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__data_start = .${CREATE_SHLIB+)};" STACK_ADDR=0x200000 NOP=0x80000000 OTHER_GOT_SYMBOLS=' diff --git a/ld/emulparams/elf32lriscv-defs.sh b/ld/emulparams/elf32lriscv-defs.sh index f373ece..91015d4 100644 --- a/ld/emulparams/elf32lriscv-defs.sh +++ b/ld/emulparams/elf32lriscv-defs.sh @@ -30,8 +30,7 @@ TEXT_START_ADDR=0x10000 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" -SDATA_START_SYMBOLS="__global_pointer$ = . + 0x800;" -SDATA_START_SYMBOLS="${CREATE_SHLIB-${SDATA_START_SYMBOLS}} +SDATA_START_SYMBOLS="${CREATE_SHLIB-__global_pointer$ = . + 0x800;} *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)" INITIAL_READONLY_SECTIONS=".interp : { *(.interp) } ${CREATE_PIE-${INITIAL_READONLY_SECTIONS}}" diff --git a/ld/emulparams/elf32mcore.sh b/ld/emulparams/elf32mcore.sh index 1e14c19..8a09bba 100644 --- a/ld/emulparams/elf32mcore.sh +++ b/ld/emulparams/elf32mcore.sh @@ -21,8 +21,8 @@ EMBEDDED=yes # not matter. NOP=0x0e0e0e0e -OTHER_BSS_SYMBOLS="__bss_start__ = . ;" -OTHER_BSS_END_SYMBOLS="__bss_end__ = . ;" +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)};" # This sets the stack to the top of the simulator memory (2^19 bytes). STACK_ADDR=0x80000 diff --git a/ld/emulparams/elf32ppccommon.sh b/ld/emulparams/elf32ppccommon.sh index 44edbd0..11a4d53 100644 --- a/ld/emulparams/elf32ppccommon.sh +++ b/ld/emulparams/elf32ppccommon.sh @@ -23,7 +23,7 @@ else unset SBSS_START_SYMBOLS unset SBSS_END_SYMBOLS fi -OTHER_END_SYMBOLS="__end = .;" +OTHER_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__end = .${CREATE_SHLIB+)};" OTHER_RELRO_SECTIONS=" .fixup ${RELOCATING-0} : { *(.fixup) } .got1 ${RELOCATING-0} : { *(.got1) } diff --git a/ld/emulparams/elf32rl78.sh b/ld/emulparams/elf32rl78.sh index b782d03..d1a00e1 100644 --- a/ld/emulparams/elf32rl78.sh +++ b/ld/emulparams/elf32rl78.sh @@ -11,10 +11,6 @@ ELFSIZE=32 # EXTRA_EM_FILE=needrelax MAXPAGESIZE=256 -STACK_ADDR="(DEFINED(__stack) ? __stack : 0xffedc)" +STACK_ADDR="${CREATE_SHLIB-(DEFINED(__stack) ? __stack : 0xffedc)}" STACK_SENTINEL="LONG(0xdead)" -# We do not need .stack for shared library. -test -n "$CREATE_SHLIB" && unset STACK_ADDR - -OTHER_SYMBOLS="PROVIDE (__rl78_abs__ = 0);" -test -n "$CREATE_SHLIB" && unset OTHER_SYMBOLS +OTHER_SYMBOLS="${CREATE_SHLIB-PROVIDE (__rl78_abs__ = 0);}" diff --git a/ld/emulparams/i386nto.sh b/ld/emulparams/i386nto.sh index 626f9c1..bb685f3 100644 --- a/ld/emulparams/i386nto.sh +++ b/ld/emulparams/i386nto.sh @@ -2,7 +2,7 @@ SCRIPT_NAME=elf OUTPUT_FORMAT="elf32-i386" NO_RELA_RELOCS=yes TEXT_START_ADDR=0x08048000 -TEXT_START_SYMBOLS='_btext = .;' +TEXT_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_btext = .${CREATE_SHLIB+)};" MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" ARCH=i386 MACHINE= diff --git a/ld/emulparams/score3_elf.sh b/ld/emulparams/score3_elf.sh index 4636cd3..8fbd47b 100644 --- a/ld/emulparams/score3_elf.sh +++ b/ld/emulparams/score3_elf.sh @@ -12,17 +12,13 @@ TEXT_START_ADDR=0x00000000 MAXPAGESIZE=256 NONPAGED_TEXT_START_ADDR=0x0400000 SHLIB_TEXT_START_ADDR=0x5ffe0000 -OTHER_GOT_SYMBOLS=' - _gp = ALIGN(16) + 0x3ff0; -' +OTHER_GOT_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_gp = ALIGN(16) + 0x3ff0${CREATE_SHLIB+)};" -OTHER_BSS_START_SYMBOLS='_bss_start__ = . + ALIGN(4);' -OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ; __end__ = . ;' -DATA_START_SYMBOLS='_fdata = . ;' -SDATA_START_SYMBOLS='_sdata_begin = . ;' -OTHER_BSS_SYMBOLS=' - _bss_start = ALIGN(4) ; -' +OTHER_BSS_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_start__ = ALIGN(4)${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__end__ = .${CREATE_SHLIB+)};" +DATA_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_fdata = .${CREATE_SHLIB+)};" +SDATA_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_sdata_begin = .${CREATE_SHLIB+)};" +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_start = ALIGN(4)${CREATE_SHLIB+)};" # This sets the stack to the top of the simulator memory (2^19 bytes). STACK_ADDR=0x8000000 diff --git a/ld/emulparams/shelf_nto.sh b/ld/emulparams/shelf_nto.sh index c4d71aa..1dc5e46 100644 --- a/ld/emulparams/shelf_nto.sh +++ b/ld/emulparams/shelf_nto.sh @@ -7,5 +7,5 @@ ARCH=sh MACHINE= TEMPLATE_NAME=elf32 GENERATE_SHLIB_SCRIPT=yes -TEXT_START_SYMBOLS='_btext = .;' +TEXT_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_btext = .${CREATE_SHLIB+)};" ENTRY=_start diff --git a/ld/emulparams/shlelf_nto.sh b/ld/emulparams/shlelf_nto.sh index 16f6508..ddc4fc6 100644 --- a/ld/emulparams/shlelf_nto.sh +++ b/ld/emulparams/shlelf_nto.sh @@ -7,5 +7,5 @@ ARCH=sh MACHINE= TEMPLATE_NAME=elf32 GENERATE_SHLIB_SCRIPT=yes -TEXT_START_SYMBOLS='_btext = .;' +TEXT_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_btext = .${CREATE_SHLIB+)};" ENTRY=_start -- cgit v1.1