&& 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))
+ && h->def_dynamic)
{
/* Disallow non-canonical reference to canonical
protected function. */
&& 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))
+ && h->def_dynamic)
{
/* Disallow non-canonical reference to canonical
protected function. */
|| (h != NULL
&& !h->root.linker_def
&& !h->root.ldscript_def
- && eh->def_protected
- && elf_has_no_copy_on_protected (h->root.u.def.section->owner)));
+ && eh->def_protected));
if ((input_section->flags & SEC_ALLOC) != 0
&& (input_section->flags & SEC_READONLY) != 0
{
case R_X86_64_32S:
sec = h->root.u.def.section;
- if ((info->nocopyreloc
- || (eh->def_protected
- && elf_has_no_copy_on_protected (h->root.u.def.section->owner)))
+ if ((info->nocopyreloc || eh->def_protected)
&& !(h->root.u.def.section->flags & SEC_CODE))
return elf_x86_64_need_pic (info, input_bfd, input_section,
h, NULL, NULL, howto);
{
asection *sreloc;
- if (eh->def_protected
- && elf_has_no_copy_on_protected (h->root.u.def.section->owner))
+ if (eh->def_protected && bfd_link_executable (info))
{
/* Disallow copy relocation against non-copyable protected
symbol. */
}
if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
{
+ if (eh->def_protected && bfd_link_executable (info))
+ for (p = h->dyn_relocs; p != NULL; p = p->next)
+ {
+ /* Disallow copy relocation against non-copyable protected
+ symbol. */
+ s = p->sec->output_section;
+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
+ {
+ info->callbacks->einfo
+ /* xgettext:c-format */
+ (_("%F%P: %pB: copy relocation against non-copyable "
+ "protected symbol `%s' in %pB\n"),
+ p->sec->owner, h->root.root.string,
+ h->root.u.def.section->owner);
+ return false;
+ }
+ }
+
srel->size += htab->sizeof_reloc;
h->needs_copy = 1;
}
/* Should copy relocation be generated for a symbol. Don't generate
copy relocation against a protected symbol defined in a shared
- object with GNU_PROPERTY_NO_COPY_ON_PROTECTED. */
+ object. */
#define SYMBOL_NO_COPYRELOC(INFO, EH) \
((EH)->def_protected \
&& ((EH)->elf.root.type == bfd_link_hash_defined \
|| (EH)->elf.root.type == bfd_link_hash_defweak) \
- && elf_has_no_copy_on_protected ((EH)->elf.root.u.def.section->owner) \
&& ((EH)->elf.root.u.def.section->owner->flags & DYNAMIC) != 0 \
&& ((EH)->elf.root.u.def.section->flags & SEC_CODE) == 0)
"--32 -mx86-used-note=yes" {pr17709a.s} {} "libpr17709.so"}
{"PR ld/17709 (2)" "-melf_i386 tmpdir/libpr17709.so" ""
"--32 -mx86-used-note=yes"
- {pr17709b.s} {{readelf -r pr17709.rd}} "pr17709"}
+ {pr17709b.s} {{ld "pr17709.err"}} "pr17709"}
{"Build pr19827a.o" "" ""
"--32 -mx86-used-note=yes" { pr19827a.S }}
{"Build pr19827b.so" "-melf_i386 -shared" ""
--- /dev/null
+.*: tmpdir/pr17709b.o: copy relocation against non-copyable protected symbol `foo' in tmpdir/libpr17709.so
+#...
+++ /dev/null
-
-Relocation section '.rel\..*' at offset .* contains 1 entry:
- Offset Info Type Sym\.Value Sym\. Name
-[0-9a-f ]+R_386_COPY +[0-9a-f]+ +foo
--- /dev/null
+.*: tmpdir/pr17709b.o: copy relocation against non-copyable protected symbol `foo' in tmpdir/libpr17709.so
+#...
+++ /dev/null
-
-Relocation section '.rela\..*' at offset .* contains 1 entry:
- +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
-[0-9a-f ]+R_X86_64_COPY+[0-9a-f ]+ +foo \+ 0
-.*: tmpdir/protected-func-1b.o: non-canonical reference to canonical protected function `protected_func_1a' in tmpdir/libprotected-func-2b.so
+.*: tmpdir/protected-func-1b.o: non-canonical reference to canonical protected function `protected_func_1a' in tmpdir/libprotected-func-2..so
#...
{"PR ld/17709 (1)" "-melf_x86_64 -shared" ""
"--64" {pr17709a.s} {} "libpr17709.so"}
{"PR ld/17709 (2)" "-melf_x86_64 tmpdir/libpr17709.so" ""
- "--64" {pr17709b.s} {{readelf -rW pr17709.rd}} "pr17709"}
+ "--64" {pr17709b.s} {{ld "pr17709.err"}} "pr17709"}
{"Build pr19827a.o" "" ""
"--64" { pr19827a.S }}
{"Build pr19827b.so" "-melf_x86_64 -shared" ""
{{error_output "pr28875-func.err"}} \
"protected-func-2" \
] \
+ [list \
+ "Build libprotected-func-2c.so" \
+ "-shared" \
+ "-fPIC -Wa,-mx86-used-note=yes" \
+ { protected-func-2c.c } \
+ {} \
+ "libprotected-func-2c.so" \
+ ] \
+ [list \
+ "Build protected-func-2a without PIE" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-func-2c.so" \
+ "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
+ { protected-func-1b.c } \
+ {{error_output "pr28875-func.err"}} \
+ "protected-func-2a" \
+ ] \
[list \
"Build libprotected-data-1a.so" \
"-shared -z noindirect-extern-access" \