Skip to content

Commit caa49e0

Browse files
committed
fix(plugin): ensure proper DLL export for Windows compatibility
- Added conditional export definition for llvmGetPassPluginInfo to handle MSVC's lack of LLVM_ATTRIBUTE_WEAK. - Included necessary header for compiler support on Windows.
1 parent bba93c6 commit caa49e0

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

passes/src/PassPlugin.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "llvm/Passes/PassBuilder.h"
44
#include "llvm/Passes/PassPlugin.h"
5+
#include "llvm/Support/Compiler.h"
56

67
using namespace llvm;
78
using namespace obfuscator;
@@ -112,6 +113,14 @@ llvm::PassPluginLibraryInfo getObfuscatorPluginInfo() {
112113
};
113114
}
114115

115-
extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo llvmGetPassPluginInfo() {
116+
// On MSVC, LLVM_ATTRIBUTE_WEAK is empty, so the entry point is not exported from the DLL and
117+
// opt/clang cannot resolve llvmGetPassPluginInfo (legacy-plugin error).
118+
#if defined(_MSC_VER)
119+
#define LLVM_OBFUSCATOR_PLUGIN_ABI __declspec(dllexport)
120+
#else
121+
#define LLVM_OBFUSCATOR_PLUGIN_ABI LLVM_ATTRIBUTE_WEAK
122+
#endif
123+
124+
extern "C" LLVM_OBFUSCATOR_PLUGIN_ABI ::llvm::PassPluginLibraryInfo llvmGetPassPluginInfo() {
116125
return getObfuscatorPluginInfo();
117126
}

0 commit comments

Comments
 (0)