This is the mail archive of the binutils@sourceware.org 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]

PR17488, powerpc64-linux-ld segfault


For binary ouput, we don't have an ELF bfd output so can't access
elf_elfheader.  Testing stub_bfd in ppc64elf.em ensures we have a
ppc64 ELF output.

The elf64-ppc.c changes are really just a tidy, triggered by looking
at all places where the abiversion bits of the ELF header are
accessed.  Note -w diff.

bfd/
	* elf64-ppc.c (ppc64_elf_before_check_relocs): Do .opd processing
	even when output is not ppc64 ELF.  Remove redundant tests on
	type of input bfd.
ld/
	PR 17488
	* emultempl/ppc64elf.em (gld${EMULATION_NAME}_finish): Don't attempt
	to access ELF header e_flags when not ppc64 ELF output.

diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 123a33a..974f992 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -4962,15 +4962,6 @@ ppc64_elf_before_check_relocs (bfd *ibfd, struct bfd_link_info *info)
 {
   struct ppc_link_hash_table *htab;
   struct ppc_link_hash_entry **p, *eh;
-
-  if (!is_ppc64_elf (info->output_bfd))
-    return TRUE;
-  htab = ppc_hash_table (info);
-  if (htab == NULL)
-    return FALSE;
-
-  if (is_ppc64_elf (ibfd))
-    {
   asection *opd = bfd_get_section_by_name (ibfd, ".opd");
 
   if (opd != NULL && opd->size != 0)
@@ -5011,6 +5002,12 @@ ppc64_elf_before_check_relocs (bfd *ibfd, struct bfd_link_info *info)
 	}
     }
 
+  if (!is_ppc64_elf (info->output_bfd))
+    return TRUE;
+  htab = ppc_hash_table (info);
+  if (htab == NULL)
+    return FALSE;
+
   /* For input files without an explicit abiversion in e_flags
      we should have flagged any with symbol st_other bits set
      as ELFv1 and above flagged those with .opd as ELFv2.
@@ -5035,7 +5032,6 @@ ppc64_elf_before_check_relocs (bfd *ibfd, struct bfd_link_info *info)
 	return FALSE;
       p = &eh->u.next_dot_sym;
     }
-    }
 
   /* Clear the list for non-ppc64 input files.  */
   p = &htab->dot_syms;
diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em
index 914fc52..59ea786 100644
--- a/ld/emultempl/ppc64elf.em
+++ b/ld/emultempl/ppc64elf.em
@@ -531,7 +531,8 @@ gld${EMULATION_NAME}_finish (void)
   /* e_entry on PowerPC64 points to the function descriptor for
      _start.  If _start is missing, default to the first function
      descriptor in the .opd section.  */
-  if ((elf_elfheader (link_info.output_bfd)->e_flags & EF_PPC64_ABI) == 1)
+  if (stub_file != NULL
+      && (elf_elfheader (link_info.output_bfd)->e_flags & EF_PPC64_ABI) == 1)
     entry_section = ".opd";
 
   if (params.emit_stub_syms < 0)

-- 
Alan Modra
Australia Development Lab, IBM


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