mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-21 10:42:35 +00:00
lld-link: Emit warning if one each of {main,wmain} and {WinMain,wWinMain} exist and no /subsystem: flag is passed.
Similar to link.exe's LNK4031. https://reviews.llvm.org/D51076 llvm-svn: 340420
This commit is contained in:
parent
7bd9dcffcd
commit
ebc27c4873
@ -449,9 +449,19 @@ StringRef LinkerDriver::findDefaultEntry() {
|
||||
WindowsSubsystem LinkerDriver::inferSubsystem() {
|
||||
if (Config->DLL)
|
||||
return IMAGE_SUBSYSTEM_WINDOWS_GUI;
|
||||
if (findUnderscoreMangle("main") || findUnderscoreMangle("wmain"))
|
||||
bool HaveMain = findUnderscoreMangle("main");
|
||||
bool HaveWMain = findUnderscoreMangle("wmain");
|
||||
bool HaveWinMain = findUnderscoreMangle("WinMain");
|
||||
bool HaveWWinMain = findUnderscoreMangle("wWinMain");
|
||||
if (HaveMain || HaveWMain) {
|
||||
if (HaveWinMain || HaveWWinMain) {
|
||||
warn(std::string("found ") + (HaveMain ? "main" : "wmain") + " and " +
|
||||
(HaveWinMain ? "WinMain" : "wWinMain") +
|
||||
"; defaulting to /subsystem:console");
|
||||
}
|
||||
return IMAGE_SUBSYSTEM_WINDOWS_CUI;
|
||||
if (findUnderscoreMangle("WinMain") || findUnderscoreMangle("wWinMain"))
|
||||
}
|
||||
if (HaveWinMain || HaveWWinMain)
|
||||
return IMAGE_SUBSYSTEM_WINDOWS_GUI;
|
||||
return IMAGE_SUBSYSTEM_UNKNOWN;
|
||||
}
|
||||
|
54
lld/test/COFF/subsystem-inference2.test
Normal file
54
lld/test/COFF/subsystem-inference2.test
Normal file
@ -0,0 +1,54 @@
|
||||
# RUN: yaml2obj %s > %t.obj
|
||||
# RUN: lld-link /out:%t.exe %t.obj 2>&1 | FileCheck -check-prefix=WARN %s
|
||||
# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s
|
||||
|
||||
# WARN: warning: found main and WinMain; defaulting to /subsystem:console
|
||||
# CHECK: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI
|
||||
|
||||
--- !COFF
|
||||
header:
|
||||
Machine: IMAGE_FILE_MACHINE_AMD64
|
||||
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: main
|
||||
Value: 0
|
||||
SectionNumber: 1
|
||||
SimpleType: IMAGE_SYM_TYPE_NULL
|
||||
ComplexType: IMAGE_SYM_DTYPE_NULL
|
||||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
|
||||
- Name: WinMain
|
||||
Value: 0
|
||||
SectionNumber: 1
|
||||
SimpleType: IMAGE_SYM_TYPE_NULL
|
||||
ComplexType: IMAGE_SYM_DTYPE_NULL
|
||||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
|
||||
- Name: mainCRTStartup
|
||||
Value: 0
|
||||
SectionNumber: 1
|
||||
SimpleType: IMAGE_SYM_TYPE_NULL
|
||||
ComplexType: IMAGE_SYM_DTYPE_NULL
|
||||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
|
||||
- Name: WinMainCRTStartup
|
||||
Value: 0
|
||||
SectionNumber: 1
|
||||
SimpleType: IMAGE_SYM_TYPE_NULL
|
||||
ComplexType: IMAGE_SYM_DTYPE_NULL
|
||||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
|
||||
...
|
Loading…
x
Reference in New Issue
Block a user