[lld] [LLD][COFF] Report undefined EC symbols on ARM64X (PR #120311)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 14:01:33 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lld

Author: Jacek Caban (cjacek)

<details>
<summary>Changes</summary>



---
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
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
 

``````````

</details>


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


More information about the llvm-commits mailing list