Skip to content

Commit 0360f81

Browse files
authored
[LLD][COFF] Infer subsystem from EC symbol table for ARM64X (#122838)
1 parent 80084e9 commit 0360f81

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

lld/COFF/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2351,7 +2351,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
23512351
// and after the early return when just writing an import library.
23522352
if (config->subsystem == IMAGE_SUBSYSTEM_UNKNOWN) {
23532353
llvm::TimeTraceScope timeScope("Infer subsystem");
2354-
config->subsystem = ctx.symtab.inferSubsystem();
2354+
config->subsystem = mainSymtab.inferSubsystem();
23552355
if (config->subsystem == IMAGE_SUBSYSTEM_UNKNOWN)
23562356
Fatal(ctx) << "subsystem must be defined";
23572357
}

lld/test/COFF/subsystem-arm64x.test

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
REQUIRES: aarch64
2+
RUN: split-file %s %t.dir && cd %t.dir
3+
4+
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows main.s -o main-arm64ec.obj
5+
RUN: llvm-mc -filetype=obj -triple=aarch64-windows main.s -o main-arm64.obj
6+
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows winmain.s -o winmain-arm64ec.obj
7+
RUN: llvm-mc -filetype=obj -triple=aarch64-windows winmain.s -o winmain-arm64.obj
8+
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj
9+
RUN: llvm-mc -filetype=obj -triple=aarch64-windows %S/Inputs/loadconfig-arm64.s -o loadconfig-arm64.obj
10+
11+
Check that the subsystem is inferred from EC symbols.
12+
13+
RUN: lld-link -machine:arm64x -entry:entry -out:out.exe main-arm64.obj winmain-arm64ec.obj \
14+
RUN: loadconfig-arm64.obj loadconfig-arm64ec.obj
15+
RUN: llvm-readobj --headers out.exe | FileCheck --check-prefix=GUI %s
16+
GUI: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI (0x2)
17+
GUI: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI (0x2)
18+
19+
RUN: lld-link -machine:arm64x -entry:entry -out:out.exe main-arm64ec.obj winmain-arm64.obj \
20+
RUN: loadconfig-arm64.obj loadconfig-arm64ec.obj
21+
RUN: llvm-readobj --headers out.exe | FileCheck --check-prefix=CUI %s
22+
CUI: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3)
23+
CUI: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3)
24+
25+
#--- main.s
26+
.globl "#main"
27+
.globl main
28+
.globl entry
29+
"#main":
30+
main:
31+
entry:
32+
ret
33+
34+
#--- winmain.s
35+
.globl "#WinMain"
36+
.globl WinMain
37+
.globl entry
38+
"#WinMain":
39+
WinMain:
40+
entry:
41+
ret

0 commit comments

Comments
 (0)