[llvm] [llvm-dlltool] Use EXPORTAS name type for renamed imports on ARM64EC. (PR #99346)

Jacek Caban via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 21 11:42:35 PDT 2024


https://github.com/cjacek updated https://github.com/llvm/llvm-project/pull/99346

>From fbcf42ba17337049d8250dfd21cefd9bf4b17976 Mon Sep 17 00:00:00 2001
From: Jacek Caban <jacek at codeweavers.com>
Date: Wed, 17 Jul 2024 17:25:05 +0200
Subject: [PATCH 1/2] [llvm-dlltool] Use EXPORTAS name type for renamed imports
 on ARM64EC.

---
 llvm/lib/Object/COFFImportFile.cpp        |  5 ++++-
 llvm/test/tools/llvm-dlltool/arm64ec.test | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Object/COFFImportFile.cpp b/llvm/lib/Object/COFFImportFile.cpp
index 2458a53cb6d54..e67b02405a3a1 100644
--- a/llvm/lib/Object/COFFImportFile.cpp
+++ b/llvm/lib/Object/COFFImportFile.cpp
@@ -729,7 +729,10 @@ Error writeImportLibrary(StringRef ImportName, StringRef Path,
         else if (Machine == IMAGE_FILE_MACHINE_I386 &&
                  applyNameType(IMPORT_NAME_NOPREFIX, Name) == E.ImportName)
           NameType = IMPORT_NAME_NOPREFIX;
-        else if (Name == E.ImportName)
+        else if (isArm64EC(M)) {
+          NameType = IMPORT_NAME_EXPORTAS;
+          ExportName = E.ImportName;
+        } else if (Name == E.ImportName)
           NameType = IMPORT_NAME;
         else {
           Deferred D;
diff --git a/llvm/test/tools/llvm-dlltool/arm64ec.test b/llvm/test/tools/llvm-dlltool/arm64ec.test
index b03b4eaf7b2d0..45142461bfc5e 100644
--- a/llvm/test/tools/llvm-dlltool/arm64ec.test
+++ b/llvm/test/tools/llvm-dlltool/arm64ec.test
@@ -44,6 +44,19 @@ RUN: llvm-nm --print-armap test3.lib | FileCheck --check-prefix=ARMAP2 %s
 RUN: not llvm-dlltool -m arm64 -d test.def -N test2.def -l test4.lib 2>&1 | FileCheck --check-prefix=ERR %s
 ERR: native .def file is supported only on arm64ec target
 
+RUN: llvm-dlltool -m arm64ec -d test3.def -l test3.lib
+RUN: llvm-readobj test3.lib | FileCheck --check-prefix=ALIAS %s
+
+ALIAS:      File: test.dll
+ALIAS-NEXT: Format: COFF-import-file-ARM64EC
+ALIAS-NEXT: Type: code
+ALIAS-NEXT: Name type: export as
+ALIAS-NEXT: Export name: efunc
+ALIAS-NEXT: Symbol: __imp_func
+ALIAS-NEXT: Symbol: func
+ALIAS-NEXT: Symbol: __imp_aux_func
+ALIAS-NEXT: Symbol: #func
+
 #--- test.def
 LIBRARY test.dll
 EXPORTS
@@ -53,3 +66,8 @@ EXPORTS
 LIBRARY test.dll
 EXPORTS
     otherfunc
+
+#--- test3.def
+LIBRARY test.dll
+EXPORTS
+    func == efunc

>From 7fad4094a8f7513a97bf42f0d34fb294f2e1b5c9 Mon Sep 17 00:00:00 2001
From: Jacek Caban <jacek at codeweavers.com>
Date: Sun, 21 Jul 2024 20:40:52 +0200
Subject: [PATCH 2/2] Improve tests

---
 llvm/test/tools/llvm-dlltool/arm64ec.test | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/llvm/test/tools/llvm-dlltool/arm64ec.test b/llvm/test/tools/llvm-dlltool/arm64ec.test
index 45142461bfc5e..4ed0f4a4387d6 100644
--- a/llvm/test/tools/llvm-dlltool/arm64ec.test
+++ b/llvm/test/tools/llvm-dlltool/arm64ec.test
@@ -56,6 +56,16 @@ ALIAS-NEXT: Symbol: __imp_func
 ALIAS-NEXT: Symbol: func
 ALIAS-NEXT: Symbol: __imp_aux_func
 ALIAS-NEXT: Symbol: #func
+ALIAS-EMPTY:
+ALIAS-NEXT: File: test.dll
+ALIAS-NEXT: Format: COFF-import-file-ARM64EC
+ALIAS-NEXT: Type: code
+ALIAS-NEXT: Name type: export as
+ALIAS-NEXT: Export name: efunc
+ALIAS-NEXT: Symbol: __imp_efunc
+ALIAS-NEXT: Symbol: efunc
+ALIAS-NEXT: Symbol: __imp_aux_efunc
+ALIAS-NEXT: Symbol: #efunc
 
 #--- test.def
 LIBRARY test.dll
@@ -71,3 +81,4 @@ EXPORTS
 LIBRARY test.dll
 EXPORTS
     func == efunc
+    efunc



More information about the llvm-commits mailing list