Skip to content

Commit ba73d70

Browse files
committed
[llvm-dlltool] Use EXPORTAS name type for renamed imports on ARM64EC.
1 parent 45c0dec commit ba73d70

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,29 @@ 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 test3.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: efunc
55+
ALIAS-NEXT: Symbol: __imp_func
56+
ALIAS-NEXT: Symbol: func
57+
ALIAS-NEXT: Symbol: __imp_aux_func
58+
ALIAS-NEXT: Symbol: #func
59+
ALIAS-EMPTY:
60+
ALIAS-NEXT: File: test.dll
61+
ALIAS-NEXT: Format: COFF-import-file-ARM64EC
62+
ALIAS-NEXT: Type: code
63+
ALIAS-NEXT: Name type: export as
64+
ALIAS-NEXT: Export name: efunc
65+
ALIAS-NEXT: Symbol: __imp_efunc
66+
ALIAS-NEXT: Symbol: efunc
67+
ALIAS-NEXT: Symbol: __imp_aux_efunc
68+
ALIAS-NEXT: Symbol: #efunc
69+
4770
#--- test.def
4871
LIBRARY test.dll
4972
EXPORTS
@@ -53,3 +76,9 @@ EXPORTS
5376
LIBRARY test.dll
5477
EXPORTS
5578
otherfunc
79+
80+
#--- test3.def
81+
LIBRARY test.dll
82+
EXPORTS
83+
func == efunc
84+
efunc

0 commit comments

Comments
 (0)