[lld] 0360f81 - [LLD][COFF] Infer subsystem from EC symbol table for ARM64X (#122838)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 08:50:23 PST 2025


Author: Jacek Caban
Date: 2025-01-15T17:50:19+01:00
New Revision: 0360f8170afffc0f273203f820ae4d5be7faf3a2

URL: https://github.com/llvm/llvm-project/commit/0360f8170afffc0f273203f820ae4d5be7faf3a2
DIFF: https://github.com/llvm/llvm-project/commit/0360f8170afffc0f273203f820ae4d5be7faf3a2.diff

LOG: [LLD][COFF] Infer subsystem from EC symbol table for ARM64X (#122838)

Added: 
    lld/test/COFF/subsystem-arm64x.test

Modified: 
    lld/COFF/Driver.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index fd88b042184e1c..beb135f08fa3b1 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -2351,7 +2351,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
   // and after the early return when just writing an import library.
   if (config->subsystem == IMAGE_SUBSYSTEM_UNKNOWN) {
     llvm::TimeTraceScope timeScope("Infer subsystem");
-    config->subsystem = ctx.symtab.inferSubsystem();
+    config->subsystem = mainSymtab.inferSubsystem();
     if (config->subsystem == IMAGE_SUBSYSTEM_UNKNOWN)
       Fatal(ctx) << "subsystem must be defined";
   }

diff  --git a/lld/test/COFF/subsystem-arm64x.test b/lld/test/COFF/subsystem-arm64x.test
new file mode 100644
index 00000000000000..68438b6f6f43bc
--- /dev/null
+++ b/lld/test/COFF/subsystem-arm64x.test
@@ -0,0 +1,41 @@
+REQUIRES: aarch64
+RUN: split-file %s %t.dir && cd %t.dir
+
+RUN: llvm-mc -filetype=obj -triple=arm64ec-windows main.s -o main-arm64ec.obj
+RUN: llvm-mc -filetype=obj -triple=aarch64-windows main.s -o main-arm64.obj
+RUN: llvm-mc -filetype=obj -triple=arm64ec-windows winmain.s -o winmain-arm64ec.obj
+RUN: llvm-mc -filetype=obj -triple=aarch64-windows winmain.s -o winmain-arm64.obj
+RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj
+RUN: llvm-mc -filetype=obj -triple=aarch64-windows %S/Inputs/loadconfig-arm64.s -o loadconfig-arm64.obj
+
+Check that the subsystem is inferred from EC symbols.
+
+RUN: lld-link -machine:arm64x -entry:entry -out:out.exe main-arm64.obj winmain-arm64ec.obj \
+RUN:          loadconfig-arm64.obj loadconfig-arm64ec.obj
+RUN: llvm-readobj --headers out.exe | FileCheck --check-prefix=GUI %s
+GUI: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI (0x2)
+GUI: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI (0x2)
+
+RUN: lld-link -machine:arm64x -entry:entry -out:out.exe main-arm64ec.obj winmain-arm64.obj \
+RUN:          loadconfig-arm64.obj loadconfig-arm64ec.obj
+RUN: llvm-readobj --headers out.exe | FileCheck --check-prefix=CUI %s
+CUI: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3)
+CUI: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3)
+
+#--- main.s
+    .globl "#main"
+    .globl main
+    .globl entry
+"#main":
+main:
+entry:
+    ret
+
+#--- winmain.s
+    .globl "#WinMain"
+    .globl WinMain
+    .globl entry
+"#WinMain":
+WinMain:
+entry:
+    ret


        


More information about the llvm-commits mailing list