diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 24183e7cbaa34a..2f2d40ba800dc6 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -1098,6 +1098,7 @@ void ObjFile::initSectionsAndLocalSyms(bool ignoreComdats) { if (!firstGlobal) return; SymbolUnion *locals = makeThreadLocalN(firstGlobal); + memset(locals, 0, sizeof(SymbolUnion) * firstGlobal); ArrayRef eSyms = this->getELFSyms(); for (size_t i = 0, end = firstGlobal; i != end; ++i) { @@ -1128,9 +1129,9 @@ void ObjFile::initSectionsAndLocalSyms(bool ignoreComdats) { else new (symbols[i]) Defined(this, name, STB_LOCAL, eSym.st_other, type, eSym.st_value, eSym.st_size, sec); + symbols[i]->partition = 1; symbols[i]->isUsedInRegularObj = true; symbols[i]->auxIdx = -1; - symbols[i]->dynsymIndex = 0; } } diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index aa7ad4d425e62e..e4ec63ac50e956 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -111,7 +111,7 @@ class Symbol { uint8_t symbolKind; // The partition whose dynamic symbol table contains this symbol's definition. - uint8_t partition = 1; + uint8_t partition; // True if this symbol is preemptible at load time. uint8_t isPreemptible : 1; @@ -263,12 +263,8 @@ class Symbol { Symbol(Kind k, InputFile *file, StringRef name, uint8_t binding, uint8_t stOther, uint8_t type) : file(file), nameData(name.data()), nameSize(name.size()), type(type), - binding(binding), stOther(stOther), symbolKind(k), isPreemptible(false), - isUsedInRegularObj(false), used(false), exportDynamic(false), - inDynamicList(false), referenced(false), referencedAfterWrap(false), - traced(false), hasVersionSuffix(false), isInIplt(false), - gotInIgot(false), folded(false), needsTocRestore(false), - scriptDefined(false), dsoProtected(false) {} + binding(binding), stOther(stOther), symbolKind(k), + exportDynamic(false) {} void overwrite(Symbol &sym, Kind k) const { if (sym.traced) @@ -307,7 +303,7 @@ class Symbol { // Temporary flags used to communicate which symbol entries need PLT and GOT // entries during postScanRelocations(); - std::atomic flags = 0; + std::atomic flags; // A symAux index used to access GOT/PLT entry indexes. This is allocated in // postScanRelocations(). @@ -551,11 +547,11 @@ union SymbolUnion { }; template Defined *makeDefined(T &&...args) { - auto *sym = new (reinterpret_cast( - getSpecificAllocSingleton().Allocate())) - Defined(std::forward(args)...); - sym->auxIdx = -1; - return sym; + auto *sym = getSpecificAllocSingleton().Allocate(); + memset(sym, 0, sizeof(Symbol)); + auto &s = *new (reinterpret_cast(sym)) Defined(std::forward(args)...); + s.auxIdx = -1; + return &s; } void reportDuplicate(const Symbol &sym, const InputFile *newFile,