aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2015-01-21 15:45:55 -0800
committerCary Coutant <ccoutant@google.com>2015-01-21 15:45:55 -0800
commit361595a3ded2175e850b23cabfcf7abe0c2c8679 (patch)
tree13762cb800750bf2fa03a2d73cc9f0502e7a1a68
parentfc0d0b62cbd4ec1785967cc9ce9f834aa3ea1a4b (diff)
downloadbinutils-361595a3ded2175e850b23cabfcf7abe0c2c8679.zip
binutils-361595a3ded2175e850b23cabfcf7abe0c2c8679.tar.gz
binutils-361595a3ded2175e850b23cabfcf7abe0c2c8679.tar.bz2
Ignore line tables whose versions we don't support.
2015-01-21 Cary Coutant <ccoutant@google.com> gold/ * dwarf_reader.cc (Sized_dwarf_line_info::read_header_prolog): Check line table version number. (Sized_dwarf_line_info::read_line_mappings): Likewise.
-rw-r--r--gold/dwarf_reader.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc
index e7c95ce..bd641d1 100644
--- a/gold/dwarf_reader.cc
+++ b/gold/dwarf_reader.cc
@@ -1638,11 +1638,17 @@ Sized_dwarf_line_info<size, big_endian>::read_header_prolog(
header_.total_length = initial_length;
+ const unsigned char* end_of_initial_length = lineptr;
gold_assert(lineptr + header_.total_length <= buffer_end_);
header_.version = elfcpp::Swap_unaligned<16, big_endian>::readval(lineptr);
lineptr += 2;
+ // We can only read versions 2 and 3 of the DWARF line number table.
+ // For other versions, just skip the entire line number table.
+ if (header_.version < 2 || header_.version > 3)
+ return end_of_initial_length + initial_length;
+
if (header_.offset_size == 4)
header_.prologue_length = elfcpp::Swap_unaligned<32, big_endian>::readval(lineptr);
else
@@ -2027,8 +2033,11 @@ Sized_dwarf_line_info<size, big_endian>::read_line_mappings(unsigned int shndx)
{
const unsigned char* lineptr = this->buffer_;
lineptr = this->read_header_prolog(lineptr);
- lineptr = this->read_header_tables(lineptr);
- lineptr = this->read_lines(lineptr, shndx);
+ if (header_.version >= 2 && header_.version <= 3)
+ {
+ lineptr = this->read_header_tables(lineptr);
+ lineptr = this->read_lines(lineptr, shndx);
+ }
this->buffer_ = lineptr;
}