This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
gold patch committed: Don't crash on empty warning section
- From: Ian Lance Taylor <ian at airs dot com>
- To: binutils at sourceware dot org
- Date: Tue, 23 Jun 2009 00:20:33 -0700
- Subject: gold patch committed: Don't crash on empty warning section
I committed this patch to gold to avoid crashing on an empty warning
section. In that case we take the name of the section to be the
warning to give.
Ian
2009-06-23 Ian Lance Taylor <iant@google.com>
PR 10147
* object.cc (Object::section_contents): Don't try to get a view if
the section has length zero.
(Object::handle_gnu_warning_section): If the section is empty, use
the name of the section as the warning.
Index: object.cc
===================================================================
RCS file: /cvs/src/src/gold/object.cc,v
retrieving revision 1.94
diff -u -r1.94 object.cc
--- object.cc 22 Jun 2009 06:51:53 -0000 1.94
+++ object.cc 23 Jun 2009 07:17:31 -0000
@@ -170,6 +170,11 @@
{
Location loc(this->do_section_contents(shndx));
*plen = convert_to_section_size_type(loc.data_size);
+ if (*plen == 0)
+ {
+ static const unsigned char empty[1] = { '\0' };
+ return empty;
+ }
return this->get_view(loc.file_offset, *plen, true, cache);
}
@@ -226,6 +231,12 @@
section_size_type len;
const unsigned char* contents = this->section_contents(shndx, &len,
false);
+ if (len == 0)
+ {
+ const char* warning = name + warn_prefix_len;
+ contents = reinterpret_cast<const unsigned char*>(warning);
+ len = strlen(warning);
+ }
std::string warning(reinterpret_cast<const char*>(contents), len);
symtab->add_warning(name + warn_prefix_len, this, warning);
return true;