Skip to content

Conversation

@cjacek
Copy link
Contributor

@cjacek cjacek commented Mar 3, 2025

Include symbols from both symbol tables.

Include symbols from both symbol tables.
@cjacek
Copy link
Contributor Author

cjacek commented Mar 3, 2025

Similar to -includeoptional from #126300.

@llvmbot
Copy link
Member

llvmbot commented Mar 3, 2025

@llvm/pr-subscribers-lld

@llvm/pr-subscribers-platform-windows

Author: Jacek Caban (cjacek)

Changes

Include symbols from both symbol tables.


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

2 Files Affected:

  • (modified) lld/COFF/Driver.cpp (+2-1)
  • (modified) lld/test/COFF/arm64x-includeoptional.s (+3)
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index b9bde9bb428e6..b60d93d45086e 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -2568,7 +2568,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
 
   // Handle /includeglob
   for (StringRef pat : args::getStrings(args, OPT_incl_glob))
-    ctx.symtab.addUndefinedGlob(pat);
+    ctx.forEachSymtab(
+        [&](SymbolTable &symtab) { symtab.addUndefinedGlob(pat); });
 
   // Create wrapped symbols for -wrap option.
   ctx.forEachSymtab([&](SymbolTable &symtab) {
diff --git a/lld/test/COFF/arm64x-includeoptional.s b/lld/test/COFF/arm64x-includeoptional.s
index bf02075d96779..63b1e89082797 100644
--- a/lld/test/COFF/arm64x-includeoptional.s
+++ b/lld/test/COFF/arm64x-includeoptional.s
@@ -11,6 +11,9 @@
 // RUN: llvm-readobj --hex-dump=.test %t.dll | FileCheck %s
 // CHECK: 0x180004000 01000000 01000000
 
+// RUN: lld-link -machine:arm64x -dll -noentry -out:%t-glob.dll %t-test.lib -includeglob:sym
+// RUN: llvm-readobj --hex-dump=.test %t-glob.dll | FileCheck %s
+
         .globl sym
         .section .test,"dr"
 sym:

@llvmbot
Copy link
Member

llvmbot commented Mar 3, 2025

@llvm/pr-subscribers-lld-coff

Author: Jacek Caban (cjacek)

Changes

Include symbols from both symbol tables.


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

2 Files Affected:

  • (modified) lld/COFF/Driver.cpp (+2-1)
  • (modified) lld/test/COFF/arm64x-includeoptional.s (+3)
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index b9bde9bb428e6..b60d93d45086e 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -2568,7 +2568,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
 
   // Handle /includeglob
   for (StringRef pat : args::getStrings(args, OPT_incl_glob))
-    ctx.symtab.addUndefinedGlob(pat);
+    ctx.forEachSymtab(
+        [&](SymbolTable &symtab) { symtab.addUndefinedGlob(pat); });
 
   // Create wrapped symbols for -wrap option.
   ctx.forEachSymtab([&](SymbolTable &symtab) {
diff --git a/lld/test/COFF/arm64x-includeoptional.s b/lld/test/COFF/arm64x-includeoptional.s
index bf02075d96779..63b1e89082797 100644
--- a/lld/test/COFF/arm64x-includeoptional.s
+++ b/lld/test/COFF/arm64x-includeoptional.s
@@ -11,6 +11,9 @@
 // RUN: llvm-readobj --hex-dump=.test %t.dll | FileCheck %s
 // CHECK: 0x180004000 01000000 01000000
 
+// RUN: lld-link -machine:arm64x -dll -noentry -out:%t-glob.dll %t-test.lib -includeglob:sym
+// RUN: llvm-readobj --hex-dump=.test %t-glob.dll | FileCheck %s
+
         .globl sym
         .section .test,"dr"
 sym:

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 2d0eb5d into llvm:main Mar 3, 2025
15 checks passed
@cjacek cjacek deleted the arm64x-includeglob branch March 3, 2025 21:39
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Jun 13, 2025
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Jul 14, 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