aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2022-07-18 11:44:32 -0700
committerH.J. Lu <hjl.tools@gmail.com>2022-07-18 18:15:39 -0700
commitbd0736124c20950ac353f01e5029b7cb5d8a7010 (patch)
tree200402b32a575d787d29576478a29bfbcb055dcb /bfd
parentb87062aade785dbac35dace7b137f5f038ace895 (diff)
downloadgdb-bd0736124c20950ac353f01e5029b7cb5d8a7010.zip
gdb-bd0736124c20950ac353f01e5029b7cb5d8a7010.tar.gz
gdb-bd0736124c20950ac353f01e5029b7cb5d8a7010.tar.bz2
x86: Properly check invalid relocation against protected symbol
Only check invalid relocation against protected symbol defined in shared object. bfd/ PR ld/29377 * elf32-i386.c (elf_i386_scan_relocs): Only check invalid relocation against protected symbol defined in shared object. * elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise. ld/ PR ld/29377 * testsuite/ld-elf/linux-x86.exp: Run PR ld/29377 tests. * testsuite/ld-elf/pr29377a.c: New file. * testsuite/ld-elf/pr29377b.c: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/elf32-i386.c2
-rw-r--r--bfd/elf64-x86-64.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index e4106d9..3d39dc0 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1811,6 +1811,8 @@ elf_i386_scan_relocs (bfd *abfd,
if (h->pointer_equality_needed
&& h->type == STT_FUNC
&& eh->def_protected
+ && !SYMBOL_DEFINED_NON_SHARED_P (h)
+ && h->def_dynamic
&& elf_has_indirect_extern_access (h->root.u.def.section->owner))
{
/* Disallow non-canonical reference to canonical
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 6154a70..48ca630 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2254,6 +2254,8 @@ elf_x86_64_scan_relocs (bfd *abfd, struct bfd_link_info *info,
if (h->pointer_equality_needed
&& h->type == STT_FUNC
&& eh->def_protected
+ && !SYMBOL_DEFINED_NON_SHARED_P (h)
+ && h->def_dynamic
&& elf_has_indirect_extern_access (h->root.u.def.section->owner))
{
/* Disallow non-canonical reference to canonical