[lld] r246581 - Every symbol now has an Elf_Sym. Simplify. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 1 13:30:53 PDT 2015
Author: rafael
Date: Tue Sep 1 15:30:52 2015
New Revision: 246581
URL: http://llvm.org/viewvc/llvm-project?rev=246581&view=rev
Log:
Every symbol now has an Elf_Sym. Simplify. NFC.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=246581&r1=246580&r2=246581&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Sep 1 15:30:52 2015
@@ -298,43 +298,36 @@ template <class ELFT> void SymbolTableSe
for (auto &P : Table.getSymbols()) {
StringRef Name = P.first;
Symbol *Sym = P.second;
+ SymbolBody *Body = Sym->Body;
+ const Elf_Sym &InputSym = cast<ELFSymbolBody<ELFT>>(Body)->Sym;
auto *ESym = reinterpret_cast<Elf_Sym *>(Buf);
ESym->st_name = Builder.getOffset(Name);
- SymbolBody *Body = Sym->Body;
const SectionChunk<ELFT> *Section = nullptr;
- const Elf_Sym *InputSym = nullptr;
OutputSection<ELFT> *Out = nullptr;
switch (Body->kind()) {
- case SymbolBody::DefinedRegularKind: {
- auto *Def = cast<DefinedRegular<ELFT>>(Body);
- InputSym = &Def->Sym;
- Section = &Def->Section;
+ case SymbolBody::DefinedRegularKind:
+ Section = &cast<DefinedRegular<ELFT>>(Body)->Section;
break;
- }
case SymbolBody::DefinedCommonKind:
- InputSym = &cast<ELFSymbolBody<ELFT>>(Body)->Sym;
Out = BSSSec;
break;
case SymbolBody::UndefinedKind:
assert(Body->isWeak() && "Should be defined by now");
case SymbolBody::DefinedAbsoluteKind:
- InputSym = &cast<ELFSymbolBody<ELFT>>(Body)->Sym;
break;
}
- if (InputSym) {
- uint8_t Type = InputSym->getType();
- uint8_t Binding = InputSym->getBinding();
- ESym->setBindingAndType(Binding, Type);
- ESym->st_size = InputSym->st_size;
- ESym->st_other = InputSym->st_other;
- if (InputSym->isAbsolute()) {
- ESym->st_shndx = SHN_ABS;
- ESym->st_value = InputSym->st_value;
- }
+ uint8_t Type = InputSym.getType();
+ uint8_t Binding = InputSym.getBinding();
+ ESym->setBindingAndType(Binding, Type);
+ ESym->st_size = InputSym.st_size;
+ ESym->st_other = InputSym.st_other;
+ if (InputSym.isAbsolute()) {
+ ESym->st_shndx = SHN_ABS;
+ ESym->st_value = InputSym.st_value;
}
if (Section)
@@ -348,7 +341,7 @@ template <class ELFT> void SymbolTableSe
if (auto *C = dyn_cast<DefinedCommon<ELFT>>(Body))
VA += C->OffsetInBSS;
else
- VA += InputSym->st_value;
+ VA += InputSym.st_value;
ESym->st_value = VA;
}
More information about the llvm-commits
mailing list