+Versions::Versions(const Version_script_info& version_script,
+ Stringpool* dynpool)
+ : defs_(), needs_(), version_table_(),
+ is_finalized_(false), version_script_(version_script)
+{
+ // We always need a base version, so define that first. Nothing
+ // explicitly declares itself as part of base, so it doesn't need to
+ // be in version_table_.
+ // FIXME: Should use soname here when creating a shared object. Is
+ // this fixme still valid? It looks like it's doing the right thing
+ // to me.
+ if (parameters->output_is_shared())
+ {
+ const char* name = dynpool->add(parameters->output_file_name(),
+ false, NULL);
+ Verdef* vdbase = new Verdef(name, std::vector<std::string>(),
+ true, false, true);
+ this->defs_.push_back(vdbase);
+ }
+
+ if (!this->version_script_.empty())
+ {
+ // Parse the version script, and insert each declared version into
+ // defs_ and version_table_.
+ std::vector<std::string> versions = this->version_script_.get_versions();
+ for (size_t k = 0; k < versions.size(); ++k)
+ {
+ Stringpool::Key version_key;
+ const char* version = dynpool->add(versions[k].c_str(),
+ true, &version_key);
+ Verdef* const vd = new Verdef(
+ version,
+ this->version_script_.get_dependencies(version),
+ false, false, false);
+ this->defs_.push_back(vd);
+ Key key(version_key, 0);
+ this->version_table_.insert(std::make_pair(key, vd));
+ }
+ }
+}
+