Hide ppc64 .TOC. from --export-dynamic
authorAlan Modra <amodra@gmail.com>
Tue, 5 Nov 2013 02:08:51 +0000 (12:38 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 5 Nov 2013 02:14:54 +0000 (12:44 +1030)
I can't see any good reason why anyone would want a dynamic .TOC., so
hide it in a way that is respected by _bfd_elf_export_symbol.  This
also fixes an abort in relocate_section on not finding sreloc for .TOC.

* elf64-ppc.c (ppc64_elf_func_desc_adjust): Make .TOC. defined and
hidden.
(ppc64_elf_set_toc): Adjust.

bfd/ChangeLog
bfd/elf64-ppc.c

index d6b9989f048785fc9e3ffc1efbcc4d3435c35b87..ac78036cbc37a3ef9a5624f63fd6e6b152848765 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-05  Alan Modra  <amodra@gmail.com>
+
+       * elf64-ppc.c (ppc64_elf_func_desc_adjust): Make .TOC. defined and
+       hidden.
+       (ppc64_elf_set_toc): Adjust.
+
 2013-11-05  Alan Modra  <amodra@gmail.com>
 
        * elf64-ppc.c (struct ppc_link_hash_table): Remove got, plt, relplt,
index adc285f48762d86a5517eb7a5c8fb1168e5fece7..136887f25e2d7de673450f44a0ae3d065dd77d19 100644 (file)
@@ -6837,7 +6837,18 @@ ppc64_elf_func_desc_adjust (bfd *obfd ATTRIBUTE_UNUSED,
 
   if (!info->relocatable
       && htab->elf.hgot != NULL)
-    _bfd_elf_link_hash_hide_symbol (info, htab->elf.hgot, TRUE);
+    {
+      _bfd_elf_link_hash_hide_symbol (info, htab->elf.hgot, TRUE);
+      /* Make .TOC. defined so as to prevent it being made dynamic.
+        The wrong value here is fixed later in ppc64_elf_set_toc.  */
+      htab->elf.hgot->type = STT_OBJECT;
+      htab->elf.hgot->root.type = bfd_link_hash_defined;
+      htab->elf.hgot->root.u.def.value = 0;
+      htab->elf.hgot->root.u.def.section = bfd_abs_section_ptr;
+      htab->elf.hgot->def_regular = 1;
+      htab->elf.hgot->other = ((htab->elf.hgot->other & ~ELF_ST_VISIBILITY (-1))
+                              | STV_HIDDEN);
+    }
 
   if (htab->sfpr == NULL)
     /* We don't have any relocs.  */
@@ -12329,8 +12340,6 @@ ppc64_elf_set_toc (struct bfd_link_info *info, bfd *obfd)
       if (htab != NULL
          && htab->elf.hgot != NULL)
        {
-         htab->elf.hgot->type = STT_OBJECT;
-         htab->elf.hgot->root.type = bfd_link_hash_defined;
          htab->elf.hgot->root.u.def.value = TOC_BASE_OFF;
          htab->elf.hgot->root.u.def.section = s;
        }
This page took 0.032107 seconds and 4 git commands to generate.