Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/tools/llvm-readobj/ELFDumper.cpp
Show First 20 Lines • Show All 1,393 Lines • ▼ Show 20 Lines | |||||
ELFDumper<ELFT>::ELFDumper(const object::ELFObjectFile<ELFT> *ObjF, | ELFDumper<ELFT>::ELFDumper(const object::ELFObjectFile<ELFT> *ObjF, | ||||
ScopedPrinter &Writer) | ScopedPrinter &Writer) | ||||
: ObjDumper(Writer), ObjF(ObjF) { | : ObjDumper(Writer), ObjF(ObjF) { | ||||
const ELFFile<ELFT> *Obj = ObjF->getELFFile(); | const ELFFile<ELFT> *Obj = ObjF->getELFFile(); | ||||
for (const Elf_Shdr &Sec : unwrapOrError(Obj->sections())) { | for (const Elf_Shdr &Sec : unwrapOrError(Obj->sections())) { | ||||
switch (Sec.sh_type) { | switch (Sec.sh_type) { | ||||
case ELF::SHT_SYMTAB: | case ELF::SHT_SYMTAB: | ||||
if (DotSymtabSec != nullptr) | if (!DotSymtabSec) | ||||
reportError("Multiple SHT_SYMTAB"); | |||||
DotSymtabSec = &Sec; | DotSymtabSec = &Sec; | ||||
break; | break; | ||||
case ELF::SHT_DYNSYM: | case ELF::SHT_DYNSYM: | ||||
if (DynSymRegion.Size) | if (!DynSymRegion.Size) | ||||
reportError("Multiple SHT_DYNSYM"); | |||||
DynSymRegion = createDRIFrom(&Sec); | DynSymRegion = createDRIFrom(&Sec); | ||||
// This is only used (if Elf_Shdr present)for naming section in GNU style | // This is only used (if Elf_Shdr present)for naming section in GNU style | ||||
DynSymtabName = unwrapOrError(Obj->getSectionName(&Sec)); | DynSymtabName = unwrapOrError(Obj->getSectionName(&Sec)); | ||||
DynamicStringTable = unwrapOrError(Obj->getStringTableForSymtab(Sec)); | DynamicStringTable = unwrapOrError(Obj->getStringTableForSymtab(Sec)); | ||||
grimar: I think the following is more correct:
```
if (!DynSymRegion.Size) {
DynSymRegion =… | |||||
break; | break; | ||||
case ELF::SHT_SYMTAB_SHNDX: | case ELF::SHT_SYMTAB_SHNDX: | ||||
ShndxTable = unwrapOrError(Obj->getSHNDXTable(Sec)); | ShndxTable = unwrapOrError(Obj->getSHNDXTable(Sec)); | ||||
break; | break; | ||||
case ELF::SHT_GNU_versym: | case ELF::SHT_GNU_versym: | ||||
if (SymbolVersionSection != nullptr) | if (!SymbolVersionSection) | ||||
reportError("Multiple SHT_GNU_versym"); | |||||
SymbolVersionSection = &Sec; | SymbolVersionSection = &Sec; | ||||
break; | break; | ||||
case ELF::SHT_GNU_verdef: | case ELF::SHT_GNU_verdef: | ||||
if (SymbolVersionDefSection != nullptr) | if (!SymbolVersionDefSection) | ||||
reportError("Multiple SHT_GNU_verdef"); | |||||
SymbolVersionDefSection = &Sec; | SymbolVersionDefSection = &Sec; | ||||
break; | break; | ||||
case ELF::SHT_GNU_verneed: | case ELF::SHT_GNU_verneed: | ||||
if (SymbolVersionNeedSection != nullptr) | if (!SymbolVersionNeedSection) | ||||
reportError("Multiple SHT_GNU_verneed"); | |||||
SymbolVersionNeedSection = &Sec; | SymbolVersionNeedSection = &Sec; | ||||
break; | break; | ||||
case ELF::SHT_LLVM_CALL_GRAPH_PROFILE: | case ELF::SHT_LLVM_CALL_GRAPH_PROFILE: | ||||
if (DotCGProfileSec != nullptr) | if (!DotCGProfileSec) | ||||
Not Done ReplyInline ActionsDitto. jhenderson: Ditto. | |||||
Not Done ReplyInline ActionsSee D62350. Only dynamic sections are duplicated for partitions. Static symbol table, etc, are still singleton. MaskRay: See D62350. Only dynamic sections are duplicated for partitions.
Static symbol table, etc, are… | |||||
Not Done ReplyInline ActionsThe principle is more general though. For most of these tools, there's no reason why there can't be multiple sections of these other types. jhenderson: The principle is more general though. For most of these tools, there's no reason why there… | |||||
My initial inclination was to do only what was required for partitions, but after thinking about this for a bit, I think it's fine to do this for all sections. Although it means that we'll be ignoring some sections in some cases, that's simply a limitation of our tools and there's nothing wrong with the files themselves. pcc: My initial inclination was to do only what was required for partitions, but after thinking… | |||||
reportError("Multiple .llvm.call-graph-profile"); | |||||
DotCGProfileSec = &Sec; | DotCGProfileSec = &Sec; | ||||
break; | break; | ||||
case ELF::SHT_LLVM_ADDRSIG: | case ELF::SHT_LLVM_ADDRSIG: | ||||
if (DotAddrsigSec != nullptr) | if (!DotAddrsigSec) | ||||
Not Done ReplyInline ActionsDitto. jhenderson: Ditto. | |||||
reportError("Multiple .llvm_addrsig"); | |||||
DotAddrsigSec = &Sec; | DotAddrsigSec = &Sec; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
loadDynamicTable(Obj); | loadDynamicTable(Obj); | ||||
if (opts::Output == opts::GNU) | if (opts::Output == opts::GNU) | ||||
ELFDumperStyle.reset(new GNUStyle<ELFT>(Writer, this)); | ELFDumperStyle.reset(new GNUStyle<ELFT>(Writer, this)); | ||||
▲ Show 20 Lines • Show All 3,535 Lines • Show Last 20 Lines |
I think the following is more correct: