[llvm] [llvm-dlltool] Respect the DATA flag when creating aliases (PR #98225)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 9 14:28:57 PDT 2024


https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/98225

None

>From ea041bd6df7bebad5fe657c21e75260bd2bb7bc5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Tue, 9 Jul 2024 15:13:03 +0300
Subject: [PATCH] [llvm-dlltool] Respect the DATA flag when creating aliases

---
 llvm/lib/Object/COFFImportFile.cpp                 | 3 ++-
 llvm/test/tools/llvm-dlltool/coff-weak-exports.def | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Object/COFFImportFile.cpp b/llvm/lib/Object/COFFImportFile.cpp
index fd8aca393e90b..8c366db71523c 100644
--- a/llvm/lib/Object/COFFImportFile.cpp
+++ b/llvm/lib/Object/COFFImportFile.cpp
@@ -691,7 +691,8 @@ Error writeImportLibrary(StringRef ImportName, StringRef Path,
       }
 
       if (!E.ImportName.empty() && Name != E.ImportName) {
-        Members.push_back(OF.createWeakExternal(E.ImportName, Name, false, M));
+        if (ImportType == IMPORT_CODE)
+          Members.push_back(OF.createWeakExternal(E.ImportName, Name, false, M));
         Members.push_back(OF.createWeakExternal(E.ImportName, Name, true, M));
         continue;
       }
diff --git a/llvm/test/tools/llvm-dlltool/coff-weak-exports.def b/llvm/test/tools/llvm-dlltool/coff-weak-exports.def
index dacc5f73530fd..67f0013bf170f 100644
--- a/llvm/test/tools/llvm-dlltool/coff-weak-exports.def
+++ b/llvm/test/tools/llvm-dlltool/coff-weak-exports.def
@@ -6,6 +6,7 @@
 LIBRARY test.dll
 EXPORTS
 TestFunction==AltTestFunction
+TestData DATA == AltTestData
 ; When creating an import library, the DLL internal function name of
 ; the implementation of a function isn't visible at all.
 ImpLibName = Implementation
@@ -20,6 +21,9 @@ ImpLibName3 = kernel32.Sleep
 ; CHECK-NEXT: W TestFunction
 ; CHECK:      U __imp_AltTestFunction
 ; CHECK-NEXT: W __imp_TestFunction
+; CHECK-NOT:  W TestData
+; CHECK:      U __imp_AltTestData
+; CHECK-NEXT: W __imp_TestData
 ; CHECK:      T ImpLibName
 ; CHECK-NEXT: T __imp_ImpLibName
 ; CHECK:      U AltTestFunction2



More information about the llvm-commits mailing list