diff --git a/gold/ChangeLog b/gold/ChangeLog index 50c1affb7f..c1f4981ecf 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,8 @@ +2010-06-26 Jeffrey Yaskin + + * symtab.cc (detect_odr_violations): When reporting an ODR + violation, report an object where the symbol is defined. + 2010-06-25 Doug Kwan * arm.cc (Target_arm::can_check_for_functions_pointers): Return true. diff --git a/gold/symtab.cc b/gold/symtab.cc index 3f85f6c0e0..c721ae4297 100644 --- a/gold/symtab.cc +++ b/gold/symtab.cc @@ -3014,8 +3014,11 @@ Symbol_table::detect_odr_violations(const Task* task, ++it) { const char* symbol_name = it->first; - // We use a sorted set so the output is deterministic. - std::set line_nums; + // Maps from symbol location to a sample object file we found + // that location in. We use a sorted map so the location order + // is deterministic, but we only store an arbitrary object file + // to avoid copying lots of names. + std::map line_nums; for (Unordered_set::const_iterator locs = it->second.begin(); @@ -3034,7 +3037,11 @@ Symbol_table::detect_odr_violations(const Task* task, std::string lineno = Dwarf_line_info::one_addr2line( locs->object, locs->shndx, locs->offset, 16); if (!lineno.empty()) - line_nums.insert(lineno); + { + std::string& sample_object = line_nums[lineno]; + if (sample_object.empty()) + sample_object = locs->object->name(); + } } if (line_nums.size() > 1) @@ -3042,10 +3049,12 @@ Symbol_table::detect_odr_violations(const Task* task, gold_warning(_("while linking %s: symbol '%s' defined in multiple " "places (possible ODR violation):"), output_file_name, demangle(symbol_name).c_str()); - for (std::set::const_iterator it2 = line_nums.begin(); - it2 != line_nums.end(); - ++it2) - fprintf(stderr, " %s\n", it2->c_str()); + for (std::map::const_iterator it2 = + line_nums.begin(); + it2 != line_nums.end(); + ++it2) + fprintf(stderr, _(" %s from %s\n"), + it2->first.c_str(), it2->second.c_str()); } } // We only call one_addr2line() in this function, so we can clear its cache.