i386: Force symbol dynamic if it isn't undefined weak
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 24 Apr 2017 20:42:33 +0000 (13:42 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 24 Apr 2017 20:42:33 +0000 (13:42 -0700)
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.

bfd/ChangeLog
bfd/elf32-i386.c

index 6b969d63706967846f960547fb702ab17a57babf..54e2f0dbb97feac0cda97a86fec675e3e7897914 100644 (file)
@@ -1,3 +1,12 @@
+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
index 83f3b11e659e867dc5ce7285c04e1cbabe62666d..9a568ce522b7362d6f61d1f447da2f0c554ad72d 100644 (file)
@@ -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;
                        }
This page took 0.046085 seconds and 4 git commands to generate.