aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-x86.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2019-02-05 18:45:23 -0800
committerH.J. Lu <hjl.tools@gmail.com>2019-02-05 18:45:34 -0800
commit83924b3846361f2f76f9a6e7b5afa01c0eebbd4f (patch)
tree46f38366ea637c07bb5e61b3afdc8dc83f8458be /bfd/elfxx-x86.h
parent4e9ac437aaebb55624b54fc3d1cfb52acfe320dd (diff)
downloadgdb-83924b3846361f2f76f9a6e7b5afa01c0eebbd4f.zip
gdb-83924b3846361f2f76f9a6e7b5afa01c0eebbd4f.tar.gz
gdb-83924b3846361f2f76f9a6e7b5afa01c0eebbd4f.tar.bz2
x86-64: Restore PIC check for PCREL reloc against protected symbol
commit bd7ab16b4537788ad53521c45469a1bdae84ad4a Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Feb 13 07:34:22 2018 -0800 x86-64: Generate branch with PLT32 relocation removed check R_X86_64_PC32 relocation against protected symbols in shared objects. Since elf_x86_64_check_relocs is called after we have seen all input files, we can check for PC-relative relocations in elf_x86_64_check_relocs. We should not allow PC-relative relocations against protected symbols since address of protected function and location of protected data may not be in the shared object. bfd/ PR ld/24151 * elf64-x86-64.c (elf_x86_64_need_pic): Check SYMBOL_DEFINED_NON_SHARED_P instead of def_regular. (elf_x86_64_relocate_section): Move PIC check for PC-relative relocations to ... (elf_x86_64_check_relocs): Here. (elf_x86_64_finish_dynamic_symbol): Use SYMBOL_DEFINED_NON_SHARED_P to check if a symbol is defined in a non-shared object. * elfxx-x86.h (SYMBOL_DEFINED_NON_SHARED_P): New. ld/ PR ld/24151 * testsuite/ld-x86-64/pr24151a-x32.d: New file. * testsuite/ld-x86-64/pr24151a.d: Likewise. * testsuite/ld-x86-64/pr24151a.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr24151a and pr24151a-x32.
Diffstat (limited to 'bfd/elfxx-x86.h')
-rw-r--r--bfd/elfxx-x86.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index dce24dc..28d540b 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -161,6 +161,13 @@
|| (ELF_ST_VISIBILITY ((H)->other) \
&& (H)->root.type == bfd_link_hash_undefweak))
+/* TRUE if this symbol isn't defined by a shared object. */
+#define SYMBOL_DEFINED_NON_SHARED_P(H) \
+ ((H)->def_regular \
+ || (H)->root.linker_def \
+ || (H)->root.ldscript_def \
+ || ELF_COMMON_DEF_P (H))
+
/* TRUE if relative relocation should be generated. GOT reference to
global symbol in PIC will lead to dynamic symbol. It becomes a
problem when "time" or "times" is defined as a variable in an