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]

gold patch committed: Don't crash on ld -r with reloc symndx 0


PR 10843 has an odd input file which has relocations against symbol
index 0 (which is always an undefined symbol).  When gold was used to
link that file with -r, gold crashed.  I committed this patch to fix
the crash by retaining a symbol index of 0 in the output file.

Ian


2009-12-30  Ian Lance Taylor  <iant@google.com>

	PR 10843
	* target-reloc.h (relocate_for_relocatable): When copying a reloc,
	if the input symbol index is 0, make the output symbol index 0.


Index: target-reloc.h
===================================================================
RCS file: /cvs/src/src/gold/target-reloc.h,v
retrieving revision 1.36
diff -p -u -r1.36 target-reloc.h
--- target-reloc.h	29 Oct 2009 05:16:23 -0000	1.36
+++ target-reloc.h	30 Dec 2009 20:34:45 -0000
@@ -503,8 +503,13 @@ relocate_for_relocatable(
 	  switch (strategy)
 	    {
 	    case Relocatable_relocs::RELOC_COPY:
-	      new_symndx = object->symtab_index(r_sym);
-	      gold_assert(new_symndx != -1U);
+	      if (r_sym == 0)
+		new_symndx = 0;
+	      else
+		{
+		  new_symndx = object->symtab_index(r_sym);
+		  gold_assert(new_symndx != -1U);
+		}
 	      break;
 
 	    case Relocatable_relocs::RELOC_ADJUST_FOR_SECTION_RELA:

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