[lld] [LLD][COFF] Pull _load_config_used symbol from both symbol tables on ARM64X (PR #122837)

Jacek Caban via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 08:36:55 PST 2025


https://github.com/cjacek updated https://github.com/llvm/llvm-project/pull/122837

>From 094d1ce6676f778587c625a3614f1606c6705d9e Mon Sep 17 00:00:00 2001
From: Jacek Caban <jacek at codeweavers.com>
Date: Mon, 23 Dec 2024 00:23:46 +0100
Subject: [PATCH] [LLD][COFF] Pull _load_config_used symbol from both symbol
 tables on ARM64X

---
 lld/COFF/Driver.cpp               | 9 ++++++---
 lld/test/COFF/arm64x-loadconfig.s | 5 +++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 6af6b4f7307664..fd88b042184e1c 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -2571,9 +2571,12 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
           ctx.symtab.addLibcall(s);
       }
 
-      // Windows specific -- if __load_config_used can be resolved, resolve it.
-      if (ctx.symtab.findUnderscore("_load_config_used"))
-        ctx.symtab.addGCRoot(ctx.symtab.mangle("_load_config_used"));
+      ctx.forEachSymtab([&](SymbolTable &symtab) {
+        // Windows specific -- if __load_config_used can be resolved, resolve
+        // it.
+        if (symtab.findUnderscore("_load_config_used"))
+          symtab.addGCRoot(symtab.mangle("_load_config_used"));
+      });
 
       if (args.hasArg(OPT_include_optional)) {
         // Handle /includeoptional
diff --git a/lld/test/COFF/arm64x-loadconfig.s b/lld/test/COFF/arm64x-loadconfig.s
index f413adff2868c1..12f7387d9ecdcf 100644
--- a/lld/test/COFF/arm64x-loadconfig.s
+++ b/lld/test/COFF/arm64x-loadconfig.s
@@ -7,6 +7,7 @@
 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows loadconfig-ec.s -o loadconfig-ec.obj
 // RUN: llvm-mc -filetype=obj -triple=aarch64-windows loadconfig-short.s -o loadconfig-short.obj
 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows loadconfig-short.s -o loadconfig-short-arm64ec.obj
+// RUN: llvm-lib -machine:arm64x -out:loadconfig.lib loadconfig.obj loadconfig-ec.obj
 
 // RUN: lld-link -machine:arm64x -out:out-warn.dll -dll -noentry test.obj \
 // RUN:           2>&1 | FileCheck --check-prefixes=WARN-LOADCFG,WARN-EC-LOADCFG %s
@@ -158,6 +159,10 @@
 // BASERELOC-NEXT:     Address: 0x2074
 // BASERELOC-NEXT:   }
 
+// RUN: lld-link -machine:arm64x -out:out-hyb-lib.dll -dll -noentry loadconfig.lib chpe.obj test.obj
+// RUN: llvm-readobj --coff-load-config out-hyb-lib.dll | FileCheck --check-prefix=LOADCFG %s
+// RUN: llvm-readobj --coff-basereloc out-hyb-lib.dll | FileCheck --check-prefix=BASERELOC %s
+
 #--- test.s
         .data
 sym:



More information about the llvm-commits mailing list