[PECOFF] Fix entry point functions selection
authorRui Ueyama <ruiu@google.com>
Wed, 23 Jul 2014 00:57:57 +0000 (00:57 +0000)
committerRui Ueyama <ruiu@google.com>
Wed, 23 Jul 2014 00:57:57 +0000 (00:57 +0000)
commita27bb08e7380151e3ddea3eeff9d618fe25675f7
tree1364844ba28e6f93da4712855f2666b845bbd7ae
parent7e9808f7de23e0136d3c8b5dea7d31d745933454
[PECOFF] Fix entry point functions selection

On Windows there are four "main" functions -- main, wmain, WinMain,
or wWinMain. Their parameter types are diffferent. The standard
library provides four different entry functions (i.e.
{w,}{WinMain,main}CRTStartup) for them. You need to use the right
entry routine for your "main" function.

If you give an /entry option, the specified name is used
unconditionally.

Otherwise, the linker needs to select the right one based on
user-supplied entry point function. This can be done after the
linker reads all the input files.

This patch moves the code to determine the entry point function
from the driver to a virtual input file. It also implements the
correct logic for the entry point function selection.

llvm-svn: 213713
lld/include/lld/ReaderWriter/PECOFFLinkingContext.h
lld/lib/Driver/WinLinkDriver.cpp
lld/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h
lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
lld/lib/ReaderWriter/PECOFF/SetSubsystemPass.h [deleted file]
lld/test/pecoff/Inputs/entry.obj.yaml [new file with mode: 0644]
lld/test/pecoff/Inputs/subsystem.main.yaml
lld/test/pecoff/Inputs/subsystem.winmain.yaml
lld/test/pecoff/alternatename.test
lld/test/pecoff/entry.test
lld/unittests/DriverTests/WinLinkDriverTest.cpp