[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

llvm-svn: 361367
This commit is contained in:
Martin Storsjo 2019-05-22 09:49:54 +00:00
parent f8f93ba90d
commit de6038b265
2 changed files with 18 additions and 1 deletions

View File

@ -595,7 +595,10 @@ Error writeImportLibrary(StringRef ImportName, StringRef Path,
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);

View File

@ -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