[lld] [LLD][COFF] Follow up comments on pr146610 (PR #147152)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 5 14:11:57 PDT 2025
================
@@ -207,10 +207,10 @@ void ArchiveFile::parse() {
// Read the symbol table to construct Lazy objects.
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") {
+ // If an import library provides the DllMain symbol, skip importing it, as
+ // we should be using our own DllMain, not another DLL's DllMain.
+ if (sym.getName() == "__imp_DllMain" || sym.getName() == "DllMain" ||
+ sym.getName() == "_DllMain") {
----------------
mstorsjo wrote:
We shouldn't be testing two different syntaxes, we should only be testing the right one for each architecture. (Otherwise we'd be matching an unrelated symbol on x86_64 too, even if using a symbol named `_DllMain` there also would be kinda odd.) IIRC you can do e.g. `mangle("DllMain")` to get the right symbol name. And the same goes for the `__imp_` form too, on i386 it would be `__imp__DllMain`, so `Twine("__imp_") + mangle("DllMain")` or something along those lines.
https://github.com/llvm/llvm-project/pull/147152
More information about the llvm-commits
mailing list