[lld] 8cb3d7b - [LLD][COFF] Emit locally imported EC symbols for ARM64X (#125527)

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 5 01:30:16 PST 2025


Author: Jacek Caban
Date: 2025-02-05T10:30:13+01:00
New Revision: 8cb3d7b41869ab517624d8966aac200c84145daf

URL: https://github.com/llvm/llvm-project/commit/8cb3d7b41869ab517624d8966aac200c84145daf
DIFF: https://github.com/llvm/llvm-project/commit/8cb3d7b41869ab517624d8966aac200c84145daf.diff

LOG: [LLD][COFF] Emit locally imported EC symbols for ARM64X (#125527)

Added: 
    lld/test/COFF/locally-imported-arm64x.s

Modified: 
    lld/COFF/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 2bdaeb58ab432d3..484ac9cdcaf9eaf 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -1191,10 +1191,12 @@ void Writer::createMiscChunks() {
   }
 
   // Create thunks for locally-dllimported symbols.
-  if (!ctx.symtab.localImportChunks.empty()) {
-    for (Chunk *c : ctx.symtab.localImportChunks)
-      rdataSec->addChunk(c);
-  }
+  ctx.forEachSymtab([&](SymbolTable &symtab) {
+    if (!symtab.localImportChunks.empty()) {
+      for (Chunk *c : symtab.localImportChunks)
+        rdataSec->addChunk(c);
+    }
+  });
 
   // Create Debug Information Chunks
   debugInfoSec = config->mingw ? buildidSec : rdataSec;

diff  --git a/lld/test/COFF/locally-imported-arm64x.s b/lld/test/COFF/locally-imported-arm64x.s
new file mode 100644
index 000000000000000..6091af2dfa16708
--- /dev/null
+++ b/lld/test/COFF/locally-imported-arm64x.s
@@ -0,0 +1,32 @@
+// REQUIRES: aarch64
+
+// RUN: llvm-mc -filetype=obj -triple=aarch64-windows %s -o %t.arm64.obj
+// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %s -o %t.arm64ec.obj
+
+// RUN: lld-link -machine:arm64x -dll -noentry %t.arm64.obj %t.arm64ec.obj -out:%t.dll 2>&1 | FileCheck --check-prefix=WARN %s
+// WARN:      lld-link: warning: {{.*}}.arm64.obj: locally defined symbol imported: func
+// WARN-NEXT: lld-link: warning: {{.*}}.arm64ec.obj: locally defined symbol imported: func
+
+// RUN: llvm-readobj --hex-dump=.test %t.dll | FileCheck --check-prefix=TEST %s
+// TEST: 0x180005000 00300000 08300000
+
+// RUN: llvm-readobj --coff-basereloc %t.dll | FileCheck --check-prefix=RELOCS %s
+// RELOCS:      Entry {
+// RELOCS-NEXT:   Type: DIR64
+// RELOCS-NEXT:   Address: 0x3000
+// RELOCS-NEXT: }
+// RELOCS-NEXT: Entry {
+// RELOCS-NEXT:   Type: DIR64
+// RELOCS-NEXT:   Address: 0x3008
+// RELOCS-NEXT: }
+
+// RUN: llvm-readobj --hex-dump=.rdata %t.dll | FileCheck --check-prefix=RDATA %s
+// RDATA: 0x180003000 00100080 01000000 00200080 01000000
+
+    .text
+    .globl func
+func:
+    ret
+
+    .section .test, "r"
+    .rva __imp_func


        


More information about the llvm-commits mailing list