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.
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
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
{{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 \
--- /dev/null
+__attribute__ ((visibility ("protected")))
+void
+foo (void)
+{
+}
--- /dev/null
+extern void foo (void);
+
+void (*foo_p) (void);
+
+int
+main ()
+{
+ foo_p = foo;
+ return 0;
+}