llvm-capstone/lld/test/COFF/subsystem-inference-mingw.s
Martin Storsjo 08ab568aaa [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
2018-10-05 19:43:24 +00:00

18 lines
401 B
ArmAsm

# REQUIRES: x86
# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.o
# RUN: lld-link -lldmingw %t.o -out:%t.exe
# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s
# CHECK: AddressOfEntryPoint: 0x1001
# CHECK: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3)
.text
.globl foo
.globl mainCRTStartup
foo:
ret
mainCRTStartup:
call foo
ret