public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Hide ppc64 .TOC. from --export-dynamic
@ 2013-11-05  2:17 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2013-11-05  2:17 UTC (permalink / raw)
  To: binutils

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.

diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index adc285f..136887f 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -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;
 	}

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-11-05  2:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-05  2:17 Hide ppc64 .TOC. from --export-dynamic Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).