aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-03-05 06:34:39 -0800
committerH.J. Lu <hjl.tools@gmail.com>2015-04-10 11:06:34 -0700
commitf74839702efcea048ac61374b1539ae81e7c86cc (patch)
tree3e5461167d93f4a40cc81f1e9879938e55471f4d /bfd/elflink.c
parentde3db44c87a30c67deb38fa9d43d2db3bc98c161 (diff)
downloadgdb-f74839702efcea048ac61374b1539ae81e7c86cc.zip
gdb-f74839702efcea048ac61374b1539ae81e7c86cc.tar.gz
gdb-f74839702efcea048ac61374b1539ae81e7c86cc.tar.bz2
Add extern_protected_data and set it for x86
Re-apply: commit ca3fe95e469b9daec153caa2c90665f5daaec2b5 With copy relocation, address of protected data defined in the shared library may be external. This patch adds extern_protected_data and changes _bfd_elf_symbol_refs_local_p to return false for protected data if extern_protected_data is true. This patch will break building shared libraries with protected data symbols using GCCs older than GCC 5 without the bug fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248 GCC backport request should be made in the GCC bug report above. To get correct run-time behavior on Linux, glibc 2.22 or above are required, which have the bug fix for https://sourceware.org/bugzilla/show_bug.cgi?id=17711 Backports for glibc 2.21, 2.20, 2.19 and 2.18 are on hjl/pr17711/2.21, hjl/pr17711/2.20, hjl/pr17711/2.19 and hjl/pr17711/2.18 branches, respectively, at https://sourceware.org/git/?p=glibc.git;a=summary bfd/ PR ld/pr15228 PR ld/pr17709 * elf-bfd.h (elf_backend_data): Add extern_protected_data. * elf32-i386.c (elf_backend_extern_protected_data): New. Defined to 1. * elf64-x86-64.c (elf_backend_extern_protected_data): Likewise. * elflink.c (_bfd_elf_adjust_dynamic_copy): Don't error on copy relocs against protected symbols if extern_protected_data is true. (_bfd_elf_symbol_refs_local_p): Don't return true on protected non-function symbols if extern_protected_data is true. * elfxx-target.h (elf_backend_extern_protected_data): New. Default to 0. (elfNN_bed): Initialize extern_protected_data with elf_backend_extern_protected_data. ld/testsuite/ PR ld/pr15228 PR ld/pr17709 * ld-i386/i386.exp (i386tests): Add a test for PR ld/17709. * ld-i386/pr17709-nacl.rd: New file. * ld-i386/pr17709.rd: Likewise. * ld-i386/pr17709a.s: Likewise. * ld-i386/pr17709b.s: Likewise. * ld-i386/protected3.d: Updated. * ld-i386/protected3.s: Likewise. * ld-x86-64/pr17709-nacl.rd: New file. * ld-x86-64/pr17709.rd: Likewise. * ld-x86-64/pr17709a.s: Likewise. * ld-x86-64/pr17709b.s: Likewise. * ld-x86-64/protected3.d: Updated. * ld-x86-64/protected3.s: Likewise. * ld-x86-64/x86-64.exp (x86_64tests): Add a test for PR ld/17709.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 5bc9e9b..98d3108 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -2673,7 +2673,9 @@ _bfd_elf_adjust_dynamic_copy (struct bfd_link_info *info,
/* Increment the size of DYNBSS to make room for the symbol. */
dynbss->size += h->size;
- if (h->protected_def)
+ /* No error if extern_protected_data is true. */
+ if (h->protected_def
+ && !get_elf_backend_data (dynbss->owner)->extern_protected_data)
info->callbacks->einfo
(_("%P: copy reloc against protected `%T' is dangerous\n"),
h->root.root.string);
@@ -2833,8 +2835,9 @@ _bfd_elf_symbol_refs_local_p (struct elf_link_hash_entry *h,
bed = get_elf_backend_data (hash_table->dynobj);
- /* STV_PROTECTED non-function symbols are local. */
- if (!bed->is_function_type (h->type))
+ /* If extern_protected_data is false, STV_PROTECTED non-function
+ symbols are local. */
+ if (!bed->extern_protected_data && !bed->is_function_type (h->type))
return TRUE;
/* Function pointer equality tests may require that STV_PROTECTED