From 17324d8b340dd9a3e22a94191b15ebf07a41fcc9 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 1 Feb 2018 23:46:17 +0000 Subject: 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 llvm-svn: 324036 --- lld/ELF/ScriptParser.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lld/ELF/ScriptParser.cpp') diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 3e5975f3038..9f3eeda8b58 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -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 ScriptParser::readVersionExtern() { StringRef Tok = next(); bool IsCXX = Tok == "\"C++\""; @@ -1245,6 +1248,8 @@ std::vector ScriptParser::readVersionExtern() { StringRef Tok = next(); bool HasWildcard = !Tok.startswith("\"") && hasWildcard(Tok); Ret.push_back({unquote(Tok), IsCXX, HasWildcard}); + if (consume("}")) + return Ret; expect(";"); } -- cgit v1.2.3