Index: MinGW/Driver.cpp =================================================================== --- MinGW/Driver.cpp +++ MinGW/Driver.cpp @@ -127,8 +127,13 @@ Add("lld-link"); - if (auto *A = Args.getLastArg(OPT_entry)) - Add("-entry:" + StringRef(A->getValue())); + if (auto *A = Args.getLastArg(OPT_entry)) { + if (Args.getLastArgValue(OPT_m) == "i386pe" && A->getValue()[0] == '_') + Add("-entry:" + StringRef(A->getValue()).substr(1)); + else + Add("-entry:" + StringRef(A->getValue())); + } + if (auto *A = Args.getLastArg(OPT_subs)) Add("-subsystem:" + StringRef(A->getValue())); if (auto *A = Args.getLastArg(OPT_outlib)) Index: test/MinGW/driver.s =================================================================== --- test/MinGW/driver.s +++ test/MinGW/driver.s @@ -54,6 +54,9 @@ # CHECK-IMPLIB: Symbol: __imp_exportfn3 # CHECK-IMPLIB: Symbol: exportfn3 +# RUN: ld.lld -shared -m i386pe -e _DllMainCRTStartup@12 %t.obj -o %t.dll -### | FileCheck %s -check-prefix CHECK-I386-ENTRY +# CHECK-I386-ENTRY: lld-link -entry:DllMainCRTStartup@12 + .global main .text main: