Skip to content

Commit

Permalink
[MinGW] Pass the undecorated entry point name to the COFF linker
Browse files Browse the repository at this point in the history
On i386, the --entry parameter to GNU ld is supposed to be a decorated
symbol name, while it is an undecorated name in link.exe.

Differential Revision: https://reviews.llvm.org/D37710

llvm-svn: 313066
  • Loading branch information
mstorsjo committed Sep 12, 2017
1 parent 796a13f commit 6d8dace
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lld/MinGW/Driver.cpp
Expand Up @@ -121,8 +121,14 @@ bool mingw::link(ArrayRef<const char *> ArgsArr, raw_ostream &Diag) {

Add("lld-link");

if (auto *A = Args.getLastArg(OPT_entry))
Add("-entry:" + StringRef(A->getValue()));
if (auto *A = Args.getLastArg(OPT_entry)) {
StringRef S = A->getValue();
if (Args.getLastArgValue(OPT_m) == "i386pe" && S.startswith("_"))
Add("-entry:" + S.substr(1));
else
Add("-entry:" + S);
}

if (auto *A = Args.getLastArg(OPT_subs))
Add("-subsystem:" + StringRef(A->getValue()));
if (auto *A = Args.getLastArg(OPT_out_implib))
Expand Down
3 changes: 3 additions & 0 deletions lld/test/MinGW/driver.test
Expand Up @@ -44,3 +44,6 @@ STACK: -stack:4194304,8192

RUN: ld.lld -### foo.o -m i386pep --verbose | FileCheck -check-prefix=VERBOSE %s
VERBOSE: -verbose

RUN: ld.lld -### -shared -m i386pe -e _DllMainCRTStartup@12 foo.o | FileCheck -check-prefix I386-ENTRY %s
I386-ENTRY: -entry:DllMainCRTStartup@12

0 comments on commit 6d8dace

Please sign in to comment.