mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-14 03:29:57 +00:00
f4f5b7eea3
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
40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
# RUN: sed -e s/ENTRYNAME/_mainCRTStartup/ %s | yaml2obj > %t.obj
|
|
# RUN: lld-link /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1
|
|
# RUN: FileCheck %s < %t.log
|
|
|
|
# RUN: sed -e s/ENTRYNAME/?mainCRTStartup@@YAHXZ/ %s | yaml2obj > %t.obj
|
|
# RUN: lld-link /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1
|
|
# RUN: FileCheck %s < %t.log
|
|
|
|
# CHECK: Entry name inferred: _mainCRTStartup
|
|
|
|
--- !COFF
|
|
header:
|
|
Machine: IMAGE_FILE_MACHINE_I386
|
|
Characteristics: []
|
|
sections:
|
|
- Name: .text
|
|
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
|
|
Alignment: 4
|
|
SectionData: B82A000000C3
|
|
symbols:
|
|
- Name: .text
|
|
Value: 0
|
|
SectionNumber: 1
|
|
SimpleType: IMAGE_SYM_TYPE_NULL
|
|
ComplexType: IMAGE_SYM_DTYPE_NULL
|
|
StorageClass: IMAGE_SYM_CLASS_STATIC
|
|
SectionDefinition:
|
|
Length: 6
|
|
NumberOfRelocations: 0
|
|
NumberOfLinenumbers: 0
|
|
CheckSum: 0
|
|
Number: 0
|
|
- Name: "ENTRYNAME"
|
|
Value: 0
|
|
SectionNumber: 1
|
|
SimpleType: IMAGE_SYM_TYPE_NULL
|
|
ComplexType: IMAGE_SYM_DTYPE_NULL
|
|
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
|
|
...
|