forked from OSchip/llvm-project
Every symbol now has an Elf_Sym. Simplify. NFC.
llvm-svn: 246581
This commit is contained in:
parent
45a98fffa5
commit
7f37775e56
|
@ -298,43 +298,36 @@ template <class ELFT> void SymbolTableSection<ELFT>::writeTo(uint8_t *Buf) {
|
||||||
for (auto &P : Table.getSymbols()) {
|
for (auto &P : Table.getSymbols()) {
|
||||||
StringRef Name = P.first;
|
StringRef Name = P.first;
|
||||||
Symbol *Sym = P.second;
|
Symbol *Sym = P.second;
|
||||||
|
SymbolBody *Body = Sym->Body;
|
||||||
|
const Elf_Sym &InputSym = cast<ELFSymbolBody<ELFT>>(Body)->Sym;
|
||||||
|
|
||||||
auto *ESym = reinterpret_cast<Elf_Sym *>(Buf);
|
auto *ESym = reinterpret_cast<Elf_Sym *>(Buf);
|
||||||
ESym->st_name = Builder.getOffset(Name);
|
ESym->st_name = Builder.getOffset(Name);
|
||||||
SymbolBody *Body = Sym->Body;
|
|
||||||
|
|
||||||
const SectionChunk<ELFT> *Section = nullptr;
|
const SectionChunk<ELFT> *Section = nullptr;
|
||||||
const Elf_Sym *InputSym = nullptr;
|
|
||||||
OutputSection<ELFT> *Out = nullptr;
|
OutputSection<ELFT> *Out = nullptr;
|
||||||
|
|
||||||
switch (Body->kind()) {
|
switch (Body->kind()) {
|
||||||
case SymbolBody::DefinedRegularKind: {
|
case SymbolBody::DefinedRegularKind:
|
||||||
auto *Def = cast<DefinedRegular<ELFT>>(Body);
|
Section = &cast<DefinedRegular<ELFT>>(Body)->Section;
|
||||||
InputSym = &Def->Sym;
|
|
||||||
Section = &Def->Section;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case SymbolBody::DefinedCommonKind:
|
case SymbolBody::DefinedCommonKind:
|
||||||
InputSym = &cast<ELFSymbolBody<ELFT>>(Body)->Sym;
|
|
||||||
Out = BSSSec;
|
Out = BSSSec;
|
||||||
break;
|
break;
|
||||||
case SymbolBody::UndefinedKind:
|
case SymbolBody::UndefinedKind:
|
||||||
assert(Body->isWeak() && "Should be defined by now");
|
assert(Body->isWeak() && "Should be defined by now");
|
||||||
case SymbolBody::DefinedAbsoluteKind:
|
case SymbolBody::DefinedAbsoluteKind:
|
||||||
InputSym = &cast<ELFSymbolBody<ELFT>>(Body)->Sym;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InputSym) {
|
uint8_t Type = InputSym.getType();
|
||||||
uint8_t Type = InputSym->getType();
|
uint8_t Binding = InputSym.getBinding();
|
||||||
uint8_t Binding = InputSym->getBinding();
|
ESym->setBindingAndType(Binding, Type);
|
||||||
ESym->setBindingAndType(Binding, Type);
|
ESym->st_size = InputSym.st_size;
|
||||||
ESym->st_size = InputSym->st_size;
|
ESym->st_other = InputSym.st_other;
|
||||||
ESym->st_other = InputSym->st_other;
|
if (InputSym.isAbsolute()) {
|
||||||
if (InputSym->isAbsolute()) {
|
ESym->st_shndx = SHN_ABS;
|
||||||
ESym->st_shndx = SHN_ABS;
|
ESym->st_value = InputSym.st_value;
|
||||||
ESym->st_value = InputSym->st_value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Section)
|
if (Section)
|
||||||
|
@ -348,7 +341,7 @@ template <class ELFT> void SymbolTableSection<ELFT>::writeTo(uint8_t *Buf) {
|
||||||
if (auto *C = dyn_cast<DefinedCommon<ELFT>>(Body))
|
if (auto *C = dyn_cast<DefinedCommon<ELFT>>(Body))
|
||||||
VA += C->OffsetInBSS;
|
VA += C->OffsetInBSS;
|
||||||
else
|
else
|
||||||
VA += InputSym->st_value;
|
VA += InputSym.st_value;
|
||||||
ESym->st_value = VA;
|
ESym->st_value = VA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue