[llvm] r361367 - [llvm-dlltool] Respect NONAME keyword

Martin Storsjo via llvm-commits llvm-commits at lists.llvm.org
Wed May 22 02:49:54 PDT 2019


Author: mstorsjo
Date: Wed May 22 02:49:54 2019
New Revision: 361367

URL: http://llvm.org/viewvc/llvm-project?rev=361367&view=rev
Log:
[llvm-dlltool] Respect NONAME keyword

This adds proper handling of the NONAME-keyword, which makes llvm-dlltool
generate an import using the ordinal instead of the name.

Patch by by Jannik Vogel, test added by Stefan Schmidt.

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

Added:
    llvm/trunk/test/tools/llvm-dlltool/coff-noname.def
Modified:
    llvm/trunk/lib/Object/COFFImportFile.cpp

Modified: llvm/trunk/lib/Object/COFFImportFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFImportFile.cpp?rev=361367&r1=361366&r2=361367&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFImportFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFImportFile.cpp Wed May 22 02:49:54 2019
@@ -595,7 +595,10 @@ Error writeImportLibrary(StringRef Impor
       ImportType = IMPORT_CONST;
 
     StringRef SymbolName = E.SymbolName.empty() ? E.Name : E.SymbolName;
-    ImportNameType NameType = getNameType(SymbolName, E.Name, Machine, MinGW);
+    ImportNameType NameType = E.Noname
+                                  ? IMPORT_ORDINAL
+                                  : getNameType(SymbolName, E.Name,
+                                                Machine, MinGW);
     Expected<std::string> Name = E.ExtName.empty()
                                      ? SymbolName
                                      : replace(SymbolName, E.Name, E.ExtName);

Added: llvm/trunk/test/tools/llvm-dlltool/coff-noname.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dlltool/coff-noname.def?rev=361367&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dlltool/coff-noname.def (added)
+++ llvm/trunk/test/tools/llvm-dlltool/coff-noname.def Wed May 22 02:49:54 2019
@@ -0,0 +1,14 @@
+; RUN: llvm-dlltool -k -m i386 --input-def %s --output-lib %t.a
+; RUN: llvm-readobj %t.a | FileCheck %s
+
+LIBRARY test.dll
+EXPORTS
+ByOrdinalFunction @ 1 NONAME
+ByNameFunction
+
+; CHECK: Name type: ordinal
+; CHECK: Symbol: __imp__ByOrdinalFunction
+; CHECK: Symbol: _ByOrdinalFunction
+; CHECK: Name type: noprefix
+; CHECK: Symbol: __imp__ByNameFunction
+; CHECK: Symbol: _ByNameFunction




More information about the llvm-commits mailing list