[lld] r324036 - Relax the grammar of the version script.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 15:46:17 PST 2018


Author: ruiu
Date: Thu Feb  1 15:46:17 2018
New Revision: 324036

URL: http://llvm.org/viewvc/llvm-project?rev=324036&view=rev
Log:
Relax the grammar of the version script.

In GNU linkers, the last semicolon is optional. We can't link libstdc++
with lld because of that difference.

Differential Revision: https://reviews.llvm.org/D42820

Modified:
    lld/trunk/ELF/ScriptParser.cpp
    lld/trunk/test/ELF/dynamic-list-extern.s

Modified: lld/trunk/ELF/ScriptParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ScriptParser.cpp?rev=324036&r1=324035&r2=324036&view=diff
==============================================================================
--- lld/trunk/ELF/ScriptParser.cpp (original)
+++ lld/trunk/ELF/ScriptParser.cpp Thu Feb  1 15:46:17 2018
@@ -1233,6 +1233,9 @@ ScriptParser::readSymbols() {
 
 // Reads an "extern C++" directive, e.g.,
 // "extern "C++" { ns::*; "f(int, double)"; };"
+//
+// The last semicolon is optional. E.g. this is OK:
+// "extern "C++" { ns::*; "f(int, double)" };"
 std::vector<SymbolVersion> ScriptParser::readVersionExtern() {
   StringRef Tok = next();
   bool IsCXX = Tok == "\"C++\"";
@@ -1245,6 +1248,8 @@ std::vector<SymbolVersion> ScriptParser:
     StringRef Tok = next();
     bool HasWildcard = !Tok.startswith("\"") && hasWildcard(Tok);
     Ret.push_back({unquote(Tok), IsCXX, HasWildcard});
+    if (consume("}"))
+      return Ret;
     expect(";");
   }
 

Modified: lld/trunk/test/ELF/dynamic-list-extern.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/dynamic-list-extern.s?rev=324036&r1=324035&r2=324036&view=diff
==============================================================================
--- lld/trunk/test/ELF/dynamic-list-extern.s (original)
+++ lld/trunk/test/ELF/dynamic-list-extern.s Thu Feb  1 15:46:17 2018
@@ -4,12 +4,8 @@
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
 
-# RUN: echo '{ \
-# RUN:         extern "C" { \
-# RUN:           foo; \
-# RUN:         }; \
-# RUN:         extern "C++" { \
-# RUN:           bar; \
-# RUN:         }; \
-# RUN:       };' > %t.list
+# RUN: echo '{ extern "C" { foo; }; extern "C++" { bar; }; };' > %t.list
+# RUN: ld.lld --dynamic-list %t.list %t.o -shared -o %t.so
+
+# RUN: echo '{ extern "C" { foo }; extern "C++" { bar }; };' > %t.list
 # RUN: ld.lld --dynamic-list %t.list %t.o -shared -o %t.so




More information about the llvm-commits mailing list