diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-04-14 04:12:55 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-04-14 04:13:11 -0700 |
commit | 889c2a67967f7047c245779a0a0fd8ba8796846e (patch) | |
tree | c6b6b56e0438ab85f6f508a13ac5287ed113b395 /ld/emulparams | |
parent | 887bddbcad907021f4cb98168cd51f2631e6cfc8 (diff) | |
download | gdb-889c2a67967f7047c245779a0a0fd8ba8796846e.zip gdb-889c2a67967f7047c245779a0a0fd8ba8796846e.tar.gz gdb-889c2a67967f7047c245779a0a0fd8ba8796846e.tar.bz2 |
Add -z noextern-protected-data to ld for ELF/x86
Address of protected data defined in the shared library may be external,
i.e., due to copy relocation. By default, linker backend checks if
relocations against protected data symbols are valid for building shared
library and issues an error if relocation isn't allowed. The new option
override linker backend default. When -z noextern-protected-data is used,
updates on protected data symbols by another module won't be visibile
to the resulting shared library. This option is specific to ELF/i386
and ELF/x86-64.
bfd/
PR ld/pr17709
* elflink.c (_bfd_elf_adjust_dynamic_copy): Check
info->extern_protected_data when warning copy relocs against
protected symbols.
(_bfd_elf_symbol_refs_local_p): Check info->extern_protected_data
when checking protected non-function symbols.
include/
PR ld/pr17709
* bfdlink.h (bfd_link_info): Add extern_protected_data.
ld/
PR ld/pr17709
* ld.texinfo: Document "-z noextern-protected-data".
* ldmain.c (main): Initialize link_info.extern_protected_data
to -1.
* lexsup.c (elf_shlib_list_options): Add
"-z [no]extern-protected-data".
* emulparams/elf32_x86_64.sh: Source extern_protected_data.sh.
* emulparams/elf_i386.sh: Likewise.
* emulparams/elf_i386_be.sh: Likewise.
* emulparams/elf_i386_chaos.sh: Likewise.
* emulparams/elf_i386_ldso.sh: Likewise.
* emulparams/elf_i386_vxworks.sh: Likewise.
* emulparams/elf_k1om.sh: Likewise.
* emulparams/elf_l1om.sh: Likewise.
* emulparams/elf_x86_64.sh: Source extern_protected_data.sh.
(PARSE_AND_LIST_OPTIONS): Renamed to ...
(PARSE_AND_LIST_OPTIONS_BNDPLT): This.
(PARSE_AND_LIST_ARGS_CASE_Z): Renamed to ...
(PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT): This.
(PARSE_AND_LIST_OPTIONS): Append $PARSE_AND_LIST_OPTIONS_BNDPLT.
(PARSE_AND_LIST_ARGS_CASE_Z): Append
$PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT.
* emulparams/extern_protected_data.sh: New file.
ld/testsuite/
PR ld/pr17709
* ld-i386/i386.exp: Run protected6b.
* ld-i386/protected6b.d: New file.
* ld-x86-64/protected6b.d: Likewise.
* ld-x86-64/x86-64.exp: Run protected6b.
Diffstat (limited to 'ld/emulparams')
-rw-r--r-- | ld/emulparams/elf32_x86_64.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_i386.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_i386_be.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_i386_chaos.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_i386_ldso.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_i386_vxworks.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_k1om.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_l1om.sh | 1 | ||||
-rw-r--r-- | ld/emulparams/elf_x86_64.sh | 7 | ||||
-rw-r--r-- | ld/emulparams/extern_protected_data.sh | 9 |
10 files changed, 22 insertions, 2 deletions
diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh index 11d17ad..8fd96fb 100644 --- a/ld/emulparams/elf32_x86_64.sh +++ b/ld/emulparams/elf32_x86_64.sh @@ -1,4 +1,5 @@ . ${srcdir}/emulparams/plt_unwind.sh +. ${srcdir}/emulparams/extern_protected_data.sh SCRIPT_NAME=elf ELFSIZE=32 OUTPUT_FORMAT="elf32-x86-64" diff --git a/ld/emulparams/elf_i386.sh b/ld/emulparams/elf_i386.sh index 2ebfaac..ae87f6b 100644 --- a/ld/emulparams/elf_i386.sh +++ b/ld/emulparams/elf_i386.sh @@ -1,4 +1,5 @@ . ${srcdir}/emulparams/plt_unwind.sh +. ${srcdir}/emulparams/extern_protected_data.sh SCRIPT_NAME=elf OUTPUT_FORMAT="elf32-i386" NO_RELA_RELOCS=yes diff --git a/ld/emulparams/elf_i386_be.sh b/ld/emulparams/elf_i386_be.sh index 1e27faa..06a80c7 100644 --- a/ld/emulparams/elf_i386_be.sh +++ b/ld/emulparams/elf_i386_be.sh @@ -1,3 +1,4 @@ +. ${srcdir}/emulparams/extern_protected_data.sh SCRIPT_NAME=elf OUTPUT_FORMAT="elf32-i386" NO_RELA_RELOCS=yes diff --git a/ld/emulparams/elf_i386_chaos.sh b/ld/emulparams/elf_i386_chaos.sh index b3005e1..c59dbce 100644 --- a/ld/emulparams/elf_i386_chaos.sh +++ b/ld/emulparams/elf_i386_chaos.sh @@ -1,4 +1,5 @@ . ${srcdir}/emulparams/plt_unwind.sh +. ${srcdir}/emulparams/extern_protected_data.sh SCRIPT_NAME=elf_chaos OUTPUT_FORMAT="elf32-i386" TEXT_START_ADDR=0x40000000 diff --git a/ld/emulparams/elf_i386_ldso.sh b/ld/emulparams/elf_i386_ldso.sh index e1a2cb7..7fd08fe 100644 --- a/ld/emulparams/elf_i386_ldso.sh +++ b/ld/emulparams/elf_i386_ldso.sh @@ -1,4 +1,5 @@ . ${srcdir}/emulparams/plt_unwind.sh +. ${srcdir}/emulparams/extern_protected_data.sh SCRIPT_NAME=elf OUTPUT_FORMAT="elf32-i386" NO_RELA_RELOCS=yes diff --git a/ld/emulparams/elf_i386_vxworks.sh b/ld/emulparams/elf_i386_vxworks.sh index 61839c8..306e8d3 100644 --- a/ld/emulparams/elf_i386_vxworks.sh +++ b/ld/emulparams/elf_i386_vxworks.sh @@ -11,3 +11,4 @@ GENERATE_SHLIB_SCRIPT=yes GENERATE_PIE_SCRIPT=yes NO_SMALL_DATA=yes . ${srcdir}/emulparams/vxworks.sh +. ${srcdir}/emulparams/extern_protected_data.sh diff --git a/ld/emulparams/elf_k1om.sh b/ld/emulparams/elf_k1om.sh index 00bf2ca..0cd606a 100644 --- a/ld/emulparams/elf_k1om.sh +++ b/ld/emulparams/elf_k1om.sh @@ -1,4 +1,5 @@ . ${srcdir}/emulparams/plt_unwind.sh +. ${srcdir}/emulparams/extern_protected_data.sh SCRIPT_NAME=elf ELFSIZE=64 OUTPUT_FORMAT="elf64-k1om" diff --git a/ld/emulparams/elf_l1om.sh b/ld/emulparams/elf_l1om.sh index abf59f1..1964e85 100644 --- a/ld/emulparams/elf_l1om.sh +++ b/ld/emulparams/elf_l1om.sh @@ -1,4 +1,5 @@ . ${srcdir}/emulparams/plt_unwind.sh +. ${srcdir}/emulparams/extern_protected_data.sh SCRIPT_NAME=elf ELFSIZE=64 OUTPUT_FORMAT="elf64-l1om" diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh index 984e5e9..a304771 100644 --- a/ld/emulparams/elf_x86_64.sh +++ b/ld/emulparams/elf_x86_64.sh @@ -1,4 +1,5 @@ . ${srcdir}/emulparams/plt_unwind.sh +. ${srcdir}/emulparams/extern_protected_data.sh SCRIPT_NAME=elf ELFSIZE=64 OUTPUT_FORMAT="elf64-x86-64" @@ -36,14 +37,16 @@ case "$target" in case "$EMULATION_NAME" in *64*) LIBPATH_SUFFIX=64 - PARSE_AND_LIST_OPTIONS=' + PARSE_AND_LIST_OPTIONS_BNDPLT=' fprintf (file, _("\ -z bndplt Always generate BND prefix in PLT entries\n")); ' - PARSE_AND_LIST_ARGS_CASE_Z=' + PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT=' else if (strcmp (optarg, "bndplt") == 0) link_info.bndplt = TRUE; ' + PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_BNDPLT" + PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_BNDPLT" ;; esac ;; diff --git a/ld/emulparams/extern_protected_data.sh b/ld/emulparams/extern_protected_data.sh new file mode 100644 index 0000000..fd4bd3b --- /dev/null +++ b/ld/emulparams/extern_protected_data.sh @@ -0,0 +1,9 @@ +PARSE_AND_LIST_OPTIONS=' + fprintf (file, _("\ + -z noextern-protected-data Do not treat protected data symbol as external\n")); +' + +PARSE_AND_LIST_ARGS_CASE_Z=' + else if (strcmp (optarg, "noextern-protected-data") == 0) + link_info.extern_protected_data = FALSE; +' |