]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use dynamic text relocs for protected vars
authorAlan Modra <amodra@gmail.com>
Mon, 23 Feb 2015 06:15:05 +0000 (16:45 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 18 Mar 2015 07:21:31 +0000 (17:51 +1030)
Rather than reporting a link error on attempting to use dynbss for
protected vars, use dynamic text relocs.

* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Heed -z nocopyreloc.
Use text relocs rather than giving an error on trying to use
.dynbss for protected shared lib vars.
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.

bfd/ChangeLog
bfd/elf32-ppc.c
bfd/elf64-ppc.c

index d12d9669187938689d853800613591a7b161483c..78fe403024c182518960f50f7ffceb4d36944189 100644 (file)
@@ -1,3 +1,12 @@
+2015-03-18  Alan Modra  <amodra@gmail.com>
+
+       Apply from master
+       2015-02-26  Alan Modra  <amodra@gmail.com>
+       * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Heed -z nocopyreloc.
+       Use text relocs rather than giving an error on trying to use
+       .dynbss for protected shared lib vars.
+       * elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
+
 2015-03-06  H.J. Lu  <hongjiu.lu@intel.com>
 
        Backport from master
index 83f8452d2a104d7cdd8bf9a757847a21bc4d6e17..3325406fc4e971be858955c1b1d02a799b201516 100644 (file)
@@ -5576,6 +5576,13 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
   if (!h->non_got_ref)
     return TRUE;
 
+  /* If -z nocopyreloc was given, we won't generate them either.  */
+  if (info->nocopyreloc)
+    {
+      h->non_got_ref = 0;
+      return TRUE;
+    }
+
    /* 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.
       We can't do this if there are any small data relocations.  This
@@ -5592,6 +5599,16 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
       return TRUE;
     }
 
+  /* Protected variables do not work with .dynbss.  The copy in
+     .dynbss won't be used by the shared library with the protected
+     definition for the variable.  Text relocations are preferable
+     to an incorrect program.  */
+  if (h->protected_def)
+    {
+      h->non_got_ref = 0;
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
index 3b64f9a16dbdd6d5066ec9d95f43c3903e635f62..3026b4686ac436c563b7753cc5b0c8a6793b6e03 100644 (file)
@@ -7075,6 +7075,13 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
   if (!h->def_dynamic || !h->ref_regular || h->def_regular)
     return TRUE;
 
+  /* If -z nocopyreloc was given, don't generate them either.  */
+  if (info->nocopyreloc)
+    {
+      h->non_got_ref = 0;
+      return TRUE;
+    }
+
   /* 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))
@@ -7083,6 +7090,16 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
       return TRUE;
     }
 
+  /* Protected variables do not work with .dynbss.  The copy in
+     .dynbss won't be used by the shared library with the protected
+     definition for the variable.  Text relocations are preferable
+     to an incorrect program.  */
+  if (h->protected_def)
+    {
+      h->non_got_ref = 0;
+      return TRUE;
+    }
+
   if (h->plt.plist != NULL)
     {
       /* We should never get here, but unfortunately there are versions