[PATCH] D66130: [ELF] Initialize 2 fields of Symbol in SymbolTable::insert
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 02:32:49 PDT 2019
MaskRay created this revision.
MaskRay added reviewers: grimar, peter.smith, ruiu.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
A new symbol is added to elf::symtab in 3 steps:
1. SymbolTable::insert creates a placeholder.
2. Symbol::mergeProperties
3. Symbol::replace
Fields referenced by steps 2) and 3) should be initialized in
SymbolTable::insert. `traced` and `referenced` were missed previously.
This did not cause problems because compilers generated code that
initialized them (bit fields) to 0.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D66130
Files:
ELF/SymbolTable.cpp
ELF/Symbols.h
Index: ELF/Symbols.h
===================================================================
--- ELF/Symbols.h
+++ ELF/Symbols.h
@@ -537,6 +537,8 @@
Symbol old = *this;
memcpy(this, &newSym, newSym.getSymbolSize());
+ // Old fields that are referenced here must be initialized in
+ // SymbolTable::insert.
versionId = old.versionId;
visibility = old.visibility;
isUsedInRegularObj = old.isUsedInRegularObj;
Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -71,6 +71,8 @@
Symbol *sym = reinterpret_cast<Symbol *>(make<SymbolUnion>());
symVector.push_back(sym);
+ // Fields referenced by Symbol::mergeProperties and Symbol::replace must be
+ // initialized here.
sym->setName(name);
sym->symbolKind = Symbol::PlaceholderKind;
sym->versionId = VER_NDX_GLOBAL;
@@ -79,6 +81,8 @@
sym->exportDynamic = false;
sym->inDynamicList = false;
sym->canInline = true;
+ sym->referenced = false;
+ sym->traced = false;
sym->scriptDefined = false;
sym->partition = 1;
return sym;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66130.214787.patch
Type: text/x-patch
Size: 1115 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190813/87d3fbe0/attachment.bin>
More information about the llvm-commits
mailing list