From 52e5d8bcbb1f54919c07bfa7ff6fd64ef8581e6f Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 20 Dec 2010 18:37:36 +0000 Subject: [PATCH] * dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Only keep second of two consecutive entries with same offset. --- gold/ChangeLog | 5 +++++ gold/dwarf_reader.cc | 13 ++++++++++++- gold/dwarf_reader.h | 5 ++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index 4fbd9f70e..64958ab92 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,8 @@ +2010-12-20 Ian Lance Taylor + + * dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Only keep + second of two consecutive entries with same offset. + 2010-12-16 Ralf Wildenhues * testsuite/Makefile.am (ifuncmain2static_LDADD) diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc index 7fbfdaedc..8110f3814 100644 --- a/gold/dwarf_reader.cc +++ b/gold/dwarf_reader.cc @@ -493,7 +493,18 @@ Sized_dwarf_line_info::read_lines(unsigned const char* lineptr Offset_to_lineno_entry entry = { lsm.address, this->current_header_index_, lsm.file_num, lsm.line_num }; - line_number_map_[lsm.shndx].push_back(entry); + std::vector& + map(this->line_number_map_[lsm.shndx]); + // If we see two consecutive entries with the same + // offset and a real line number, then always use the + // second one. + if (!map.empty() + && (map.back().offset == static_cast(lsm.address)) + && lsm.line_num != -1 + && map.back().line_num != -1) + map.back() = entry; + else + map.push_back(entry); } lineptr += oplength; } diff --git a/gold/dwarf_reader.h b/gold/dwarf_reader.h index c1978332e..8fe7898a5 100644 --- a/gold/dwarf_reader.h +++ b/gold/dwarf_reader.h @@ -46,7 +46,10 @@ struct Offset_to_lineno_entry int header_num; // which file-list to use (i.e. which .o file are we in) int file_num; // a pointer into files_ int line_num; // the line number in the source file - // Offsets are unique within a section, so that's a sufficient sort key. + + // When we add entries to the table, we always use the last entry + // with a given offset. Given proper DWARF info, this should ensure + // that the offset is a sufficient sort key. bool operator<(const Offset_to_lineno_entry& that) const { return this->offset < that.offset; } }; -- 2.11.4.GIT