+ // A new weak undefined reference, merging with an old weak
+ // reference, could be a One Definition Rule (ODR) violation --
+ // especially if the types or sizes of the references differ. We'll
+ // store such pairs and look them up later to make sure they
+ // actually refer to the same lines of code. We also check
+ // combinations of weak and strong, which might occur if one case is
+ // inline and the other is not. (Note: not all ODR violations can
+ // be found this way, and not everything this finds is an ODR
+ // violation. But it's helpful to warn about.)
+ if (parameters->options().detect_odr_violations()
+ && (sym.get_st_bind() == elfcpp::STB_WEAK
+ || to->binding() == elfcpp::STB_WEAK)
+ && orig_st_shndx != elfcpp::SHN_UNDEF
+ && to->shndx(&to_is_ordinary) != elfcpp::SHN_UNDEF
+ && to_is_ordinary
+ && sym.get_st_size() != 0 // Ignore weird 0-sized symbols.
+ && to->symsize() != 0
+ && (sym.get_st_type() != to->type()
+ || sym.get_st_size() != to->symsize())
+ // C does not have a concept of ODR, so we only need to do this
+ // on C++ symbols. These have (mangled) names starting with _Z.
+ && to->name()[0] == '_' && to->name()[1] == 'Z')
+ {
+ Symbol_location fromloc
+ = { object, orig_st_shndx, static_cast<off_t>(sym.get_st_value()) };
+ Symbol_location toloc = { to->object(), to->shndx(&to_is_ordinary),
+ static_cast<off_t>(to->value()) };
+ this->candidate_odr_violations_[to->name()].insert(fromloc);
+ this->candidate_odr_violations_[to->name()].insert(toloc);
+ }
+
+ // Plugins don't provide a symbol type, so adopt the existing type
+ // if the FROM symbol is from a plugin.
+ elfcpp::STT fromtype = (object->pluginobj() != NULL
+ ? to->type()
+ : sym.get_st_type());
+ unsigned int frombits = symbol_to_bits(sym.get_st_bind(),
+ object->is_dynamic(),
+ st_shndx, is_ordinary);
+
+ bool adjust_common_sizes;
+ bool adjust_dyndef;
+ typename Sized_symbol<size>::Size_type tosize = to->symsize();
+ if (Symbol_table::should_override(to, frombits, fromtype, OBJECT,
+ object, &adjust_common_sizes,
+ &adjust_dyndef, is_default_version))
+ {
+ elfcpp::STB tobinding = to->binding();
+ typename Sized_symbol<size>::Value_type tovalue = to->value();
+ this->override(to, sym, st_shndx, is_ordinary, object, version);
+ if (adjust_common_sizes)
+ {
+ if (tosize > to->symsize())
+ to->set_symsize(tosize);
+ if (tovalue > to->value())
+ to->set_value(tovalue);
+ }
+ if (adjust_dyndef)
+ {
+ // We are overriding an UNDEF or WEAK UNDEF with a DYN DEF.
+ // Remember which kind of UNDEF it was for future reference.
+ to->set_undef_binding(tobinding);
+ }