[ELF] - Recommit r273143("[ELF] - Basic versioned symbols support implemented.")
With fix:
-soname flag was not set in testcase. Hash calculated for base def was different on local
and bot machines because filename fos used for calculating.
Initial commit message:
Patch implements basic support of versioned symbols.
There is no wildcards patterns matching except local: *;
There is no support for hierarchies.
There is no support for symbols overrides (@ vs @@ not handled).
This patch allows programs that using simple scripts to link and run.
Differential revision: http://reviews.llvm.org/D21018
llvm-svn: 273152
diff --git a/lld/ELF/SymbolListFile.cpp b/lld/ELF/SymbolListFile.cpp
index 3d1377b..2d5d1c5 100644
--- a/lld/ELF/SymbolListFile.cpp
+++ b/lld/ELF/SymbolListFile.cpp
@@ -77,21 +77,21 @@
void run();
private:
- void parseVersion();
+ void parseVersion(StringRef Version);
void parseLocal();
- void parseVersionSymbols();
+ void parseVersionSymbols(StringRef Version);
};
-void VersionScriptParser::parseVersion() {
+void VersionScriptParser::parseVersion(StringRef Version) {
expect("{");
if (peek() == "global:") {
next();
- parseVersionSymbols();
+ parseVersionSymbols(Version);
}
if (peek() == "local:")
parseLocal();
else
- parseVersionSymbols();
+ parseVersionSymbols(Version);
expect("}");
expect(";");
@@ -104,13 +104,21 @@
Config->VersionScriptGlobalByDefault = false;
}
-void VersionScriptParser::parseVersionSymbols() {
+void VersionScriptParser::parseVersionSymbols(StringRef Version) {
+ std::vector<StringRef> *Globals;
+ if (Version.empty()) {
+ Globals = &Config->VersionScriptGlobals;
+ } else {
+ Config->SymbolVersions.push_back(elf::Version(Version));
+ Globals = &Config->SymbolVersions.back().Globals;
+ }
+
for (;;) {
StringRef Cur = peek();
if (Cur == "}" || Cur == "local:")
return;
next();
- Config->VersionScriptGlobals.push_back(Cur);
+ Globals->push_back(Cur);
expect(";");
}
}
@@ -119,18 +127,18 @@
StringRef Msg = "anonymous version definition is used in "
"combination with other version definitions";
if (peek() == "{") {
- parseVersion();
+ parseVersion("");
if (!atEOF())
setError(Msg);
return;
}
while (!atEOF() && !Error) {
- if (next() == "{") {
+ if (peek() == "{") {
setError(Msg);
return;
}
- parseVersion();
+ parseVersion(next());
}
}