diff options
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/elf32-i386.c | 3 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 10 | ||||
-rw-r--r-- | bfd/elfxx-x86.c | 21 | ||||
-rw-r--r-- | bfd/elfxx-x86.h | 3 |
4 files changed, 24 insertions, 13 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 04a972e..cfb0085 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1812,8 +1812,7 @@ elf_i386_scan_relocs (bfd *abfd, && 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. */ diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 3abc68a..62a9a22 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -2255,8 +2255,7 @@ elf_x86_64_scan_relocs (bfd *abfd, struct bfd_link_info *info, && 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. */ @@ -3156,8 +3155,7 @@ elf_x86_64_relocate_section (bfd *output_bfd, || (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 @@ -4097,9 +4095,7 @@ elf_x86_64_relocate_section (bfd *output_bfd, { 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); diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index 18f3d33..7fb9727 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -524,8 +524,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) { 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. */ @@ -3041,6 +3040,24 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info, } 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; } diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h index 77fb1ad..7d23893 100644 --- a/bfd/elfxx-x86.h +++ b/bfd/elfxx-x86.h @@ -135,12 +135,11 @@ /* 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) |