[lld] [LLD][COFF] Use EC symbol table for output DEF file on ARM64X (PR #125531)

Jacek Caban via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 3 08:45:55 PST 2025


https://github.com/cjacek created https://github.com/llvm/llvm-project/pull/125531

For consistency with input def handling.

>From 778d242307c0061a7008ed3dbb728b05d79ea4cc Mon Sep 17 00:00:00 2001
From: Jacek Caban <jacek at codeweavers.com>
Date: Mon, 3 Feb 2025 17:38:40 +0100
Subject: [PATCH] [LLD][COFF] Use EC symbol table for output DEF file on ARM64X

For consistency with input def handling.
---
 lld/COFF/Driver.cpp              | 2 +-
 lld/test/COFF/arm64x-export.test | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index b848e0d81dfa76..979c0ae4962732 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -2692,7 +2692,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
 
   // Handle /output-def (MinGW specific).
   if (auto *arg = args.getLastArg(OPT_output_def))
-    writeDefFile(ctx, arg->getValue(), ctx.symtab.exports);
+    writeDefFile(ctx, arg->getValue(), mainSymtab.exports);
 
   // Set extra alignment for .comm symbols
   for (auto pair : config->alignComm) {
diff --git a/lld/test/COFF/arm64x-export.test b/lld/test/COFF/arm64x-export.test
index bae40af4585ae1..c83db2a436db50 100644
--- a/lld/test/COFF/arm64x-export.test
+++ b/lld/test/COFF/arm64x-export.test
@@ -14,7 +14,7 @@ RUN: llvm-mc -filetype=obj -triple=aarch64-windows %S/Inputs/loadconfig-arm64.s
 # A command-line export applies only to EC exports.
 
 RUN: lld-link -machine:arm64x -dll -out:out-cmd.dll arm64ec-func.obj arm64-func.obj \
-RUN:          loadconfig-arm64.obj loadconfig-arm64ec.obj -noentry -export:func
+RUN:          loadconfig-arm64.obj loadconfig-arm64ec.obj -noentry -export:func -output-def:out.def
 
 RUN: llvm-objdump -d out-cmd.dll | FileCheck --check-prefix=DISASM-EC %s
 DISASM-EC:      Disassembly of section .text:
@@ -74,6 +74,10 @@ IMPLIB-EC-NEXT: Symbol: func
 IMPLIB-EC-NEXT: Symbol: __imp_aux_func
 IMPLIB-EC-NEXT: Symbol: #func
 
+RUN: FileCheck --check-prefix=OUT-DEF %s < out.def
+OUT-DEF:      EXPORTS
+OUT-DEF-NEXT:     func @1
+
 
 # Export using the EC .drectve section.
 



More information about the llvm-commits mailing list