diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -173,11 +173,7 @@ void printVersionInfo() override; void printGroupSections() override; - void printAttributes() override; - void printMipsPLTGOT() override; - void printMipsABIFlags() override; - void printMipsReginfo() override; - void printMipsOptions() override; + void printArchSpecificInfo() override; void printStackMap() const override; @@ -218,6 +214,12 @@ S->sh_entsize, ObjF->getFileName()}); } + void printAttributes(); + void printMipsPLTGOT(); + void printMipsABIFlags(); + void printMipsReginfo(); + void printMipsOptions(); + std::pair findDynamic(const ELFFile *Obj); void loadDynamicTable(const ELFFile *Obj); @@ -2210,6 +2212,23 @@ W.printString("LoadName", SOName); } +template void ELFDumper::printArchSpecificInfo() { + const ELFFile *Obj = ObjF->getELFFile(); + switch (Obj->getHeader()->e_machine) { + case EM_ARM: + printAttributes(); + break; + case EM_MIPS: + printMipsABIFlags(); + printMipsOptions(); + printMipsReginfo(); + printMipsPLTGOT(); + break; + default: + break; + } +} + template void ELFDumper::printAttributes() { W.startLine() << "Attributes not implemented.\n"; } diff --git a/llvm/tools/llvm-readobj/ObjDumper.h b/llvm/tools/llvm-readobj/ObjDumper.h --- a/llvm/tools/llvm-readobj/ObjDumper.h +++ b/llvm/tools/llvm-readobj/ObjDumper.h @@ -69,15 +69,7 @@ virtual void printNotes() {} virtual void printELFLinkerOptions() {} virtual void printStackSizes() {} - - // Only implemented for ARM ELF at this time. - virtual void printAttributes() { } - - // Only implemented for MIPS ELF at this time. - virtual void printMipsPLTGOT() { } - virtual void printMipsABIFlags() { } - virtual void printMipsReginfo() { } - virtual void printMipsOptions() { } + virtual void printArchSpecificInfo() { } // Only implemented for PE/COFF. virtual void printCOFFImports() { } diff --git a/llvm/tools/llvm-readobj/llvm-readobj.cpp b/llvm/tools/llvm-readobj/llvm-readobj.cpp --- a/llvm/tools/llvm-readobj/llvm-readobj.cpp +++ b/llvm/tools/llvm-readobj/llvm-readobj.cpp @@ -397,17 +397,6 @@ } // namespace llvm -static bool isMipsArch(unsigned Arch) { - switch (Arch) { - case llvm::Triple::mips: - case llvm::Triple::mipsel: - case llvm::Triple::mips64: - case llvm::Triple::mips64el: - return true; - default: - return false; - } -} namespace { struct ReadObjTypeTableBuilder { ReadObjTypeTableBuilder() @@ -502,16 +491,8 @@ if (Obj->isELF()) { if (opts::ELFLinkerOptions) Dumper->printELFLinkerOptions(); - if (opts::ArchSpecificInfo) { - if (Obj->getArch() == llvm::Triple::arm) - Dumper->printAttributes(); - else if (isMipsArch(Obj->getArch())) { - Dumper->printMipsABIFlags(); - Dumper->printMipsOptions(); - Dumper->printMipsReginfo(); - Dumper->printMipsPLTGOT(); - } - } + if (opts::ArchSpecificInfo) + Dumper->printArchSpecificInfo(); if (opts::SectionGroups) Dumper->printGroupSections(); if (opts::HashHistogram)