gold patch committed: Ignore empty reloc sections

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

gold patch committed: Ignore empty reloc sections

Ian Lance Taylor
This patch to gold ignores empty reloc sections when reading relocs,
rather than crashing when it tries to get a zero-sized view.  Committed
to mainline.

Ian


2011-05-30  Ian Lance Taylor  <[hidden email]>

        * reloc.cc (Sized_relobj_file::do_read_relocs): Ignore empty reloc
        sections.



Index: reloc.cc
===================================================================
RCS file: /cvs/src/src/gold/reloc.cc,v
retrieving revision 1.66
diff -p -u -r1.66 reloc.cc
--- reloc.cc 24 May 2011 21:41:10 -0000 1.66
+++ reloc.cc 31 May 2011 04:25:52 -0000
@@ -322,6 +322,9 @@ Sized_relobj_file<size, big_endian>::do_
 
       off_t sh_size = shdr.get_sh_size();
 
+      if (sh_size == 0)
+ continue;
+
       unsigned int reloc_size;
       if (sh_type == elfcpp::SHT_REL)
  reloc_size = elfcpp::Elf_sizes<size>::rel_size;