llvm-project/lld/COFF
Nico Weber f4f5b7eea3 lld-link: Take /SUBSYSTEM into account for automatic /ENTRY detection.
If /subsystem:windows is passed, link.exe only looks for WinMain and wWinMain,
and if /subsystem:console is passed it only looks for main and wmain. lld-link
used to look for all 4 in both cases. This patch makes lld-link match
link.exe's behavior.

This requires that the subsystem is known by the time findDefaultEntry() gets
called. findDefaultEntry() is called before the main link loop, so that the
loop can mark the entry point as undefined. That means inferSubsystem() has to
be called above the main loop as well. This in turn means /subsystem: from
.drectve sections only has an effect on entry point inference for obj files
passed to lld-link directly (and not in obj files found later in .lib files).
link.exe seems to ignore /subsystem: for obj files from lib files completely
(while in lld it's ignored only for entry point detection but it still
overrides /subsystem: flags passed on the command line for the value that gets
written in the output file).

Also, if the subsytem isn't needed (e.g. when only writing a /def: lib file and
not writing a coff file), link.exe doesn't complain if the subsystem isn't
known, so both subsystem and entry point handling should be below the early
return lld has for that case.

Fixes PR36523.
https://reviews.llvm.org/D50316

llvm-svn: 339165
2018-08-07 19:10:28 +00:00
..
CMakeLists.txt Merge {COFF,ELF}/Strings.cpp to Common/Strings.cpp. 2018-02-28 17:38:19 +00:00
Chunks.cpp [COFF] report file containing unsupported relocation 2018-06-07 00:50:03 +00:00
Chunks.h COFF: Preserve section type when processing /section flag. 2018-04-20 21:23:16 +00:00
Config.h [PDB] Add PDBSourcePath flag to support absolutize source file path 2018-07-19 04:56:22 +00:00
DLL.cpp Consistent (non) use of empty lines in include blocks 2018-02-20 21:53:18 +00:00
DLL.h COFF: Process /merge flag as we create output sections. 2018-04-07 00:46:55 +00:00
Driver.cpp lld-link: Take /SUBSYSTEM into account for automatic /ENTRY detection. 2018-08-07 19:10:28 +00:00
Driver.h lld-link: Fix subsystem inference for non-console apps on 32-bit, and fix entry point inference on 32-bit with /nodefaultlib 2018-08-03 12:00:12 +00:00
DriverUtils.cpp lld-link: Remove /msvclto option 2018-08-01 19:00:49 +00:00
ICF.cpp Make ICF log output order deterministic. 2018-07-31 18:04:58 +00:00
ICF.h Consistent use of header file for ICF and MarkLive 2018-02-20 22:09:59 +00:00
InputFiles.cpp [COFF] Treat .xdata/.pdata$<sym> as implicitly associative to <sym> for MinGW 2018-08-06 21:26:09 +00:00
InputFiles.h [COFF] Treat .xdata/.pdata$<sym> as implicitly associative to <sym> for MinGW 2018-08-06 21:26:09 +00:00
LTO.cpp Code cleanup in preparation for adding LTO for wasm. NFC. 2018-05-22 20:20:25 +00:00
LTO.h Code cleanup in preparation for adding LTO for wasm. NFC. 2018-05-22 20:20:25 +00:00
MapFile.cpp COFF: Move assignment of section RVAs to assignAddresses(). NFCI. 2018-03-15 21:13:46 +00:00
MapFile.h COFF: Change the /lldmap output format to be more like the ELF linker. 2017-01-14 03:14:46 +00:00
MarkLive.cpp COFF: Don't create unnecessary thunks. 2018-05-10 19:01:28 +00:00
MarkLive.h Consistent use of header file for ICF and MarkLive 2018-02-20 22:09:59 +00:00
MinGW.cpp COFF: Rename Chunk::getPermissions to getOutputCharacteristics. 2018-04-19 20:03:24 +00:00
MinGW.h [COFF] Avoid forward declaring StringSet, fix build 2017-10-19 20:19:16 +00:00
Options.td lld-link: Remove /msvclto option 2018-08-01 19:00:49 +00:00
PDB.cpp [PDB] Add PDBSourcePath flag to support absolutize source file path 2018-07-19 04:56:22 +00:00
PDB.h COFF: Friendlier undefined symbol errors. 2018-04-17 23:32:33 +00:00
README.md Update the documents of the new LLD. 2016-03-12 06:06:40 +00:00
SymbolTable.cpp Set IsUsedInRegularObj in a consistent manor between COFF, ELF and wasm. NFC 2018-08-02 20:39:19 +00:00
SymbolTable.h Set IsUsedInRegularObj in a consistent manor between COFF, ELF and wasm. NFC 2018-08-02 20:39:19 +00:00
Symbols.cpp COFF: Don't create unnecessary thunks. 2018-05-10 19:01:28 +00:00
Symbols.h [COFF] Fix a comment about automatic resolving of dllimports from within a module. NFC. 2018-08-07 06:42:53 +00:00
Writer.cpp [COFF] Sort .reloc before all other discardable sections 2018-07-20 18:43:35 +00:00
Writer.h COFF: Use (name, output characteristics) as a key when grouping input sections into output sections. 2018-04-20 21:10:33 +00:00

README.md

See docs/NewLLD.rst