-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LLD][COFF] Set __buildid symbol in both symbol tables on ARM64X #126777
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
Conversation
@llvm/pr-subscribers-lld @llvm/pr-subscribers-platform-windows Author: Jacek Caban (cjacek) ChangesFull diff: https://github.com/llvm/llvm-project/pull/126777.diff 2 Files Affected:
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 484ac9cdcaf9e..b03a4eab16ce2 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -1215,9 +1215,11 @@ void Writer::createMiscChunks() {
// if we're ultimately not going to write CodeView data to the PDB.
buildId = make<CVDebugRecordChunk>(ctx);
debugRecords.emplace_back(COFF::IMAGE_DEBUG_TYPE_CODEVIEW, buildId);
- if (Symbol *buildidSym = ctx.symtab.findUnderscore("__buildid"))
- replaceSymbol<DefinedSynthetic>(buildidSym, buildidSym->getName(),
- buildId, 4);
+ ctx.forEachSymtab([&](SymbolTable &symtab) {
+ if (Symbol *buildidSym = symtab.findUnderscore("__buildid"))
+ replaceSymbol<DefinedSynthetic>(buildidSym, buildidSym->getName(),
+ buildId, 4);
+ });
}
if (config->cetCompat) {
diff --git a/lld/test/COFF/arm64x-buildid.s b/lld/test/COFF/arm64x-buildid.s
new file mode 100644
index 0000000000000..99f50073eaa69
--- /dev/null
+++ b/lld/test/COFF/arm64x-buildid.s
@@ -0,0 +1,14 @@
+# REQUIRES: aarch64
+# RUN: llvm-mc -triple=aarch64-windows -filetype=obj -o %t-arm64.obj %s
+# RUN: llvm-mc -triple=arm64ec-windows -filetype=obj -o %t-arm64ec.obj %s
+
+# RUN: lld-link -machine:arm64x -dll -noentry %t-arm64.obj %t-arm64ec.obj -debug -build-id -Brepro -out:%t.dll
+# RUN: llvm-readobj --hex-dump=.test %t.dll | FileCheck %s
+# CHECK: 0x180003000 3c100000 3c100000
+
+.section .test,"dr"
+.rva __buildid
+
+.section .bss,"bw",discard,__buildid
+.global __buildid
+__buildid:
|
@llvm/pr-subscribers-lld-coff Author: Jacek Caban (cjacek) ChangesFull diff: https://github.com/llvm/llvm-project/pull/126777.diff 2 Files Affected:
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 484ac9cdcaf9e..b03a4eab16ce2 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -1215,9 +1215,11 @@ void Writer::createMiscChunks() {
// if we're ultimately not going to write CodeView data to the PDB.
buildId = make<CVDebugRecordChunk>(ctx);
debugRecords.emplace_back(COFF::IMAGE_DEBUG_TYPE_CODEVIEW, buildId);
- if (Symbol *buildidSym = ctx.symtab.findUnderscore("__buildid"))
- replaceSymbol<DefinedSynthetic>(buildidSym, buildidSym->getName(),
- buildId, 4);
+ ctx.forEachSymtab([&](SymbolTable &symtab) {
+ if (Symbol *buildidSym = symtab.findUnderscore("__buildid"))
+ replaceSymbol<DefinedSynthetic>(buildidSym, buildidSym->getName(),
+ buildId, 4);
+ });
}
if (config->cetCompat) {
diff --git a/lld/test/COFF/arm64x-buildid.s b/lld/test/COFF/arm64x-buildid.s
new file mode 100644
index 0000000000000..99f50073eaa69
--- /dev/null
+++ b/lld/test/COFF/arm64x-buildid.s
@@ -0,0 +1,14 @@
+# REQUIRES: aarch64
+# RUN: llvm-mc -triple=aarch64-windows -filetype=obj -o %t-arm64.obj %s
+# RUN: llvm-mc -triple=arm64ec-windows -filetype=obj -o %t-arm64ec.obj %s
+
+# RUN: lld-link -machine:arm64x -dll -noentry %t-arm64.obj %t-arm64ec.obj -debug -build-id -Brepro -out:%t.dll
+# RUN: llvm-readobj --hex-dump=.test %t.dll | FileCheck %s
+# CHECK: 0x180003000 3c100000 3c100000
+
+.section .test,"dr"
+.rva __buildid
+
+.section .bss,"bw",discard,__buildid
+.global __buildid
+__buildid:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.