[PATCH] D62175: [llvm-dlltool] Respect NONAME keyword

Stefan Schmidt via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 20 23:50:36 PDT 2019


thrimbor created this revision.
Herald added subscribers: llvm-commits, mstorsjo, dexonsmith, steven_wu, hiraditya, inglorion, mehdi_amini.
Herald added a project: LLVM.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62175

Files:
  llvm/lib/Object/COFFImportFile.cpp
  llvm/test/tools/llvm-dlltool/coff-noname.def


Index: llvm/test/tools/llvm-dlltool/coff-noname.def
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-dlltool/coff-noname.def
@@ -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
Index: llvm/lib/Object/COFFImportFile.cpp
===================================================================
--- llvm/lib/Object/COFFImportFile.cpp
+++ llvm/lib/Object/COFFImportFile.cpp
@@ -595,7 +595,10 @@
       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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62175.200408.patch
Type: text/x-patch
Size: 1405 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190521/2211914e/attachment.bin>


More information about the llvm-commits mailing list