[COFF] Do MinGW specific entry/subsystem inference
authorMartin Storsjo <martin@martin.st>
Fri, 5 Oct 2018 19:43:24 +0000 (19:43 +0000)
committerMartin Storsjo <martin@martin.st>
Fri, 5 Oct 2018 19:43:24 +0000 (19:43 +0000)
commit08ab568aaaaab16b68453a0f16e7ee5853ccdd5d
treec297cbd4c5cb9e9acb9b45644b0d8cc956009cc2
parentdb9148d21dec584a5555f67da427f71e998cb611
[COFF] Do MinGW specific entry/subsystem inference

ld.bfd doesn't do any inference of subsystem; unless the windows
subsystem is specified, the console subsystem is used.

For the console subsystem, the entry point is called mainCRTStartup,
regardless of whether the the user code entry point is main or wmain.
The same goes for the windows subsystem, where the entry point always
is WinMainCRTStartup, for both WinMain and wWinMain in user code.

One detail that we don't emulate, is that if the inferred entry point
is undefined, ld.bfd silently just sets the entry point to the start
of the image. And if an explicit entry point is set, but it is
undefined, the link still succeeds but the linker warns about the
entry point not being found.

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

llvm-svn: 343879
lld/COFF/Driver.cpp
lld/test/COFF/entry-inference-mingw.s [new file with mode: 0644]
lld/test/COFF/subsystem-inference-mingw.s [new file with mode: 0644]