This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] arm: Check UNDEFWEAK_NO_DYNAMIC_RELOC


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=95b03e4ad68e7a90f5096b47df595636344b783a

commit 95b03e4ad68e7a90f5096b47df595636344b783a
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Oct 14 10:27:33 2017 -0700

    arm: Check UNDEFWEAK_NO_DYNAMIC_RELOC
    
    Don't generate dynamic relocation against weak undefined symbol if it
    is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
    checked in more places.
    
    	PR ld/22269
    	* elf32-arm.c (elf32_arm_final_link_relocate): Don't generate
    	dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
    	(allocate_dynrelocs_for_symbol): Discard dynamic relocations
    	if UNDEFWEAK_NO_DYNAMIC_RELOC is true.

Diff:
---
 bfd/ChangeLog   |  8 ++++++++
 bfd/elf32-arm.c | 13 ++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 0dc2f44a..849ce20 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,6 +1,14 @@
 2017-10-14  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR ld/22269
+	* elf32-arm.c (elf32_arm_final_link_relocate): Don't generate
+	dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
+	(allocate_dynrelocs_for_symbol): Discard dynamic relocations
+	if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
+
+2017-10-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR ld/22269
 	* elf32-tilepro.c (allocate_dynrelocs): Discard dynamic
 	relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
 	(tilepro_elf_relocate_section): Don't generate dynamic
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 34b9e0c..1e78c7a 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -9900,6 +9900,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
   bfd_vma                       plt_offset;
   bfd_vma                       gotplt_offset;
   bfd_boolean                   has_iplt_entry;
+  bfd_boolean                   resolved_to_zero;
 
   globals = elf32_arm_hash_table (info);
   if (globals == NULL)
@@ -10017,6 +10018,9 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
       gotplt_offset = (bfd_vma) -1;
     }
 
+  resolved_to_zero = (h != NULL
+		      && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
+
   switch (r_type)
     {
     case R_ARM_NONE:
@@ -10081,7 +10085,8 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
 	  && !(input_bfd == globals->stub_bfd
 	       && strstr (input_section->name, STUB_SUFFIX))
 	  && (h == NULL
-	      || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+	      || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+		  && !resolved_to_zero)
 	      || h->root.type != bfd_link_hash_undefweak)
 	  && r_type != R_ARM_PC24
 	  && r_type != R_ARM_CALL
@@ -11284,7 +11289,8 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
 
 	    if ((bfd_link_pic (info) || indx != 0)
 		&& (h == NULL
-		    || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+		    || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+			&& !resolved_to_zero)
 		    || h->root.type != bfd_link_hash_undefweak))
 	      {
 		need_relocs = TRUE;
@@ -15716,7 +15722,8 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf)
       if (eh->dyn_relocs != NULL
 	  && h->root.type == bfd_link_hash_undefweak)
 	{
-	  if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+	  if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+	      || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
 	    eh->dyn_relocs = NULL;
 
 	  /* Make sure undefined weak symbols are output as a dynamic


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]