This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fix ppc64 hash table use


When linking to foreign output formats like srec, ppc64_elf_tls_setup
and other ppc64 functions were accessing ppc64 specific fields of the
hash table that didn't exist.  In the case of ppc64_elf_tls_setup, the
access was a write, causing some "interesting" effects.

ld/ChangeLog
	* emultempl/ppc64elf.em (ppc_create_output_section_statements): Check
	hash creator.
	(ppc_before_allocation): Don't do optimizations if wrong hash table.
	(gld${EMULATION_NAME}_finish): Ditto.

Forgot to commit this one.

ld/testsuite/ChangeLog
	* ld-powerpc/tlsexe.g: Update for 2003-02-14 elf64-ppc.c change.

Index: ld/emultempl/ppc64elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ppc64elf.em,v
retrieving revision 1.13
diff -u -p -d -r1.13 ppc64elf.em
--- ld/emultempl/ppc64elf.em	9 Feb 2003 04:36:44 -0000	1.13
+++ ld/emultempl/ppc64elf.em	17 Feb 2003 22:31:25 -0000
@@ -67,6 +67,13 @@ static struct bfd_elf_version_expr *gld$
 static void
 ppc_create_output_section_statements ()
 {
+  extern const bfd_target bfd_elf64_powerpc_vec;
+  extern const bfd_target bfd_elf64_powerpcle_vec;
+
+  if (link_info.hash->creator != &bfd_elf64_powerpc_vec
+      && link_info.hash->creator != &bfd_elf64_powerpcle_vec)
+    return;
+
   stub_file = lang_add_input_file ("linker stubs",
 				   lang_input_file_is_fake_enum,
 				   NULL);
@@ -98,26 +105,29 @@ ppc_after_open ()
 static void
 ppc_before_allocation ()
 {
-  if (!ppc64_elf_edit_opd (output_bfd, &link_info))
-    {
-      einfo ("%X%P: can not edit opd %E\n");
-      return;
-    }
-
-  if (ppc64_elf_tls_setup (output_bfd, &link_info) && !notlsopt)
+  if (stub_file != NULL)
     {
-      /* Size the sections.  This is premature, but we want to know the
-	 TLS segment layout so that certain optimizations can be done.  */
-      lang_size_sections (stat_ptr->head, abs_output_section,
-			  &stat_ptr->head, 0, (bfd_vma) 0, NULL);
-
-      if (!ppc64_elf_tls_optimize (output_bfd, &link_info))
+      if (!ppc64_elf_edit_opd (output_bfd, &link_info))
 	{
-	  einfo ("%X%P: TLS problem %E\n");
+	  einfo ("%X%P: can not edit opd %E\n");
 	  return;
 	}
 
-      lang_reset_memory_regions ();
+      if (ppc64_elf_tls_setup (output_bfd, &link_info) && !notlsopt)
+	{
+	  /* Size the sections.  This is premature, but we want to know the
+	     TLS segment layout so that certain optimizations can be done.  */
+	  lang_size_sections (stat_ptr->head, abs_output_section,
+			      &stat_ptr->head, 0, (bfd_vma) 0, NULL);
+
+	  if (!ppc64_elf_tls_optimize (output_bfd, &link_info))
+	    {
+	      einfo ("%X%P: TLS problem %E\n");
+	      return;
+	    }
+
+	  lang_reset_memory_regions ();
+	}
     }
 
   gld${EMULATION_NAME}_before_allocation ();
@@ -318,7 +328,7 @@ gld${EMULATION_NAME}_finish ()
 
   /* If generating a relocatable output file, then we don't have any
      stubs.  */
-  if (!link_info.relocateable)
+  if (stub_file != NULL && !link_info.relocateable)
     {
       int ret = ppc64_elf_setup_section_lists (output_bfd, &link_info);
       if (ret != 0)
@@ -348,7 +358,7 @@ gld${EMULATION_NAME}_finish ()
   if (need_laying_out)
     ppc_layout_sections_again ();
 
-  if (stub_file->the_bfd->sections != NULL)
+  if (stub_file != NULL && stub_file->the_bfd->sections != NULL)
     {
       if (!ppc64_elf_build_stubs (&link_info))
 	einfo ("%X%P: can not build stubs: %E\n");
Index: ld/testsuite/ld-powerpc/tlsexe.g
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlsexe.g,v
retrieving revision 1.2
diff -u -p -d -r1.2 tlsexe.g
--- ld/testsuite/ld-powerpc/tlsexe.g	9 Feb 2003 04:37:04 -0000	1.2
+++ ld/testsuite/ld-powerpc/tlsexe.g	17 Feb 2003 22:31:28 -0000
@@ -7,6 +7,6 @@
 .*: +file format elf64-powerpc
 
 Contents of section \.got:
- 100105f8 00000000 100185f8 00000000 00000000  .*
+ 100105f8 00000000 100185f8 00000000 00000001  .*
  10010608 00000000 00000000 ffffffff ffff8018  .*
  10010618 00000000 00000000 00000000 00000000  .*

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]