summaryrefslogtreecommitdiff
path: root/lld/COFF/Driver.h
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2018-08-30 08:25:34 +0000
committerHans Wennborg <hans@hanshq.net>2018-08-30 08:25:34 +0000
commitad4963df8483e65a34865c30ab5811965df5b42c (patch)
tree0d3354b3fbf0d5a72b35230ff1257ffb55d9619c /lld/COFF/Driver.h
parentcde357f31846b63e03b52f92db77aa47c09a73fe (diff)
Merging r338877, r338911 and r339165:
------------------------------------------------------------------------ r338877 | nico | 2018-08-03 14:00:12 +0200 (Fri, 03 Aug 2018) | 19 lines lld-link: Fix subsystem inference for non-console apps on 32-bit, and fix entry point inference on 32-bit with /nodefaultlib LinkerDriver::inferSubsystem() used to do Symtab->findUnderscore("WinMain"), but WinMain is stdcall in 32-bit and is hence is called _WinMain@16. Instead, Symtab->findMangle(mangle("WinMain")) needs to be called. But since LinkerDriver::inferSubsystem() and LinkerDriver::findDefaultEntry() both need to call this, introduce a common helper function for this and call it from both places. (Also call it for "main" for consistency, even though findUnderscore() is enough for main since that's __cdecl on 32-bit). This also exposed a bug for /nodefaultlib entrypoint inference: The code here called findMangle(Sym) instead of findMangle(mangle(Sym)), again doing the wrong thing on 32-bit. Fix that too. While here, make Driver::mangle() a static free function. https://reviews.llvm.org/D50184 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r338911 | nico | 2018-08-03 20:32:44 +0200 (Fri, 03 Aug 2018) | 7 lines lld-link: Simplify LinkerDriver::findDefaultEntry() No intended behavior change. Not repeating the CRTStartup names makes fixing PR36523 simpler. https://reviews.llvm.org/D50253 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r339165 | nico | 2018-08-07 21:10:28 +0200 (Tue, 07 Aug 2018) | 26 lines 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 ------------------------------------------------------------------------
Diffstat (limited to 'lld/COFF/Driver.h')
-rw-r--r--lld/COFF/Driver.h1
1 files changed, 0 insertions, 1 deletions
diff --git a/lld/COFF/Driver.h b/lld/COFF/Driver.h
index 627e991a902..44bc3ba943d 100644
--- a/lld/COFF/Driver.h
+++ b/lld/COFF/Driver.h
@@ -103,7 +103,6 @@ private:
std::set<std::string> VisitedLibs;
Symbol *addUndefined(StringRef Sym);
- StringRef mangle(StringRef Sym);
// Windows specific -- "main" is not the only main function in Windows.
// You can choose one from these four -- {w,}{WinMain,main}.