From c4414c4118425eeb443af336b7eb94a6082fb28b Mon Sep 17 00:00:00 2001 From: joerg Date: Sun, 6 Nov 2016 23:46:01 +0000 Subject: [PATCH] Merge r1.10 from the main in-tree binutils version: More detailed error messages for text relocations on ppc code. Tested by joerg@ --- .../gpl3/binutils.old/dist/bfd/elf32-ppc.c | 21 +++++++++++++------ .../gpl3/binutils.old/dist/bfd/elf64-ppc.c | 21 +++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/external/gpl3/binutils.old/dist/bfd/elf32-ppc.c b/external/gpl3/binutils.old/dist/bfd/elf32-ppc.c index 1d269e097dad..80d0c1f16fa5 100644 --- a/external/gpl3/binutils.old/dist/bfd/elf32-ppc.c +++ b/external/gpl3/binutils.old/dist/bfd/elf32-ppc.c @@ -5483,7 +5483,7 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUTE_UNUSED, /* Return true if we have dynamic relocs that apply to read-only sections. */ static bfd_boolean -readonly_dynrelocs (struct elf_link_hash_entry *h) +readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf, bfd_boolean warn) { struct elf_dyn_relocs *p; @@ -5494,7 +5494,16 @@ readonly_dynrelocs (struct elf_link_hash_entry *h) if (s != NULL && ((s->flags & (SEC_READONLY | SEC_ALLOC)) == (SEC_READONLY | SEC_ALLOC))) - return TRUE; + { + struct bfd_link_info *info = (struct bfd_link_info *) inf; + + if (warn && ((info->warn_shared_textrel && bfd_link_pic (info)) + || info->error_textrel)) + info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'\n"), + p->sec->owner, h->root.root.string, + p->sec); + return TRUE; + } } return FALSE; } @@ -5568,7 +5577,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, && h->type != STT_GNU_IFUNC && !htab->is_vxworks && !ppc_elf_hash_entry (h)->has_sda_refs - && !readonly_dynrelocs (h)) + && !readonly_dynrelocs (h, info, FALSE)) { h->pointer_equality_needed = 0; h->non_got_ref = 0; @@ -5588,7 +5597,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, && h->type != STT_GNU_IFUNC && !htab->is_vxworks && !ppc_elf_hash_entry (h)->has_sda_refs - && !readonly_dynrelocs (h)) + && !readonly_dynrelocs (h, info, FALSE)) h->non_got_ref = 0; } h->protected_def = 0; @@ -5665,7 +5674,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, && !ppc_elf_hash_entry (h)->has_sda_refs && !htab->is_vxworks && !h->def_regular - && !readonly_dynrelocs (h)) + && !readonly_dynrelocs (h, info, FALSE)) { h->non_got_ref = 0; return TRUE; @@ -6175,7 +6184,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info) if (h->root.type == bfd_link_hash_indirect) return TRUE; - if (readonly_dynrelocs (h)) + if (readonly_dynrelocs (h, info, TRUE)) { ((struct bfd_link_info *) info)->flags |= DF_TEXTREL; diff --git a/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c b/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c index 2e90d23196df..46619b5a76bd 100644 --- a/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c +++ b/external/gpl3/binutils.old/dist/bfd/elf64-ppc.c @@ -7103,7 +7103,7 @@ ppc64_elf_func_desc_adjust (bfd *obfd ATTRIBUTE_UNUSED, /* Return true if we have dynamic relocs that apply to read-only sections. */ static bfd_boolean -readonly_dynrelocs (struct elf_link_hash_entry *h) +readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf, bfd_boolean warn) { struct ppc_link_hash_entry *eh; struct elf_dyn_relocs *p; @@ -7114,7 +7114,16 @@ readonly_dynrelocs (struct elf_link_hash_entry *h) asection *s = p->sec->output_section; if (s != NULL && (s->flags & SEC_READONLY) != 0) - return TRUE; + { + struct bfd_link_info *info = (struct bfd_link_info *) inf; + + if (warn && ((info->warn_shared_textrel && bfd_link_pic (info)) + || info->error_textrel)) + info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'\n"), + p->sec->owner, h->root.root.string, + p->sec); + return TRUE; + } } return FALSE; } @@ -7166,7 +7175,7 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info, be used instead. */ if (h->pointer_equality_needed && h->type != STT_GNU_IFUNC - && !readonly_dynrelocs (h)) + && !readonly_dynrelocs (h, info, FALSE)) { h->pointer_equality_needed = 0; h->non_got_ref = 0; @@ -7184,7 +7193,7 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info, else if (!h->ref_regular_nonweak && h->non_got_ref && h->type != STT_GNU_IFUNC - && !readonly_dynrelocs (h)) + && !readonly_dynrelocs (h, info, FALSE)) h->non_got_ref = 0; /* If making a plt entry, then we don't need copy relocs. */ @@ -7233,7 +7242,7 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we didn't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (ELIMINATE_COPY_RELOCS && !readonly_dynrelocs (h)) + if (ELIMINATE_COPY_RELOCS && !readonly_dynrelocs (h, info, FALSE)) { h->non_got_ref = 0; return TRUE; @@ -9841,7 +9850,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info) if (h->root.type == bfd_link_hash_indirect) return TRUE; - if (readonly_dynrelocs (h)) + if (readonly_dynrelocs (h, info, TRUE)) { ((struct bfd_link_info *) info)->flags |= DF_TEXTREL;