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 empty reloc sections


PR 10244 has an interesting object file with an empty .text section and
also an empty .rel.text section.  gold crashes on this case, expecting
to see a view of the empty .text section.  I committed this patch to
avoid the crash by skipping empty reloc sections.

Ian


2009-06-24  Ian Lance Taylor  <iant@google.com>

	PR 10244
	* reloc.cc (relocate_sections): Skip empty relocation sections.


Index: reloc.cc
===================================================================
RCS file: /cvs/src/src/gold/reloc.cc,v
retrieving revision 1.42
diff -p -u -r1.42 reloc.cc
--- reloc.cc	4 Mar 2009 06:46:27 -0000	1.42
+++ reloc.cc	24 Jun 2009 14:32:38 -0000
@@ -822,6 +822,10 @@ Sized_relobj<size, big_endian>::relocate
       if (sh_type != elfcpp::SHT_REL && sh_type != elfcpp::SHT_RELA)
 	continue;
 
+      off_t sh_size = shdr.get_sh_size();
+      if (sh_size == 0)
+	continue;
+
       unsigned int index = this->adjust_shndx(shdr.get_sh_info());
       if (index >= this->shnum())
 	{
@@ -851,7 +855,6 @@ Sized_relobj<size, big_endian>::relocate
 	  continue;
 	}
 
-      off_t sh_size = shdr.get_sh_size();
       const unsigned char* prelocs = this->get_view(shdr.get_sh_offset(),
 						    sh_size, true, false);
 

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