Module Name:    src
Committed By:   christos
Date:           Thu Nov  3 01:22:59 UTC 2016

Modified Files:
        src/external/gpl3/binutils/dist/bfd: elf32-ppc.c elf64-ppc.c

Log Message:
More detailed error messages for text relocations on ppc code. Tested by joerg@


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/gpl3/binutils/dist/bfd/elf32-ppc.c \
    src/external/gpl3/binutils/dist/bfd/elf64-ppc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/binutils/dist/bfd/elf32-ppc.c
diff -u src/external/gpl3/binutils/dist/bfd/elf32-ppc.c:1.9 src/external/gpl3/binutils/dist/bfd/elf32-ppc.c:1.10
--- src/external/gpl3/binutils/dist/bfd/elf32-ppc.c:1.9	Wed Oct 26 14:42:52 2016
+++ src/external/gpl3/binutils/dist/bfd/elf32-ppc.c	Wed Nov  2 21:22:59 2016
@@ -5557,7 +5557,7 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUT
 /* 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;
 
@@ -5568,7 +5568,16 @@ readonly_dynrelocs (struct elf_link_hash
       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;
 }
@@ -5642,7 +5651,7 @@ ppc_elf_adjust_dynamic_symbol (struct bf
 	      && 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;
@@ -5662,7 +5671,7 @@ ppc_elf_adjust_dynamic_symbol (struct bf
 		   && 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;
@@ -5739,7 +5748,7 @@ ppc_elf_adjust_dynamic_symbol (struct bf
       && !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;
@@ -6249,7 +6258,7 @@ maybe_set_textrel (struct elf_link_hash_
   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;
 
Index: src/external/gpl3/binutils/dist/bfd/elf64-ppc.c
diff -u src/external/gpl3/binutils/dist/bfd/elf64-ppc.c:1.9 src/external/gpl3/binutils/dist/bfd/elf64-ppc.c:1.10
--- src/external/gpl3/binutils/dist/bfd/elf64-ppc.c:1.9	Wed Oct 26 14:42:52 2016
+++ src/external/gpl3/binutils/dist/bfd/elf64-ppc.c	Wed Nov  2 21:22:59 2016
@@ -7105,7 +7105,7 @@ ppc64_elf_func_desc_adjust (bfd *obfd AT
 /* 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;
@@ -7116,7 +7116,16 @@ readonly_dynrelocs (struct elf_link_hash
       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;
 }
@@ -7168,7 +7177,7 @@ ppc64_elf_adjust_dynamic_symbol (struct 
 	     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;
@@ -7186,7 +7195,7 @@ ppc64_elf_adjust_dynamic_symbol (struct 
 	  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.  */
@@ -7235,7 +7244,7 @@ ppc64_elf_adjust_dynamic_symbol (struct 
 
   /* 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;
@@ -9844,7 +9853,7 @@ maybe_set_textrel (struct elf_link_hash_
   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;
 

Reply via email to