[binutils-gdb] xlc -z relro toc section fixes

Alan Modra amodra@sourceware.org
Mon Feb 2 12:45:00 GMT 2015


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

commit 6c2573b7abfc3a504b902e46169cc521b6aa5eb7
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Feb 2 21:48:46 2015 +1030

    xlc -z relro toc section fixes
    
    Moving .toc out of .got caused us to lose toc sorting and multi-toc
    support.
    
    	* emultempl/ppc64elf.em (toc_section_name): New var.
    	(ppc_after_open): Set it.
    	(ppc_before_allocation): Use it.
    	(gld${EMULATION_NAME}_after_allocation): Here too.

Diff:
---
 ld/ChangeLog             |  7 +++++++
 ld/emultempl/ppc64elf.em | 10 ++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index c889769..472cf36 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2015-02-02  Alan Modra  <amodra@gmail.com>
+
+	* emultempl/ppc64elf.em (toc_section_name): New var.
+	(ppc_after_open): Set it.
+	(ppc_before_allocation): Use it.
+	(gld${EMULATION_NAME}_after_allocation): Here too.
+
 2015-01-29  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* ldfile.c (ldfile_try_open_bfd): Replace plugin_active_plugins_p()
diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em
index 5a784fd..fd9a3ce 100644
--- a/ld/emultempl/ppc64elf.em
+++ b/ld/emultempl/ppc64elf.em
@@ -62,6 +62,8 @@ static int no_toc_opt = 0;
 /* Whether to sort input toc and got sections.  */
 static int no_toc_sort = 0;
 
+/* Input .toc sections will be placed in this output section.  */
+static const char *toc_section_name = ".got";
 static asection *toc_section = 0;
 
 /* This is called before the input files are opened.  We create a new
@@ -124,6 +126,10 @@ ppc_after_open (void)
 		  else
 		    i = &(*i)->next;
 	      }
+	  /* Instead, .toc input sections will be mapped to the
+	     read/write .toc output section.  If user scripts don't
+	     provide one then we'll lose toc sorting and multi-toc.  */
+	  toc_section_name = ".toc";
 	}
     }
   gld${EMULATION_NAME}_after_open ();
@@ -301,7 +307,7 @@ ppc_before_allocation (void)
 	{
 	  lang_output_section_statement_type *toc_os;
 
-	  toc_os = lang_output_section_find (".got");
+	  toc_os = lang_output_section_find (toc_section_name);
 	  if (toc_os != NULL)
 	    sort_toc_sections (&toc_os->children, NULL, NULL);
 	}
@@ -504,7 +510,7 @@ gld${EMULATION_NAME}_after_allocation (void)
 	  if (!params.no_multi_toc)
 	    {
 	      toc_section = bfd_get_section_by_name (link_info.output_bfd,
-						     ".got");
+						     toc_section_name);
 	      if (toc_section != NULL)
 		lang_for_each_statement (build_toc_list);
 	    }



More information about the Binutils-cvs mailing list