[lld] r363431 - [COFF] Allow setting subsystem versions while inferring the subsystem type implicitly
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 14 10:50:30 PDT 2019
Author: mstorsjo
Date: Fri Jun 14 10:50:29 2019
New Revision: 363431
URL: http://llvm.org/viewvc/llvm-project?rev=363431&view=rev
Log:
[COFF] Allow setting subsystem versions while inferring the subsystem type implicitly
Differential Revision: https://reviews.llvm.org/D63248
Modified:
lld/trunk/COFF/DriverUtils.cpp
lld/trunk/test/COFF/subsystem-inference.test
lld/trunk/test/COFF/subsystem.test
Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=363431&r1=363430&r2=363431&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Fri Jun 14 10:50:29 2019
@@ -114,9 +114,11 @@ void parseSubsystem(StringRef Arg, Windo
uint32_t *Minor) {
StringRef SysStr, Ver;
std::tie(SysStr, Ver) = Arg.split(',');
- *Sys = StringSwitch<WindowsSubsystem>(SysStr.lower())
+ std::string SysStrLower = SysStr.lower();
+ *Sys = StringSwitch<WindowsSubsystem>(SysStrLower)
.Case("boot_application", IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION)
.Case("console", IMAGE_SUBSYSTEM_WINDOWS_CUI)
+ .Case("default", IMAGE_SUBSYSTEM_UNKNOWN)
.Case("efi_application", IMAGE_SUBSYSTEM_EFI_APPLICATION)
.Case("efi_boot_service_driver", IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER)
.Case("efi_rom", IMAGE_SUBSYSTEM_EFI_ROM)
@@ -125,7 +127,7 @@ void parseSubsystem(StringRef Arg, Windo
.Case("posix", IMAGE_SUBSYSTEM_POSIX_CUI)
.Case("windows", IMAGE_SUBSYSTEM_WINDOWS_GUI)
.Default(IMAGE_SUBSYSTEM_UNKNOWN);
- if (*Sys == IMAGE_SUBSYSTEM_UNKNOWN)
+ if (*Sys == IMAGE_SUBSYSTEM_UNKNOWN && SysStrLower != "default")
fatal("unknown subsystem: " + SysStr);
if (!Ver.empty())
parseVersion(Ver, Major, Minor);
Modified: lld/trunk/test/COFF/subsystem-inference.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/subsystem-inference.test?rev=363431&r1=363430&r2=363431&view=diff
==============================================================================
--- lld/trunk/test/COFF/subsystem-inference.test (original)
+++ lld/trunk/test/COFF/subsystem-inference.test Fri Jun 14 10:50:29 2019
@@ -1,6 +1,8 @@
# RUN: sed -e s/ENTRYNAME/main/ %s | yaml2obj > %t.obj
# RUN: lld-link /out:%t.exe %t.obj
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=MAIN %s
+# RUN: lld-link /out:%t.exe %t.obj /subsystem:default,6.0
+# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=MAIN %s
# RUN: sed s/ENTRYNAME/wmain/ %s | yaml2obj > %t.obj
# RUN: lld-link /out:%t.exe %t.obj
@@ -9,6 +11,8 @@
# RUN: sed s/ENTRYNAME/WinMain/ %s | yaml2obj > %t.obj
# RUN: lld-link /out:%t.exe %t.obj
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=WINMAIN %s
+# RUN: lld-link /out:%t.exe %t.obj /subsystem:default,6.0
+# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=WINMAIN %s
# RUN: sed s/ENTRYNAME/wWinMain/ %s | yaml2obj > %t.obj
# RUN: lld-link /out:%t.exe %t.obj
Modified: lld/trunk/test/COFF/subsystem.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/subsystem.test?rev=363431&r1=363430&r2=363431&view=diff
==============================================================================
--- lld/trunk/test/COFF/subsystem.test (original)
+++ lld/trunk/test/COFF/subsystem.test Fri Jun 14 10:50:29 2019
@@ -17,3 +17,12 @@ CHECK2: MinorOperatingSystemVersion: 9
CHECK2: MajorSubsystemVersion: 8
CHECK2: MinorSubsystemVersion: 9
CHECK2: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI
+
+# RUN: lld-link /entry:main /out:%t.exe /subsystem:default,8.9 \
+# RUN: %p/Inputs/ret42.obj
+# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=CHECK3 %s
+
+CHECK3: MajorOperatingSystemVersion: 8
+CHECK3: MinorOperatingSystemVersion: 9
+CHECK3: MajorSubsystemVersion: 8
+CHECK3: MinorSubsystemVersion: 9
More information about the llvm-commits
mailing list