diff options
author | Ian Lance Taylor <ian@airs.com> | 2008-05-28 20:48:16 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2008-05-28 20:48:16 +0000 |
commit | 62b01cb5034c3694d07c60158529f18cb301bb5c (patch) | |
tree | 22682d726ba0094de43e3b3eb47306a3e08f5e93 /gold/dwarf_reader.cc | |
parent | 1a51c1a48dafc996d6c199832cb75b46779d33ae (diff) | |
download | binutils-62b01cb5034c3694d07c60158529f18cb301bb5c.zip binutils-62b01cb5034c3694d07c60158529f18cb301bb5c.tar.gz binutils-62b01cb5034c3694d07c60158529f18cb301bb5c.tar.bz2 |
elfcpp/:
* dwarf.h (enum DW_FORM): Define.
gold/:
* reduced_debug_output.cc: New file.
* reduced_debug_output.h: New file.
* options.h (class General_optoins): Add --strip-debug-non-line.
* options.cc (General_options::finalize): Add strip_debug_non_line
to the strip heirarchy.
* layout.h (class Layout): Add debug_abbrev_ and debug_info_
fields.
* layout.cc: Include "reduced_debug_output.h".
(Layout::Layout): Initialize new fields.
(line_only_debug_sections): New static array.
(is_lines_only_debug_sections): New static inline function.
(Layout::include_section): Handle --strip-debug-non-line.
(Layout::make_output_section): If --strip-debug-non-line, build
new output sections for .debug_abbrev and .debug_info.
* dwarf_reader.cc (read_unsigned_LEB_128): Move to namespace
gold. Warn about possible overflow.
(read_signed_LEB_128): Likewise.
* dwarf_reader.h: (read_unsigned_LEB_128): Declare.
(read_signed_LEB_128): Declare.
* Makefile.am (CCFILES): Add reduced_debug_output.cc.
(HFILES): Add reduced_debug_output.h.
* Makefile.in: Rebuild.
Diffstat (limited to 'gold/dwarf_reader.cc')
-rw-r--r-- | gold/dwarf_reader.cc | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc index ec697e4..3d0f65a 100644 --- a/gold/dwarf_reader.cc +++ b/gold/dwarf_reader.cc @@ -32,7 +32,7 @@ #include "reloc.h" #include "dwarf_reader.h" -namespace { +namespace gold { // Read an unsigned LEB128 number. Each byte contains 7 bits of // information, plus one bit saying whether the number continues or @@ -48,6 +48,12 @@ read_unsigned_LEB_128(const unsigned char* buffer, size_t* len) do { + if (num_read >= 64 / 7) + { + gold_warning(_("Unusually large LEB128 decoded, " + "debug information may be corrupted")); + break; + } byte = *buffer++; num_read++; result |= (static_cast<uint64_t>(byte & 0x7f)) << shift; @@ -73,6 +79,12 @@ read_signed_LEB_128(const unsigned char* buffer, size_t* len) do { + if (num_read >= 64 / 7) + { + gold_warning(_("Unusually large LEB128 decoded, " + "debug information may be corrupted")); + break; + } byte = *buffer++; num_read++; result |= (static_cast<uint64_t>(byte & 0x7f) << shift); @@ -86,11 +98,6 @@ read_signed_LEB_128(const unsigned char* buffer, size_t* len) return result; } -} // End anonymous namespace. - - -namespace gold { - // This is the format of a DWARF2/3 line state machine that we process // opcodes using. There is no need for anything outside the lineinfo // processor to know how this works. |