Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

cjacek
Copy link
Contributor

@cjacek cjacek commented Feb 3, 2025

For consistency with input def handling.

For consistency with input def handling.
@cjacek
Copy link
Contributor Author

cjacek commented Feb 3, 2025

Since this is a MinGW extension, we define its meaning. Other command-line arguments apply either to the EC symbol table or both, so for consistency, we should use the EC symbol table.

For the input DEF file, a new command-line option, -defarm64native, specifies the native symbol table instead. We could introduce a similar option for the output DEF file, but I’m not sure it’s necessary. My suggestion is to skip it for now and add it later if there’s demand.

@llvmbot
Copy link
Member

llvmbot commented Feb 3, 2025

@llvm/pr-subscribers-lld-coff
@llvm/pr-subscribers-lld

@llvm/pr-subscribers-platform-windows

Author: Jacek Caban (cjacek)

Changes

For consistency with input def handling.


Full diff: https://github.com/llvm/llvm-project/pull/125531.diff

2 Files Affected:

  • (modified) lld/COFF/Driver.cpp (+1-1)
  • (modified) lld/test/COFF/arm64x-export.test (+5-1)
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.
 

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable overall; yes, let's not invent new options until we have a known case where we'd need it, and until we have it all settled how we otherwise want things to behave in a mingw context.

The code looks good, but I've got one question on the testcase.

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cjacek cjacek merged commit e596387 into llvm:main Feb 5, 2025
12 checks passed
@cjacek cjacek deleted the arm64x-output-def branch February 5, 2025 11:16
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Mar 8, 2025
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Mar 20, 2025
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Apr 2, 2025
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Apr 17, 2025
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Apr 30, 2025
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request May 15, 2025
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request May 29, 2025
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants