[PATCH] D133627: [Object][COFF] Allow section symbol to be common symbol
Pengxuan Zheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 9 18:16:05 PDT 2022
pzheng created this revision.
pzheng added reviewers: rnk, thieta, thakis, hans, mstorsjo, majnemer.
Herald added a project: All.
pzheng requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
I ran into an lld-link error due to a symbol named ".idata$4" coming from some
static library:
.idata$4 should not refer to special section 0.
Here is the symbol table entry for .idata$4:
Symbol {
Name: .idata$4
Value: 3221225536
Section: IMAGE_SYM_UNDEFINED (0)
BaseType: Null (0x0)
ComplexType: Null (0x0)
StorageClass: Section (0x68)
AuxSymbolCount: 0
}
The symbol .idata$4 is a section symbol (IMAGE_SYM_CLASS_SECTION) and LLD
currently handles it as a regular defined symbol since isCommon() returns false
for this symbol. This results in the error ".idata$4 should not refer to special
section 0" because lld-link asserts that regular defined symbols should not
refer to section 0.
Should this symbol be handled as a common symbol instead? LLVM currently only
allows external symbols (IMAGE_SYM_CLASS_EXTERNAL) to be common
symbols. However, the PE/COFF spec (see section "Section Number Values") does
not seem to mention this restriction. Any thoughts?
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133627
Files:
llvm/include/llvm/Object/COFF.h
Index: llvm/include/llvm/Object/COFF.h
===================================================================
--- llvm/include/llvm/Object/COFF.h
+++ llvm/include/llvm/Object/COFF.h
@@ -379,8 +379,8 @@
}
bool isCommon() const {
- return isExternal() && getSectionNumber() == COFF::IMAGE_SYM_UNDEFINED &&
- getValue() != 0;
+ return (isExternal() || isSection()) &&
+ getSectionNumber() == COFF::IMAGE_SYM_UNDEFINED && getValue() != 0;
}
bool isUndefined() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133627.459243.patch
Type: text/x-patch
Size: 503 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220910/99d25b8a/attachment.bin>
More information about the llvm-commits
mailing list