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]

ppc64_elf_get_synthetic_symtab


gprof and oprofile were giving errors like the following on powerpc64.
   BFD: some_file(.rela.plt): relocation 1 has invalid symbol index 3

Caused by calling slurp_relocs without any symbols.

	* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Don't attempt to
	read plt relocs if no dynamic syms.

Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.286
diff -u -p -r1.286 elf64-ppc.c
--- bfd/elf64-ppc.c	12 Aug 2008 13:12:49 -0000	1.286
+++ bfd/elf64-ppc.c	8 Oct 2008 23:36:02 -0000
@@ -3005,8 +3005,8 @@ ppc64_elf_get_synthetic_symtab (bfd *abf
 	}
 
       /* Get start of .glink stubs from DT_PPC64_GLINK.  */
-      dynamic = bfd_get_section_by_name (abfd, ".dynamic");
-      if (dynamic != NULL)
+      if (dyn_count != 0
+	  && (dynamic = bfd_get_section_by_name (abfd, ".dynamic")) != NULL)
 	{
 	  bfd_byte *dynbuf, *extdyn, *extdynend;
 	  size_t extdynsize;
@@ -3061,21 +3061,21 @@ ppc64_elf_get_synthetic_symtab (bfd *abf
 
 	  if (resolv_vma)
 	    size += sizeof (asymbol) + sizeof ("__glink_PLTresolve");
-	}
 
-      relplt = bfd_get_section_by_name (abfd, ".rela.plt");
-      if (glink != NULL && relplt != NULL)
-	{
-	  slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
-	  if (! (*slurp_relocs) (abfd, relplt, dyn_syms, TRUE))
-	    goto free_contents_and_exit;
+	  relplt = bfd_get_section_by_name (abfd, ".rela.plt");
+	  if (relplt != NULL)
+	    {
+	      slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
+	      if (! (*slurp_relocs) (abfd, relplt, dyn_syms, TRUE))
+		goto free_contents_and_exit;
 	
-	  plt_count = relplt->size / sizeof (Elf64_External_Rela);
-	  size += plt_count * sizeof (asymbol);
+	      plt_count = relplt->size / sizeof (Elf64_External_Rela);
+	      size += plt_count * sizeof (asymbol);
 
-	  p = relplt->relocation;
-	  for (i = 0; i < plt_count; i++, p++)
-	    size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
+	      p = relplt->relocation;
+	      for (i = 0; i < plt_count; i++, p++)
+		size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
+	    }
 	}
 
       s = *ret = bfd_malloc (size);

-- 
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]