Skip to content

Commit 45c0dec

Browse files
authored
[LLD] [COFF] Zero-intialization & proper constructor invocation in COFF's Symbol (#98447)
It happened due to lld's COFF linker multiple regression tests failure. It got reliably reproduced after the needed intialization of isUsedinRegularObject bit in the Symbol's ctor, but not handled at replaceSymbol API properly while creating a specific symbol to insert in symbol table. So, now while creating the specific symbol using replaceSymbol, by explicitly setting the value of isUsedinRegularObject to newly created symbol around the ctor call of symbol would solve the regression failure
1 parent 85e7428 commit 45c0dec

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lld/COFF/Symbols.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ class Symbol {
9898
friend SymbolTable;
9999
explicit Symbol(Kind k, StringRef n = "")
100100
: symbolKind(k), isExternal(true), isCOMDAT(false),
101-
writtenToSymtab(false), pendingArchiveLoad(false), isGCRoot(false),
102-
isRuntimePseudoReloc(false), deferUndefined(false), canInline(true),
103-
isWeak(false), nameSize(n.size()),
104-
nameData(n.empty() ? nullptr : n.data()) {
101+
writtenToSymtab(false), isUsedInRegularObj(false),
102+
pendingArchiveLoad(false), isGCRoot(false), isRuntimePseudoReloc(false),
103+
deferUndefined(false), canInline(true), isWeak(false),
104+
nameSize(n.size()), nameData(n.empty() ? nullptr : n.data()) {
105105
assert((!n.empty() || k <= LastDefinedCOFFKind) &&
106106
"If the name is empty, the Symbol must be a DefinedCOFF.");
107107
}
@@ -499,8 +499,10 @@ void replaceSymbol(Symbol *s, ArgT &&... arg) {
499499
assert(static_cast<Symbol *>(static_cast<T *>(nullptr)) == nullptr &&
500500
"Not a Symbol");
501501
bool canInline = s->canInline;
502+
bool isUsedInRegularObj = s->isUsedInRegularObj;
502503
new (s) T(std::forward<ArgT>(arg)...);
503504
s->canInline = canInline;
505+
s->isUsedInRegularObj = isUsedInRegularObj;
504506
}
505507
} // namespace coff
506508

0 commit comments

Comments
 (0)