diff options
| author | Rui Ueyama <ruiu@google.com> | 2018-02-01 23:46:17 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2018-02-01 23:46:17 +0000 |
| commit | 17324d8b340dd9a3e22a94191b15ebf07a41fcc9 (patch) | |
| tree | 9967fda80e930b8a01adcb16cc02761d610ea86f | |
| parent | b2c3ea760320443f9d4360cbd7fcec1a8b3cc28e (diff) | |
| download | bcm5719-llvm-17324d8b340dd9a3e22a94191b15ebf07a41fcc9.tar.gz bcm5719-llvm-17324d8b340dd9a3e22a94191b15ebf07a41fcc9.zip | |
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
| -rw-r--r-- | lld/ELF/ScriptParser.cpp | 5 | ||||
| -rw-r--r-- | lld/test/ELF/dynamic-list-extern.s | 12 |
2 files changed, 9 insertions, 8 deletions
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<SymbolVersion> ScriptParser::readVersionExtern() { StringRef Tok = next(); bool IsCXX = Tok == "\"C++\""; @@ -1245,6 +1248,8 @@ std::vector<SymbolVersion> ScriptParser::readVersionExtern() { StringRef Tok = next(); bool HasWildcard = !Tok.startswith("\"") && hasWildcard(Tok); Ret.push_back({unquote(Tok), IsCXX, HasWildcard}); + if (consume("}")) + return Ret; expect(";"); } diff --git a/lld/test/ELF/dynamic-list-extern.s b/lld/test/ELF/dynamic-list-extern.s index dfeb31d4fc0..bb06cebf5f5 100644 --- a/lld/test/ELF/dynamic-list-extern.s +++ b/lld/test/ELF/dynamic-list-extern.s @@ -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 |

