Change ELF tools to allow multiple sections per file.
This is how multi-partition combined output files are going to look. If we
see multiple sections, the tools will just read the first one.
Differential Revision: https://reviews.llvm.org/D62349
llvm-svn: 361869
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 150e98d..fcadf73 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1414,45 +1414,40 @@
for (const Elf_Shdr &Sec : unwrapOrError(Obj->sections())) {
switch (Sec.sh_type) {
case ELF::SHT_SYMTAB:
- if (DotSymtabSec != nullptr)
- reportError("Multiple SHT_SYMTAB");
- DotSymtabSec = &Sec;
+ if (!DotSymtabSec)
+ DotSymtabSec = &Sec;
break;
case ELF::SHT_DYNSYM:
- if (DynSymRegion.Size)
- reportError("Multiple SHT_DYNSYM");
- DynSymRegion = createDRIFrom(&Sec);
- // This is only used (if Elf_Shdr present)for naming section in GNU style
- DynSymtabName = unwrapOrError(Obj->getSectionName(&Sec));
- DynamicStringTable = unwrapOrError(Obj->getStringTableForSymtab(Sec));
+ if (!DynSymRegion.Size) {
+ DynSymRegion = createDRIFrom(&Sec);
+ // This is only used (if Elf_Shdr present)for naming section in GNU
+ // style
+ DynSymtabName = unwrapOrError(Obj->getSectionName(&Sec));
+ DynamicStringTable = unwrapOrError(Obj->getStringTableForSymtab(Sec));
+ }
break;
case ELF::SHT_SYMTAB_SHNDX:
ShndxTable = unwrapOrError(Obj->getSHNDXTable(Sec));
break;
case ELF::SHT_GNU_versym:
- if (SymbolVersionSection != nullptr)
- reportError("Multiple SHT_GNU_versym");
- SymbolVersionSection = &Sec;
+ if (!SymbolVersionSection)
+ SymbolVersionSection = &Sec;
break;
case ELF::SHT_GNU_verdef:
- if (SymbolVersionDefSection != nullptr)
- reportError("Multiple SHT_GNU_verdef");
- SymbolVersionDefSection = &Sec;
+ if (!SymbolVersionDefSection)
+ SymbolVersionDefSection = &Sec;
break;
case ELF::SHT_GNU_verneed:
- if (SymbolVersionNeedSection != nullptr)
- reportError("Multiple SHT_GNU_verneed");
- SymbolVersionNeedSection = &Sec;
+ if (!SymbolVersionNeedSection)
+ SymbolVersionNeedSection = &Sec;
break;
case ELF::SHT_LLVM_CALL_GRAPH_PROFILE:
- if (DotCGProfileSec != nullptr)
- reportError("Multiple .llvm.call-graph-profile");
- DotCGProfileSec = &Sec;
+ if (!DotCGProfileSec)
+ DotCGProfileSec = &Sec;
break;
case ELF::SHT_LLVM_ADDRSIG:
- if (DotAddrsigSec != nullptr)
- reportError("Multiple .llvm_addrsig");
- DotAddrsigSec = &Sec;
+ if (!DotAddrsigSec)
+ DotAddrsigSec = &Sec;
break;
}
}