diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp --- a/lld/COFF/DriverUtils.cpp +++ b/lld/COFF/DriverUtils.cpp @@ -88,10 +88,10 @@ void parseVersion(StringRef arg, uint32_t *major, uint32_t *minor) { StringRef s1, s2; std::tie(s1, s2) = arg.split('.'); - if (s1.getAsInteger(0, *major)) + if (s1.getAsInteger(10, *major)) fatal("invalid number: " + s1); *minor = 0; - if (!s2.empty() && s2.getAsInteger(0, *minor)) + if (!s2.empty() && s2.getAsInteger(10, *minor)) fatal("invalid number: " + s2); } diff --git a/lld/test/COFF/subsystem.test b/lld/test/COFF/subsystem.test --- a/lld/test/COFF/subsystem.test +++ b/lld/test/COFF/subsystem.test @@ -12,6 +12,10 @@ # RUN: %p/Inputs/ret42.obj # RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=CHECK2 %s +# RUN: lld-link /entry:main /out:%t.exe /subsystem:windows,8.09 \ +# RUN: %p/Inputs/ret42.obj +# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=CHECK2 %s + CHECK2: MajorOperatingSystemVersion: 8 CHECK2: MinorOperatingSystemVersion: 9 CHECK2: MajorSubsystemVersion: 8 diff --git a/lld/test/COFF/version.test b/lld/test/COFF/version.test --- a/lld/test/COFF/version.test +++ b/lld/test/COFF/version.test @@ -17,3 +17,9 @@ CHECK2: MajorImageVersion: 11 CHECK2: MinorImageVersion: 22 + +# RUN: lld-link /out:%t.exe /entry:main %t.obj /version:8.09 +# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=CHECK3 %s + +CHECK3: MajorImageVersion: 8 +CHECK3: MinorImageVersion: 9