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] i386: Force symbol dynamic if it isn't undefined weak


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

commit 0dc9a308a1ec9675bf6b33bae9e8b1faa0bad9ed
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Apr 24 13:42:33 2017 -0700

    i386: Force symbol dynamic if it isn't undefined weak
    
    Force symbol dynamic if it isn't undefined weak.  Generate R_386_RELATIVE
    relocation for R_386_GOT32 relocation against non-dynamic symbol in PIC.
    
    	PR ld/21402
    	* elf32-i386.c (elf_i386_allocate_dynrelocs): If a symbol isn't
    	undefined weak symbol, don't make it dynamic.
    	(elf_i386_relocate_section): If a symbol isn't dynamic in PIC,
    	set no_finish_dynamic_symbol and generate R_386_RELATIVE
    	relocation for R_386_GOT32.

Diff:
---
 bfd/ChangeLog    |  9 +++++++++
 bfd/elf32-i386.c | 17 ++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 6b969d6..54e2f0d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,14 @@
 2017-04-24  H.J. Lu  <hongjiu.lu@intel.com>
 
+	PR ld/21402
+	* elf32-i386.c (elf_i386_allocate_dynrelocs): If a symbol isn't
+	undefined weak symbol, don't make it dynamic.
+	(elf_i386_relocate_section): If a symbol isn't dynamic in PIC,
+	set no_finish_dynamic_symbol and generate R_386_RELATIVE
+	relocation for R_386_GOT32.
+
+2017-04-24  H.J. Lu  <hongjiu.lu@intel.com>
+
 	PR ld/21425
 	* elf32-i386.c (ELF_MAXPAGESIZE): Set to 0x1000 for VxWorks.
 
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 83f3b11..9a568ce 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2748,7 +2748,8 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 	 Undefined weak syms won't yet be marked as dynamic.  */
       if (h->dynindx == -1
 	  && !h->forced_local
-	  && !resolved_to_zero)
+	  && !resolved_to_zero
+	  && h->root.type == bfd_link_hash_undefweak)
 	{
 	  if (! bfd_elf_link_record_dynamic_symbol (info, h))
 	    return FALSE;
@@ -2867,14 +2868,11 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       int tls_type = elf_i386_hash_entry(h)->tls_type;
 
       /* Make sure this symbol is output as a dynamic symbol.
-	 Undefined weak syms won't yet be marked as dynamic.
-	 PR ld/21402: If this symbol isn't undefined weak symbol,
-	 don't make it dynamic in PIE.   */
+	 Undefined weak syms won't yet be marked as dynamic.  */
       if (h->dynindx == -1
 	  && !h->forced_local
 	  && !resolved_to_zero
-	  && (h->root.type == bfd_link_hash_undefweak
-	      || !bfd_link_pie (info)))
+	  && h->root.type == bfd_link_hash_undefweak)
 	{
 	  if (! bfd_elf_link_record_dynamic_symbol (info, h))
 	    return FALSE;
@@ -3035,7 +3033,8 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 	     Undefined weak syms won't yet be marked as dynamic.  */
 	  if (h->dynindx == -1
 	      && !h->forced_local
-	      && !resolved_to_zero)
+	      && !resolved_to_zero
+	      && h->root.type == bfd_link_hash_undefweak)
 	    {
 	      if (! bfd_elf_link_record_dynamic_symbol (info, h))
 		return FALSE;
@@ -4315,10 +4314,10 @@ r_386_got32:
 		      if (h->dynindx == -1
 			  && !h->forced_local
 			  && h->root.type != bfd_link_hash_undefweak
-			  && bfd_link_pie (info))
+			  && bfd_link_pic (info))
 			{
 			  /* PR ld/21402: If this symbol isn't dynamic
-			     in PIE, generate R_386_RELATIVE here.  */
+			     in PIC, generate R_386_RELATIVE here.  */
 			  eh->no_finish_dynamic_symbol = 1;
 			  relative_reloc = TRUE;
 			}


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