Skip to content

[LLD][COFF] Report undefined EC symbols on ARM64X #120311

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
Dec 20, 2024
Merged

Conversation

cjacek
Copy link
Contributor

@cjacek cjacek commented Dec 17, 2024

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Dec 17, 2024

@llvm/pr-subscribers-platform-windows

@llvm/pr-subscribers-lld

Author: Jacek Caban (cjacek)

Changes

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

2 Files Affected:

  • (modified) lld/COFF/Driver.cpp (+4-2)
  • (modified) lld/test/COFF/arm64x-symtab.s (+13)
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index bef55abb7f856e..a4d6b94812d937 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -2727,8 +2727,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
     createECExportThunks();
 
   // Resolve remaining undefined symbols and warn about imported locals.
-  while (ctx.symtab.resolveRemainingUndefines())
-    run();
+  ctx.forEachSymtab([&](SymbolTable &symtab) {
+    while (symtab.resolveRemainingUndefines())
+      run();
+  });
 
   if (errorCount())
     return;
diff --git a/lld/test/COFF/arm64x-symtab.s b/lld/test/COFF/arm64x-symtab.s
index e7beb0287d7ff9..2b269dde61f613 100644
--- a/lld/test/COFF/arm64x-symtab.s
+++ b/lld/test/COFF/arm64x-symtab.s
@@ -6,6 +6,7 @@
 // RUN: llvm-mc -filetype=obj -triple=x86_64-windows sym.s -o sym-x86_64.obj
 // RUN: llvm-mc -filetype=obj -triple=aarch64-windows symref.s -o symref-aarch64.obj
 // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows symref.s -o symref-arm64ec.obj
+// RUN: llvm-mc -filetype=obj -triple=x86_64-windows symref.s -o symref-x86_64.obj
 // RUN: llvm-lib -machine:arm64x -out:sym.lib sym-aarch64.obj sym-arm64ec.obj
 
 // Check that native object files can't reference EC symbols.
@@ -15,6 +16,18 @@
 // UNDEF:      lld-link: error: undefined symbol: sym
 // UNDEF-NEXT: >>> referenced by symref-aarch64.obj:(.data)
 
+// Check that EC object files can't reference native symbols.
+
+// RUN: not lld-link -machine:arm64x -dll -noentry -out:out.dll symref-arm64ec.obj sym-aarch64.obj \
+// RUN:              2>&1 | FileCheck --check-prefix=UNDEFEC %s
+// UNDEFEC:      lld-link: error: undefined symbol: sym
+// UNDEFEC-NEXT: >>> referenced by symref-arm64ec.obj:(.data)
+
+// RUN: not lld-link -machine:arm64x -dll -noentry -out:out.dll symref-x86_64.obj sym-aarch64.obj \
+// RUN:              2>&1 | FileCheck --check-prefix=UNDEFX86 %s
+// UNDEFX86:      lld-link: error: undefined symbol: sym
+// UNDEFX86-NEXT: >>> referenced by symref-x86_64.obj:(.data)
+
 // RUN: not lld-link -machine:arm64x -dll -noentry -out:err2.dll symref-aarch64.obj sym-x86_64.obj \
 // RUN:              2>&1 | FileCheck --check-prefix=UNDEF %s
 

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 21a6dbd into llvm:main Dec 20, 2024
12 checks passed
@cjacek cjacek deleted the arm64x-undef branch December 20, 2024 18:56
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