[PATCH] D50184: lld-link: Fix subsystem inference for non-console apps on 32-bit, an dfix entry point inference on 32-bit with /nodefaultlib

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 2 07:00:26 PDT 2018


thakis created this revision.
thakis added a reviewer: ruiu.

LinkerDriver::inferSubsystem() used to do Symtab->findUnderscore("WinMain"), but WinMain is stdcall in 32-bit and is hence is called _WinMain at 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.


https://reviews.llvm.org/D50184

Files:
  COFF/Driver.cpp
  COFF/Driver.h
  test/COFF/entry-inference3.test
  test/COFF/entry-inference332.test
  test/COFF/subsystem-inference32.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50184.158748.patch
Type: text/x-patch
Size: 7629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180802/cf85fdc9/attachment.bin>


More information about the llvm-commits mailing list