* emultempl/ppc64elf.em (ppc_create_output_section_statements): Check
authorAlan Modra <amodra@gmail.com>
Mon, 17 Feb 2003 22:49:24 +0000 (22:49 +0000)
committerAlan Modra <amodra@gmail.com>
Mon, 17 Feb 2003 22:49:24 +0000 (22:49 +0000)
hash creator.
(ppc_before_allocation): Don't do optimizations if wrong hash table.
(gld${EMULATION_NAME}_finish): Ditto.

ld/ChangeLog
ld/emultempl/ppc64elf.em

index 431345f..13dd4f4 100644 (file)
@@ -1,3 +1,10 @@
+2003-02-18  Alan Modra  <amodra@bigpond.net.au>
+
+       * 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.
+
 2003-02-17  Nick Clifton  <nickc@redhat.com>
 
        * ldmain.c (main) Default allow_shlib_undefined to true.
        * scripttempl/elf32msp430_3.sc: New file.  Linker script for msp430.
 
 2002-12-30  Ralf Habacker  <Ralf.Habacker@freenet.de>
-            Charles Wilson  <cwilson@ece.gatech.edu>
+           Charles Wilson  <cwilson@ece.gatech.edu>
 
        * ld/config.in (HAVE_REALPATH): New entry.
        (HAVE_SYS_STAT_H, HAVE_SYS_TYPES_H): Removed: obsolete.
index 20fe0a3..b524e01 100644 (file)
@@ -67,6 +67,13 @@ static struct bfd_elf_version_expr *gld${EMULATION_NAME}_new_vers_pattern
 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");