[ELF] - Separate locals list from versions.

This change separates all versioned locals to be a separate list in config,
that was suggested by Rafael and simplifies the logic a bit.

Differential revision: https://reviews.llvm.org/D26754

llvm-svn: 287132
This commit is contained in:
George Rimar 2016-11-16 18:46:23 +00:00
parent 0d162b1c4f
commit 17c65af82f
3 changed files with 10 additions and 13 deletions

View File

@ -62,7 +62,6 @@ struct VersionDefinition {
llvm::StringRef Name;
size_t Id;
std::vector<SymbolVersion> Globals;
std::vector<SymbolVersion> Locals;
size_t NameOff; // Offset in string table.
};
@ -92,6 +91,7 @@ struct Configuration {
std::vector<llvm::StringRef> SearchPaths;
std::vector<llvm::StringRef> Undefined;
std::vector<SymbolVersion> VersionScriptGlobals;
std::vector<SymbolVersion> VersionScriptLocals;
std::vector<uint8_t> BuildIdVector;
bool AllowMultipleDefinition;
bool AsNeeded = false;

View File

@ -1844,7 +1844,7 @@ void ScriptParser::readLocal(StringRef VerStr) {
if (VerStr.empty())
setError("locals list for anonymous version is not supported");
readSymbols(Config->VersionDefinitions.back().Locals);
readSymbols(Config->VersionScriptLocals);
}
void ScriptParser::readVersionExtern(std::vector<SymbolVersion> *V) {

View File

@ -716,24 +716,21 @@ template <class ELFT> void SymbolTable<ELFT>::scanVersionScript() {
// First, we assign versions to exact matching symbols,
// i.e. version definitions not containing any glob meta-characters.
for (VersionDefinition &V : Config->VersionDefinitions) {
for (SymbolVersion Sym : Config->VersionScriptLocals)
assignVersion(Sym, VER_NDX_LOCAL, "local");
for (VersionDefinition &V : Config->VersionDefinitions)
for (SymbolVersion Sym : V.Globals)
assignVersion(Sym, V.Id, V.Name);
for (SymbolVersion Sym : V.Locals)
assignVersion(Sym, VER_NDX_LOCAL, "local");
}
// Next, we assign versions to fuzzy matching symbols,
// i.e. version definitions containing glob meta-characters.
// Note that because the last match takes precedence over previous matches,
// we iterate over the definitions in the reverse order.
for (size_t I = Config->VersionDefinitions.size() - 1; I != (size_t)-1; --I) {
VersionDefinition &V = Config->VersionDefinitions[I];
for (SymbolVersion &Ver : V.Locals)
assignWildcardVersion(Ver, VER_NDX_LOCAL);
for (SymbolVersion &Ver : V.Globals)
assignWildcardVersion(Ver, V.Id);
}
for (SymbolVersion &Ver : Config->VersionScriptLocals)
assignWildcardVersion(Ver, VER_NDX_LOCAL);
for (size_t I = Config->VersionDefinitions.size() - 1; I != (size_t)-1; --I)
for (SymbolVersion &Ver : Config->VersionDefinitions[I].Globals)
assignWildcardVersion(Ver, Config->VersionDefinitions[I].Id);
}
template class elf::SymbolTable<ELF32LE>;