From 59cdec1fc6c8040d54e9d4f97157d2b7e5299fc3 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 6 Dec 2017 19:18:24 +0000 Subject: [PATCH] [COFF] Ignore semicolons in module definition identifiers Patch by David Major. The NSS project's .def files make heavy use of semicolons in a frightening attempt at portability: https://hg.mozilla.org/projects/nss/raw-file/tip/lib/ckfw/capi/nsscapi.def lld-link was treating the semicolon as part of the export name, resulting in unresolved symbols. This patch includes ';' in the list of characters to split on. Differential Revision: https://reviews.llvm.org/D39968 llvm-svn: 319933 --- lib/Object/COFFModuleDefinition.cpp | 2 +- test/tools/llvm-dlltool/coff-exports.def | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Object/COFFModuleDefinition.cpp b/lib/Object/COFFModuleDefinition.cpp index e2208016eb5..a571354648d 100644 --- a/lib/Object/COFFModuleDefinition.cpp +++ b/lib/Object/COFFModuleDefinition.cpp @@ -117,7 +117,7 @@ public: return Token(Identifier, S); } default: { - size_t End = Buf.find_first_of("=,\r\n \t\v"); + size_t End = Buf.find_first_of("=,;\r\n \t\v"); StringRef Word = Buf.substr(0, End); Kind K = llvm::StringSwitch(Word) .Case("BASE", KwBase) diff --git a/test/tools/llvm-dlltool/coff-exports.def b/test/tools/llvm-dlltool/coff-exports.def index 01d816f9f0e..0656a44a0a1 100644 --- a/test/tools/llvm-dlltool/coff-exports.def +++ b/test/tools/llvm-dlltool/coff-exports.def @@ -5,11 +5,17 @@ LIBRARY test.dll EXPORTS -TestFunction +TestFunction1 +TestFunction2; +TestFunction3 ; This is a comment ; CHECK: File: test.dll ; CHECK: Format: COFF-import-file ; CHECK: Type: code ; CHECK: Name type: name -; CHECK: Symbol: __imp_TestFunction -; CHECK: Symbol: TestFunction +; CHECK: Symbol: __imp_TestFunction1 +; CHECK: Symbol: TestFunction1 +; CHECK: Symbol: __imp_TestFunction2{{$}} +; CHECK: Symbol: TestFunction2{{$}} +; CHECK: Symbol: __imp_TestFunction3{{$}} +; CHECK: Symbol: TestFunction3{{$}}