[lld] [LLD][COFF] Skip sections marked as IMAGE_SCN_LNK_INFO in the output image (PR #122752)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 09:39:08 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld
Author: Jacek Caban (cjacek)
<details>
<summary>Changes</summary>
Fixes #<!-- -->106275.
---
Full diff: https://github.com/llvm/llvm-project/pull/122752.diff
2 Files Affected:
- (modified) lld/COFF/InputFiles.cpp (+1-1)
- (added) lld/test/COFF/info-sec.s (+10)
``````````diff
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index a94c984cfd4870..e7891d3e67f3e4 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -355,7 +355,7 @@ SectionChunk *ObjFile::readSection(uint32_t sectionNumber,
MergeChunk::addSection(symtab.ctx, c);
else if (name == ".rsrc" || name.starts_with(".rsrc$"))
resourceChunks.push_back(c);
- else
+ else if (!(sec->Characteristics & llvm::COFF::IMAGE_SCN_LNK_INFO))
chunks.push_back(c);
return c;
diff --git a/lld/test/COFF/info-sec.s b/lld/test/COFF/info-sec.s
new file mode 100644
index 00000000000000..bdc2e4711b4040
--- /dev/null
+++ b/lld/test/COFF/info-sec.s
@@ -0,0 +1,10 @@
+// REQUIRES: x86
+// Check that sections marked as IMAGE_SCN_LNK_INFO are excluded from the output.
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-windows %s -o %t.obj
+// RUN: lld-link -machine:amd64 -dll -noentry %t.obj -out:%t.dll
+// RUN: llvm-readobj --headers %t.dll | FileCheck %s
+// CHECK-NOT: Name: .test
+
+ .section .test,"i"
+ .long 1
``````````
</details>
https://github.com/llvm/llvm-project/pull/122752
More information about the llvm-commits
mailing list