+2015-08-25 Cary Coutant <ccoutant@gmail.com>
+
+ PR gold/18859
+ * object.cc (Input_objects::add_object): Store objects in a map,
+ indexed by soname; update as-needed flag when necessary.
+ * object.h (Object::clear_as_needed): New method.
+ (Input_objects::so_names_): Change from set to map.
+
2015-08-25 Cary Coutant <ccoutant@gmail.com>
PR gold/14746
Dynobj* dynobj = static_cast<Dynobj*>(obj);
const char* soname = dynobj->soname();
- std::pair<Unordered_set<std::string>::iterator, bool> ins =
- this->sonames_.insert(soname);
+ Unordered_map<std::string, Object*>::value_type val(soname, obj);
+ std::pair<Unordered_map<std::string, Object*>::iterator, bool> ins =
+ this->sonames_.insert(val);
if (!ins.second)
{
// We have already seen a dynamic object with this soname.
+ // If any instances of this object on the command line have
+ // the --no-as-needed flag, make sure the one we keep is
+ // marked so.
+ if (!obj->as_needed())
+ {
+ gold_assert(ins.first->second != NULL);
+ ins.first->second->clear_as_needed();
+ }
return false;
}
set_as_needed()
{ this->as_needed_ = true; }
+ // Clear flag that this object was linked with --as-needed.
+ void
+ clear_as_needed()
+ { this->as_needed_ = false; }
+
// Return whether this object was linked with --as-needed.
bool
as_needed() const
// The list of dynamic objects included in the link.
Dynobj_list dynobj_list_;
// SONAMEs that we have seen.
- Unordered_set<std::string> sonames_;
+ Unordered_map<std::string, Object*> sonames_;
// Manage cross-references if requested.
Cref* cref_;
};