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

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 05:53:41 PDT 2024


Author: Martin Storsjö
Date: 2024-07-11T15:53:37+03:00
New Revision: a3913a19185e3513a317aab792e85d5c50ef0242

URL: https://github.com/llvm/llvm-project/commit/a3913a19185e3513a317aab792e85d5c50ef0242
DIFF: https://github.com/llvm/llvm-project/commit/a3913a19185e3513a317aab792e85d5c50ef0242.diff

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

Added: 
    

Modified: 
    llvm/lib/Object/COFFImportFile.cpp
    llvm/test/tools/llvm-dlltool/coff-weak-exports.def

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Object/COFFImportFile.cpp b/llvm/lib/Object/COFFImportFile.cpp
index fd8aca393e90b..a9f150a965c35 100644
--- a/llvm/lib/Object/COFFImportFile.cpp
+++ b/llvm/lib/Object/COFFImportFile.cpp
@@ -691,7 +691,9 @@ 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