[lld] r294343 - Handle the case where 'local' is the name of a global in a version script:
Dmitry Mikulin via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 7 11:50:48 PST 2017
Author: dmikulin
Date: Tue Feb 7 13:50:47 2017
New Revision: 294343
URL: http://llvm.org/viewvc/llvm-project?rev=294343&view=rev
Log:
Handle the case where 'local' is the name of a global in a version script:
{ global : local; local: *; };
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/ScriptParser.cpp
lld/trunk/ELF/ScriptParser.h
lld/trunk/test/ELF/version-script-glob.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=294343&r1=294342&r2=294343&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Feb 7 13:50:47 2017
@@ -1995,7 +1995,7 @@ std::vector<SymbolVersion> ScriptParser:
continue;
}
- if (peek() == "}" || peek() == "local" || Error)
+ if (peek() == "}" || (peek() == "local" && peek(1) == ":") || Error)
break;
StringRef Tok = next();
Ret.push_back({unquote(Tok), false, hasWildcard(Tok)});
Modified: lld/trunk/ELF/ScriptParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ScriptParser.cpp?rev=294343&r1=294342&r2=294343&view=diff
==============================================================================
--- lld/trunk/ELF/ScriptParser.cpp (original)
+++ lld/trunk/ELF/ScriptParser.cpp Tue Feb 7 13:50:47 2017
@@ -156,11 +156,14 @@ StringRef ScriptParserBase::next() {
return Tokens[Pos++];
}
-StringRef ScriptParserBase::peek() {
- StringRef Tok = next();
- if (Error)
- return "";
- --Pos;
+StringRef ScriptParserBase::peek(unsigned N) {
+ StringRef Tok;
+ for (unsigned I = 0; I <= N; ++I) {
+ Tok = next();
+ if (Error)
+ return "";
+ }
+ Pos = Pos - N - 1;
return Tok;
}
Modified: lld/trunk/ELF/ScriptParser.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ScriptParser.h?rev=294343&r1=294342&r2=294343&view=diff
==============================================================================
--- lld/trunk/ELF/ScriptParser.h (original)
+++ lld/trunk/ELF/ScriptParser.h Tue Feb 7 13:50:47 2017
@@ -28,7 +28,7 @@ public:
static StringRef skipSpace(StringRef S);
bool atEOF();
StringRef next();
- StringRef peek();
+ StringRef peek(unsigned N = 0);
void skip();
bool consume(StringRef Tok);
void expect(StringRef Expect);
Modified: lld/trunk/test/ELF/version-script-glob.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/version-script-glob.s?rev=294343&r1=294342&r2=294343&view=diff
==============================================================================
--- lld/trunk/test/ELF/version-script-glob.s (original)
+++ lld/trunk/test/ELF/version-script-glob.s Tue Feb 7 13:50:47 2017
@@ -14,6 +14,9 @@ bar1:
.globl zed1
zed1:
+ .globl local
+local:
+
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name:
@@ -43,3 +46,27 @@ zed1:
# CHECK-NEXT: Section: .text
# CHECK-NEXT: }
# CHECK-NEXT: ]
+
+# RUN: echo "{ global : local; local: *; };" > %t1.script
+# RUN: ld.lld -shared --version-script %t1.script %t.o -o %t1.so
+
+# LOCAL: DynamicSymbols [
+# LOCAL-NEXT: Symbol {
+# LOCAL-NEXT: Name:
+# LOCAL-NEXT: Value: 0x0
+# LOCAL-NEXT: Size: 0
+# LOCAL-NEXT: Binding: Local
+# LOCAL-NEXT: Type: None
+# LOCAL-NEXT: Other: 0
+# LOCAL-NEXT: Section: Undefined
+# LOCAL-NEXT: }
+# LOCAL-NEXT: Symbol {
+# LOCAL-NEXT: Name: local
+# LOCAL-NEXT: Value: 0x1000
+# LOCAL-NEXT: Size: 0
+# LOCAL-NEXT: Binding: Global
+# LOCAL-NEXT: Type: None
+# LOCAL-NEXT: Other: 0
+# LOCAL-NEXT: Section: .text
+# LOCAL-NEXT: }
+# LOCAL-NEXT: ]
More information about the llvm-commits
mailing list