diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-04-10 14:02:23 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-04-10 14:02:23 -0700 |
commit | 3d9499950a94df8577fa01ba98ec0d58f07fd9c0 (patch) | |
tree | 4ec8ffff58a0fa7867665e53f261b04d9cc4d9c0 /bfd/elf32-i386.c | |
parent | 9ee417720b2f25c56a9738569b63f686cbc8584f (diff) | |
download | gdb-3d9499950a94df8577fa01ba98ec0d58f07fd9c0.zip gdb-3d9499950a94df8577fa01ba98ec0d58f07fd9c0.tar.gz gdb-3d9499950a94df8577fa01ba98ec0d58f07fd9c0.tar.bz2 |
Check GOTOFF reloc against protected data on x86
R_386_GOTOFF/R_X86_64_GOTOFF64 relocation shouldn't be used against
protected data symbol on x86 since with copy relocation, address of
protected data defined in the shared library may be external.
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.
bfd/
PR ld/pr17709
* elf32-i386.c (elf_i386_relocate_section): Also check R_386_GOTOFF
against protected data symbol when building shared library.
* elf64-x86-64.c (elf_x86_64_relocate_section): Also check
R_X86_64_GOTOFF64 against protected data symbol when building
shared library.
ld/testsuite/
PR ld/pr17709
* ld-i386/protected6.d: New file.
* ld-i386/protected6.s: Likewise.
* ld-x86-64/protected6.d: Likewise.
* ld-x86-64/protected6.s: Likewise.
* ld-x86-64/protected7.d: Likewise.
* ld-x86-64/protected7.s: Likewise.
* ld-x86-64/protected7a.d: Likewise.
* ld-x86-64/protected7b.d: Likewise.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r-- | bfd/elf32-i386.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 52f4d33..af16da3 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -3714,10 +3714,10 @@ elf_i386_relocate_section (bfd *output_bfd, /* Relocation is relative to the start of the global offset table. */ - /* Check to make sure it isn't a protected function symbol - for shared library since it may not be local when used - as function address. We also need to make sure that a - symbol is defined locally. */ + /* Check to make sure it isn't a protected function or data + symbol for shared library since it may not be local when + used as function address or with copy relocation. We also + need to make sure that a symbol is defined locally. */ if (info->shared && h) { if (!h->def_regular) @@ -3748,12 +3748,15 @@ elf_i386_relocate_section (bfd *output_bfd, } else if (!info->executable && !SYMBOLIC_BIND (info, h) - && h->type == STT_FUNC + && (h->type == STT_FUNC + || h->type == STT_OBJECT) && ELF_ST_VISIBILITY (h->other) == STV_PROTECTED) { (*_bfd_error_handler) - (_("%B: relocation R_386_GOTOFF against protected function `%s' can not be used when making a shared object"), - input_bfd, h->root.root.string); + (_("%B: relocation R_386_GOTOFF against protected %s `%s' can not be used when making a shared object"), + input_bfd, + h->type == STT_FUNC ? "function" : "data", + h->root.root.string); bfd_set_error (bfd_error_bad_value); return FALSE; } |