From f2aaebdb97977ee7a5c83c02af871e758e7d594b Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 1 Nov 2019 13:45:25 +1030 Subject: [PATCH] GENERATE_SHLIB_SCRIPT vs. EMBEDDED. A target that sets EMBEDDED non-empty is one that doesn't want to put the ELF file header or program header in a memory image. Likely the target isn't interested in supporting dynamically loaded executables, shared libraries, or PIEs, because loaders for such binaries generally require program headers to be present. This isn't 100% true though. The target might be one where the loader accesses the file system in order to retrieve headers. Also, note that not all "shared libraries" require gcc -shared or the shared library support in the linker. I believe one implementation of shared libraries on uclinux is like this. So, this patch removes GENERATE_SHLIB_SCRIPT and GENERATE_PIE_SCRIPT in most emulparams files where EMBEDDED is set, restoring the shared lib and pie support in emulparams files that unset EMBEDDED after including a file where the support is removed. Exceptions to the general rule that EMBEDDED disables shared libs are: arm*-*-symbianelf*, where the OS wants shared library support without ELF program headers in the image, and sh*-*-uclinux*, where I've left things as they were, ie. both EMBEDDED and GENERATE_SHLIB_SCRIPT because I'm unsure as to the shared library scheme. * emulparams/aarch64elf.sh (GENERATE_SHLIB_SCRIPT), (GENERATE_PIE_SCRIPT): Don't set. * emulparams/aarch64elf32.sh (GENERATE_SHLIB_SCRIPT), (GENERATE_PIE_SCRIPT): Don't set. * emulparams/arcelf.sh (GENERATE_SHLIB_SCRIPT): Don't set. * emulparams/armelf.sh (GENERATE_SHLIB_SCRIPT), (GENERATE_PIE_SCRIPT): Don't set. * emulparams/armelf_fbsd.sh (GENERATE_SHLIB_SCRIPT): Set. * emulparams/armelf_nbsd.sh (GENERATE_SHLIB_SCRIPT), (GENERATE_PIE_SCRIPT): Set. * emulparams/armelf_vxworks.sh (GENERATE_SHLIB_SCRIPT): Set. * emulparams/armsymbian.sh (GENERATE_SHLIB_SCRIPT): Set. * emulparams/elf32bfin.sh (GENERATE_SHLIB_SCRIPT): Don't set. * emulparams/elf32microblaze.sh (GENERATE_SHLIB_SCRIPT): Don't set. * emulparams/score3_elf.sh (GENERATE_SHLIB_SCRIPT): Don't set. * emulparams/shelf.sh (GENERATE_SHLIB_SCRIPT): Don't set. * emulparams/shelf_nbsd.sh (GENERATE_SHLIB_SCRIPT), (GENERATE_PIE_SCRIPT): Set. * emulparams/shelf_uclinux.sh (GENERATE_SHLIB_SCRIPT): Set. --- ld/ChangeLog | 22 ++++++++++++++++++++++ ld/emulparams/aarch64elf.sh | 3 --- ld/emulparams/aarch64elf32.sh | 3 --- ld/emulparams/arcelf.sh | 2 -- ld/emulparams/armelf.sh | 3 --- ld/emulparams/armelf_fbsd.sh | 2 +- ld/emulparams/armelf_nbsd.sh | 2 ++ ld/emulparams/armelf_vxworks.sh | 1 + ld/emulparams/armsymbian.sh | 2 ++ ld/emulparams/elf32bfin.sh | 1 - ld/emulparams/elf32microblaze.sh | 3 --- ld/emulparams/score3_elf.sh | 1 - ld/emulparams/shelf.sh | 1 - ld/emulparams/shelf_nbsd.sh | 2 ++ ld/emulparams/shelf_uclinux.sh | 1 + 15 files changed, 31 insertions(+), 18 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 2741f877d0a..431e5b62b1f 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,25 @@ +2019-11-05 Alan Modra + + * emulparams/aarch64elf.sh (GENERATE_SHLIB_SCRIPT), + (GENERATE_PIE_SCRIPT): Don't set. + * emulparams/aarch64elf32.sh (GENERATE_SHLIB_SCRIPT), + (GENERATE_PIE_SCRIPT): Don't set. + * emulparams/arcelf.sh (GENERATE_SHLIB_SCRIPT): Don't set. + * emulparams/armelf.sh (GENERATE_SHLIB_SCRIPT), + (GENERATE_PIE_SCRIPT): Don't set. + * emulparams/armelf_fbsd.sh (GENERATE_SHLIB_SCRIPT): Set. + * emulparams/armelf_nbsd.sh (GENERATE_SHLIB_SCRIPT), + (GENERATE_PIE_SCRIPT): Set. + * emulparams/armelf_vxworks.sh (GENERATE_SHLIB_SCRIPT): Set. + * emulparams/armsymbian.sh (GENERATE_SHLIB_SCRIPT): Set. + * emulparams/elf32bfin.sh (GENERATE_SHLIB_SCRIPT): Don't set. + * emulparams/elf32microblaze.sh (GENERATE_SHLIB_SCRIPT): Don't set. + * emulparams/score3_elf.sh (GENERATE_SHLIB_SCRIPT): Don't set. + * emulparams/shelf.sh (GENERATE_SHLIB_SCRIPT): Don't set. + * emulparams/shelf_nbsd.sh (GENERATE_SHLIB_SCRIPT), + (GENERATE_PIE_SCRIPT): Set. + * emulparams/shelf_uclinux.sh (GENERATE_SHLIB_SCRIPT): Set. + 2019-11-05 Alan Modra * emulparams/elf32bfinfd.sh: Unset EMBEDDED rather assigning as empty. diff --git a/ld/emulparams/aarch64elf.sh b/ld/emulparams/aarch64elf.sh index 8f68e517b45..5c70b556864 100644 --- a/ld/emulparams/aarch64elf.sh +++ b/ld/emulparams/aarch64elf.sh @@ -12,9 +12,6 @@ NO_REL_RELOCS=yes TEMPLATE_NAME=elf EXTRA_EM_FILE=aarch64elf -GENERATE_SHLIB_SCRIPT=yes -GENERATE_PIE_SCRIPT=yes - MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" ENTRY=_start diff --git a/ld/emulparams/aarch64elf32.sh b/ld/emulparams/aarch64elf32.sh index 5a08d9e29f1..a94025a139b 100644 --- a/ld/emulparams/aarch64elf32.sh +++ b/ld/emulparams/aarch64elf32.sh @@ -12,9 +12,6 @@ NO_REL_RELOCS=yes TEMPLATE_NAME=elf EXTRA_EM_FILE=aarch64elf -GENERATE_SHLIB_SCRIPT=yes -GENERATE_PIE_SCRIPT=yes - MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" ENTRY=_start diff --git a/ld/emulparams/arcelf.sh b/ld/emulparams/arcelf.sh index 625ec397790..b6d8f9fdf76 100644 --- a/ld/emulparams/arcelf.sh +++ b/ld/emulparams/arcelf.sh @@ -19,5 +19,3 @@ SDATA_START_SYMBOLS='__SDATA_BEGIN__ = . + 0x100;' JLI_START_TABLE='__JLI_TABLE__ = .;' OTHER_SECTIONS="/DISCARD/ : { *(.__arc_profile_*) }" EMBEDDED=yes - -GENERATE_SHLIB_SCRIPT=yes diff --git a/ld/emulparams/armelf.sh b/ld/emulparams/armelf.sh index 0e3147c1f24..8977fd6fea8 100644 --- a/ld/emulparams/armelf.sh +++ b/ld/emulparams/armelf.sh @@ -32,9 +32,6 @@ OTHER_READONLY_SECTIONS=" DATA_START_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__data_start = .${CREATE_SHLIB+)};" -GENERATE_SHLIB_SCRIPT=yes -GENERATE_PIE_SCRIPT=yes - ARCH=arm MACHINE= MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" diff --git a/ld/emulparams/armelf_fbsd.sh b/ld/emulparams/armelf_fbsd.sh index be88c2f2e0e..4428b91a34f 100644 --- a/ld/emulparams/armelf_fbsd.sh +++ b/ld/emulparams/armelf_fbsd.sh @@ -5,7 +5,7 @@ TEXT_START_ADDR=0x00010000 TARGET2_TYPE=got-rel MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" +GENERATE_SHLIB_SCRIPT=yes GENERATE_PIE_SCRIPT=yes - unset STACK_ADDR unset EMBEDDED diff --git a/ld/emulparams/armelf_nbsd.sh b/ld/emulparams/armelf_nbsd.sh index 37e1a4afdd0..45954597ee5 100644 --- a/ld/emulparams/armelf_nbsd.sh +++ b/ld/emulparams/armelf_nbsd.sh @@ -3,5 +3,7 @@ MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" TEXT_START_ADDR=0x00008000 TARGET2_TYPE=got-rel +GENERATE_SHLIB_SCRIPT=yes +GENERATE_PIE_SCRIPT=yes unset STACK_ADDR unset EMBEDDED diff --git a/ld/emulparams/armelf_vxworks.sh b/ld/emulparams/armelf_vxworks.sh index 5f57535feed..e344209905e 100644 --- a/ld/emulparams/armelf_vxworks.sh +++ b/ld/emulparams/armelf_vxworks.sh @@ -4,3 +4,4 @@ BIG_OUTPUT_FORMAT="elf32-bigarm-vxworks" LITTLE_OUTPUT_FORMAT="$OUTPUT_FORMAT" MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" source_sh ${srcdir}/emulparams/vxworks.sh +GENERATE_SHLIB_SCRIPT=yes diff --git a/ld/emulparams/armsymbian.sh b/ld/emulparams/armsymbian.sh index 1959685f9b4..183750a5647 100644 --- a/ld/emulparams/armsymbian.sh +++ b/ld/emulparams/armsymbian.sh @@ -8,6 +8,8 @@ TARGET1_IS_REL=1 TARGET2_TYPE=abs # On BPABI systems, program headers should not be mapped. EMBEDDED=yes +# Nonetheless, shared libraries are also supported +GENERATE_SHLIB_SCRIPT=yes # As for armelf.sh, but add the SymbianOS-specific # .ARM.exidx$${Base,Limit} symbols. diff --git a/ld/emulparams/elf32bfin.sh b/ld/emulparams/elf32bfin.sh index 8d298b467c9..6e08035b6f3 100644 --- a/ld/emulparams/elf32bfin.sh +++ b/ld/emulparams/elf32bfin.sh @@ -6,7 +6,6 @@ TARGET_PAGE_SIZE=0x1000 ARCH=bfin MACHINE= TEMPLATE_NAME=elf -GENERATE_SHLIB_SCRIPT=yes EMBEDDED=yes USER_LABEL_PREFIX=_ EXTRA_EM_FILE=bfin diff --git a/ld/emulparams/elf32microblaze.sh b/ld/emulparams/elf32microblaze.sh index f867018eb38..698adb7cf83 100644 --- a/ld/emulparams/elf32microblaze.sh +++ b/ld/emulparams/elf32microblaze.sh @@ -21,6 +21,3 @@ NOP=0x80000000 #OTHER_RELOCATING_SECTIONS='PROVIDE (_stack = _end + 0x1000);' TEMPLATE_NAME=elf -#GENERATE_SHLIB_SCRIPT=yes - - diff --git a/ld/emulparams/score3_elf.sh b/ld/emulparams/score3_elf.sh index 7be7883363e..78401876e5f 100644 --- a/ld/emulparams/score3_elf.sh +++ b/ld/emulparams/score3_elf.sh @@ -26,4 +26,3 @@ ARCH=score3 MACHINE= ENTRY=_start EMBEDDED=yes -GENERATE_SHLIB_SCRIPT=yes diff --git a/ld/emulparams/shelf.sh b/ld/emulparams/shelf.sh index 63c2ff19dc9..96c18c07502 100644 --- a/ld/emulparams/shelf.sh +++ b/ld/emulparams/shelf.sh @@ -9,7 +9,6 @@ MAXPAGESIZE=128 ARCH=sh MACHINE= TEMPLATE_NAME=elf -GENERATE_SHLIB_SCRIPT=yes EMBEDDED=yes # These are for compatibility with the COFF toolchain. ENTRY=start diff --git a/ld/emulparams/shelf_nbsd.sh b/ld/emulparams/shelf_nbsd.sh index 391399660d8..57db803d002 100644 --- a/ld/emulparams/shelf_nbsd.sh +++ b/ld/emulparams/shelf_nbsd.sh @@ -11,5 +11,7 @@ DATA_START_SYMBOLS='PROVIDE (__data_start = .);'; ENTRY=_start +GENERATE_SHLIB_SCRIPT=yes +GENERATE_PIE_SCRIPT=yes unset EMBEDDED unset STACK_ADDR diff --git a/ld/emulparams/shelf_uclinux.sh b/ld/emulparams/shelf_uclinux.sh index a22c35a9a8a..41044f028ce 100644 --- a/ld/emulparams/shelf_uclinux.sh +++ b/ld/emulparams/shelf_uclinux.sh @@ -2,3 +2,4 @@ source_sh ${srcdir}/emulparams/shelf.sh # We do not want a .stack section unset STACK_ADDR +GENERATE_SHLIB_SCRIPT=yes -- 2.30.2