diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2022-07-18 11:44:32 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2022-07-18 18:15:39 -0700 |
commit | bd0736124c20950ac353f01e5029b7cb5d8a7010 (patch) | |
tree | 200402b32a575d787d29576478a29bfbcb055dcb /ld/testsuite/ld-elf | |
parent | b87062aade785dbac35dace7b137f5f038ace895 (diff) | |
download | binutils-bd0736124c20950ac353f01e5029b7cb5d8a7010.zip binutils-bd0736124c20950ac353f01e5029b7cb5d8a7010.tar.gz binutils-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 'ld/testsuite/ld-elf')
-rw-r--r-- | ld/testsuite/ld-elf/linux-x86.exp | 16 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr29377a.c | 5 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr29377b.c | 10 |
3 files changed, 31 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp index 6035ecd..0f0a6f0 100644 --- a/ld/testsuite/ld-elf/linux-x86.exp +++ b/ld/testsuite/ld-elf/linux-x86.exp @@ -134,6 +134,22 @@ run_cc_link_tests [list \ {{readelf {--dyn-syms -W} pr28158.rd} {nm -D pr28158.nd}} \ "pr28158" \ ] \ + [list \ + "Build pr29377.o" \ + "-r -Wl,-z,noexecstack" \ + "" \ + {pr29377a.c indirect-extern-access.S} \ + {} \ + "pr29377.o" \ + ] \ + [list \ + "Build pr29377" \ + "$NOPIE_LDFLAGS tmpdir/pr29377.o" \ + "-fPIC" \ + {pr29377b.c} \ + {} \ + "pr29377" \ + ] \ ] run_ld_link_exec_tests [list \ diff --git a/ld/testsuite/ld-elf/pr29377a.c b/ld/testsuite/ld-elf/pr29377a.c new file mode 100644 index 0000000..41d9545 --- /dev/null +++ b/ld/testsuite/ld-elf/pr29377a.c @@ -0,0 +1,5 @@ +__attribute__ ((visibility ("protected"))) +void +foo (void) +{ +} diff --git a/ld/testsuite/ld-elf/pr29377b.c b/ld/testsuite/ld-elf/pr29377b.c new file mode 100644 index 0000000..3cf163b --- /dev/null +++ b/ld/testsuite/ld-elf/pr29377b.c @@ -0,0 +1,10 @@ +extern void foo (void); + +void (*foo_p) (void); + +int +main () +{ + foo_p = foo; + return 0; +} |