[ELF] - Add support for locals list in version script.
Previously we did not support anything except "local: *", patch changes that.
Actually GNU rules of proccessing wildcards are more complex than that (http://www.airs.com/blog/archives/300):
There are 2 iteration for wildcards, at first iteration "*" wildcards are ignored and handled at second iteration.
Since we previously decided not to implement such complex rules,
I suggest solution that is implemented in this patch. So for "local: *" case nothing changes,
but if we have wildcarded locals,
they are processed before wildcarded globals.
This should fix several FreeBSD ports, one of them is jpeg-turbo-1.5.1 and
currently blocks about 5k of ports.
Differential revision: https://reviews.llvm.org/D26395
llvm-svn: 286713
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 3e6b885..e25175d 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -968,7 +968,7 @@
void readExtern(std::vector<SymbolVersion> *Globals);
void readVersionDeclaration(StringRef VerStr);
void readGlobal(StringRef VerStr);
- void readLocal();
+ void readLocal(StringRef VerStr);
ScriptConfiguration &Opt = *ScriptConfig;
bool IsUnderSysroot;
@@ -1778,7 +1778,7 @@
if (consume("global:") || peek() != "local:")
readGlobal(VerStr);
if (consume("local:"))
- readLocal();
+ readLocal(VerStr);
expect("}");
// Each version may have a parent version. For example, "Ver2" defined as
@@ -1790,10 +1790,22 @@
expect(";");
}
-void ScriptParser::readLocal() {
- Config->DefaultSymbolVersion = VER_NDX_LOCAL;
- expect("*");
- expect(";");
+void ScriptParser::readLocal(StringRef VerStr) {
+ if (consume("*")) {
+ Config->DefaultSymbolVersion = VER_NDX_LOCAL;
+ expect(";");
+ return;
+ }
+
+ if (VerStr.empty())
+ setError("locals list for anonymous version is not supported");
+
+ std::vector<SymbolVersion> &Locals = Config->VersionDefinitions.back().Locals;
+ while (!Error && peek() != "}") {
+ StringRef Tok = next();
+ Locals.push_back({unquote(Tok), false, hasWildcard(Tok)});
+ expect(";");
+ }
}
void ScriptParser::readExtern(std::vector<SymbolVersion> *Globals) {