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] hppa: Check UNDEFWEAK_NO_DYNAMIC_RELOC


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

commit 60c1b909dfcc984f3aecb70032e90a34d71b44bc
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Oct 14 10:54:50 2017 -0700

    hppa: 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-hppa.c (ensure_undef_dynamic): Don't make undefined
    	symbol dynamic if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
    	(allocate_dynrelocs): Discard dynamic relocations if
    	UNDEFWEAK_NO_DYNAMIC_RELOC is true.
    	(elf32_hppa_relocate_section): Don't generate dynamic
    	relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.

Diff:
---
 bfd/ChangeLog    | 10 ++++++++++
 bfd/elf32-hppa.c | 11 +++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 3011aa2..34dde75 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,6 +1,16 @@
 2017-10-14  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR ld/22269
+	* elf32-hppa.c (ensure_undef_dynamic): Don't make undefined
+	symbol dynamic if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
+	(allocate_dynrelocs): Discard dynamic relocations if
+	UNDEFWEAK_NO_DYNAMIC_RELOC is true.
+	(elf32_hppa_relocate_section): Don't generate dynamic
+	relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
+
+2017-10-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR ld/22269
 	* elfnn-ia64.c (elfNN_ia64_check_relocs): Don't allocate
 	dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
 	(allocate_fptr): Don't allocate function pointer if
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 3adac6d..9a195be 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -1933,6 +1933,7 @@ ensure_undef_dynamic (struct bfd_link_info *info,
       && eh->dynindx == -1
       && !eh->forced_local
       && eh->type != STT_PARISC_MILLI
+      && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, eh)
       && ELF_ST_VISIBILITY (eh->other) == STV_DEFAULT)
     return bfd_elf_link_record_dynamic_symbol (info, eh);
   return TRUE;
@@ -2077,7 +2078,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
       /* Discard relocs on undefined syms with non-default visibility.  */
       if ((eh->root.type == bfd_link_hash_undefined
 	   || eh->root.type == bfd_link_hash_undefweak)
-	  && ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT)
+	  && (ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT
+	      || UNDEFWEAK_NO_DYNAMIC_RELOC (info, eh)))
 	hh->dyn_relocs = NULL;
 
 #if RELATIVE_DYNRELOCS
@@ -3672,6 +3674,7 @@ elf32_hppa_relocate_section (bfd *output_bfd,
       const char *sym_name;
       bfd_boolean plabel;
       bfd_boolean warned_undef;
+      bfd_boolean resolved_to_zero;
 
       r_type = ELF32_R_TYPE (rela->r_info);
       if (r_type >= (unsigned int) R_PARISC_UNIMPLEMENTED)
@@ -3735,6 +3738,9 @@ elf32_hppa_relocate_section (bfd *output_bfd,
       if (bfd_link_relocatable (info))
 	continue;
 
+      resolved_to_zero = (hh != NULL
+			  && UNDEFWEAK_NO_DYNAMIC_RELOC (info, &hh->eh));
+
       /* Do any required modifications to the relocation value, and
 	 determine what types of dynamic info we need to output, if
 	 any.  */
@@ -3965,7 +3971,8 @@ elf32_hppa_relocate_section (bfd *output_bfd,
 	     there all files have not been loaded.  */
 	  if ((bfd_link_pic (info)
 	       && (hh == NULL
-		   || ELF_ST_VISIBILITY (hh->eh.other) == STV_DEFAULT
+		   || (ELF_ST_VISIBILITY (hh->eh.other) == STV_DEFAULT
+		       && !resolved_to_zero)
 		   || hh->eh.root.type != bfd_link_hash_undefweak)
 	       && (IS_ABSOLUTE_RELOC (r_type)
 		   || !SYMBOL_CALLS_LOCAL (info, &hh->eh)))


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