aboutsummaryrefslogtreecommitdiff
path: root/gold/symtab.cc
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2015-04-09 11:52:21 -0700
committerCary Coutant <ccoutant@google.com>2015-04-09 11:53:01 -0700
commit437ddf0c4cb63fdb68c4bd1cc155144db344d0c5 (patch)
tree125d12fcbbc64bc9b76e629407a64c687ac12000 /gold/symtab.cc
parentcd6faa73f8e3b888ee8b73a733382a5587aca202 (diff)
downloadbinutils-437ddf0c4cb63fdb68c4bd1cc155144db344d0c5.zip
binutils-437ddf0c4cb63fdb68c4bd1cc155144db344d0c5.tar.gz
binutils-437ddf0c4cb63fdb68c4bd1cc155144db344d0c5.tar.bz2
Improve ODR checking in gold.
gold/ * debug.h (DEBUG_LOCATION): New. (DEBUG_ALL): Include DEBUG_LOCATION. (debug_string_to_enum): Add DEBUG_LOCATION. * dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Fix debug output to print correct context. (Sized_dwarf_line_info::do_addr2line): Add debug output. Return up to 4 more locations at the beginning of the function. * symtab.cc (Symbol_table::detect_odr_violations): Get canonical result before sorting list of line numbers. * testsuite/debug_msg.sh: Allow range of line numbers for canonical results on optimized code.
Diffstat (limited to 'gold/symtab.cc')
-rw-r--r--gold/symtab.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 045327a..88e9322 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -3336,8 +3336,11 @@ Symbol_table::detect_odr_violations(const Task* task,
first_object_name = locs->object->name();
first_object_linenos = this->linenos_from_loc(task, *locs);
}
+ if (first_object_linenos.empty())
+ continue;
// Sort by Odr_violation_compare to make std::set_intersection work.
+ std::string first_object_canonical_result = first_object_linenos.back();
std::sort(first_object_linenos.begin(), first_object_linenos.end(),
Odr_violation_compare());
@@ -3349,6 +3352,8 @@ Symbol_table::detect_odr_violations(const Task* task,
if (linenos.empty())
continue;
// Sort by Odr_violation_compare to make std::set_intersection work.
+ gold_assert(!linenos.empty());
+ std::string second_object_canonical_result = linenos.back();
std::sort(linenos.begin(), linenos.end(), Odr_violation_compare());
Check_intersection intersection_result =
@@ -3367,13 +3372,11 @@ Symbol_table::detect_odr_violations(const Task* task,
// which may not be the location we expect to intersect
// with another definition. We could print the whole
// set of locations, but that seems too verbose.
- gold_assert(!first_object_linenos.empty());
- gold_assert(!linenos.empty());
fprintf(stderr, _(" %s from %s\n"),
- first_object_linenos[0].c_str(),
+ first_object_canonical_result.c_str(),
first_object_name.c_str());
fprintf(stderr, _(" %s from %s\n"),
- linenos[0].c_str(),
+ second_object_canonical_result.c_str(),
locs->object->name().c_str());
// Only print one broken pair, to avoid needing to
// compare against a list of the disjoint definition