[lld] [LLD][COFF] Fix importing DllMain from import libraries (PR #146610)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 3 14:02:37 PDT 2025


================
@@ -176,8 +205,17 @@ void ArchiveFile::parse() {
   }
 
   // Read the symbol table to construct Lazy objects.
-  for (const Archive::Symbol &sym : file->symbols())
+  bool skipDllMain = false;
+  for (const Archive::Symbol &sym : file->symbols()) {
+    // If the DllMain symbol was exported by mistake, skip importing it
+    // otherwise we might end up with a import thunk in the final binary which
+    // is wrong.
+    if (sym.getName() == "__imp_DllMain" || sym.getName() == "DllMain") {
----------------
mstorsjo wrote:

This seems to be missing the relevant prefix handling for i386?

https://github.com/llvm/llvm-project/pull/146610


More information about the llvm-commits mailing list