Skip to content

Commit 7799bc5

Browse files
committed
[llvm-dlltool] Use EXPORTAS name type for renamed imports on ARM64EC.
1 parent 3fae555 commit 7799bc5

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

llvm/lib/Object/COFFImportFile.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,10 @@ Error writeImportLibrary(StringRef ImportName, StringRef Path,
729729
else if (Machine == IMAGE_FILE_MACHINE_I386 &&
730730
applyNameType(IMPORT_NAME_NOPREFIX, Name) == E.ImportName)
731731
NameType = IMPORT_NAME_NOPREFIX;
732-
else if (Name == E.ImportName)
732+
else if (isArm64EC(M)) {
733+
NameType = IMPORT_NAME_EXPORTAS;
734+
ExportName = E.ImportName;
735+
} else if (Name == E.ImportName)
733736
NameType = IMPORT_NAME;
734737
else {
735738
Deferred D;

llvm/test/tools/llvm-dlltool/arm64ec.test

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ RUN: llvm-nm --print-armap test3.lib | FileCheck --check-prefix=ARMAP2 %s
4444
RUN: not llvm-dlltool -m arm64 -d test.def -N test2.def -l test4.lib 2>&1 | FileCheck --check-prefix=ERR %s
4545
ERR: native .def file is supported only on arm64ec target
4646

47+
RUN: llvm-dlltool -m arm64ec -d test.def -l test3.lib
48+
RUN: llvm-readobj test3.lib | FileCheck --check-prefix=ALIAS %s
49+
50+
ALIAS: File: test.dll
51+
ALIAS-NEXT: Format: COFF-import-file-ARM64EC
52+
ALIAS-NEXT: Type: code
53+
ALIAS-NEXT: Name type: export as
54+
ALIAS-NEXT: Export name: func
55+
ALIAS-NEXT: Symbol: __imp_func
56+
ALIAS-NEXT: Symbol: func
57+
ALIAS-NEXT: Symbol: __imp_aux_func
58+
ALIAS-NEXT: Symbol: #func
59+
4760
#--- test.def
4861
LIBRARY test.dll
4962
EXPORTS
@@ -53,3 +66,8 @@ EXPORTS
5366
LIBRARY test.dll
5467
EXPORTS
5568
otherfunc
69+
70+
#--- test3.def
71+
LIBRARY test.dll
72+
EXPORTS
73+
func == efunc

0 commit comments

Comments
 (0)