Skip to content

Commit 205dbe7

Browse files
committed
[LLD] Zero-initialization & explicit set-up of isUsedinRegObject in Symbol class
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. Eventually, the issue was about not handling exported symbols properly, when dealing with defining undefined symbols for COFF linker. It got resolved by explicit setting up the isUsedinRegularObject bit around the ctor invocation of symbol class in replaceSymbol API.
1 parent d4e46f0 commit 205dbe7

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)