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 automatic multiple toc segfaults


This patch cures a linker bug that can result in segfaults in ppc64
shared libraries with large toc sections requiring the linker's
automatic multiple toc support.  Shared libraries may call their own
functions via the PLT, and these types of calls were not recognized as
needing r2 valid.

	* elf64-ppc.c (toc_adjusting_stub_needed): Any call via the plt
	needs r2 valid, not just those to external syms.

Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.284
diff -u -p -r1.284 elf64-ppc.c
--- bfd/elf64-ppc.c	30 Jun 2008 20:51:58 -0000	1.284
+++ bfd/elf64-ppc.c	11 Aug 2008 13:36:03 -0000
@@ -9184,6 +9184,7 @@ toc_adjusting_stub_needed (struct bfd_li
       enum elf_ppc64_reloc_type r_type;
       unsigned long r_symndx;
       struct elf_link_hash_entry *h;
+      struct ppc_link_hash_entry *eh;
       Elf_Internal_Sym *sym;
       asection *sym_sec;
       struct _opd_sec_data *opd;
@@ -9206,24 +9207,21 @@ toc_adjusting_stub_needed (struct bfd_li
 	}
 
       /* Calls to dynamic lib functions go through a plt call stub
-	 that uses r2.  Branches to undefined symbols might be a call
-	 using old-style dot symbols that can be satisfied by a plt
-	 call into a new-style dynamic library.  */
-      if (sym_sec == NULL)
+	 that uses r2.  */
+      eh = (struct ppc_link_hash_entry *) h;
+      if (eh != NULL
+	  && (eh->elf.plt.plist != NULL
+	      || (eh->oh != NULL
+		  && eh->oh->elf.plt.plist != NULL)))
 	{
-	  struct ppc_link_hash_entry *eh = (struct ppc_link_hash_entry *) h;
-	  if (eh != NULL
-	      && eh->oh != NULL
-	      && eh->oh->elf.plt.plist != NULL)
-	    {
-	      ret = 1;
-	      break;
-	    }
-
-	  /* Ignore other undefined symbols.  */
-	  continue;
+	  ret = 1;
+	  break;
 	}
 
+      if (sym_sec == NULL)
+	/* Ignore other undefined symbols.  */
+	continue;
+
       /* Assume branches to other sections not included in the link need
 	 stubs too, to cover -R and absolute syms.  */
       if (sym_sec->output_section == NULL)

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