[llvm] r373731 - [llvm-readobj] Replace arch-specific ObjDumper methods by the single `printArchSpecificInfo`
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 4 04:59:06 PDT 2019
Author: atanasyan
Date: Fri Oct 4 04:59:06 2019
New Revision: 373731
URL: http://llvm.org/viewvc/llvm-project?rev=373731&view=rev
Log:
[llvm-readobj] Replace arch-specific ObjDumper methods by the single `printArchSpecificInfo`
Initially llvm-readobj supports multiple command line options like
`--arm-attributes` and `--mips-plt-got` for display ELF arch-specific
information. Now all these options are superseded by the
`--arch-specific` one. It makes sense to have a single `printArchSpecificInfo`
method in the base `ObjDumper`, and hide all ELF/target specific details
in the `ELFDumper::printArchSpecificInfo` override.
Differential Revision: https://reviews.llvm.org/D68385
Modified:
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
llvm/trunk/tools/llvm-readobj/ObjDumper.h
llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=373731&r1=373730&r2=373731&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Fri Oct 4 04:59:06 2019
@@ -173,11 +173,7 @@ public:
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 @@ private:
S->sh_entsize, ObjF->getFileName()});
}
+ void printAttributes();
+ void printMipsPLTGOT();
+ void printMipsABIFlags();
+ void printMipsReginfo();
+ void printMipsOptions();
+
std::pair<const Elf_Phdr *, const Elf_Shdr *>
findDynamic(const ELFFile<ELFT> *Obj);
void loadDynamicTable(const ELFFile<ELFT> *Obj);
@@ -2210,6 +2212,23 @@ template <typename ELFT> void ELFDumper<
W.printString("LoadName", SOName);
}
+template <class ELFT> void ELFDumper<ELFT>::printArchSpecificInfo() {
+ const ELFFile<ELFT> *Obj = ObjF->getELFFile();
+ switch (Obj->getHeader()->e_machine) {
+ case EM_ARM:
+ printAttributes();
+ break;
+ case EM_MIPS:
+ printMipsABIFlags();
+ printMipsOptions();
+ printMipsReginfo();
+ printMipsPLTGOT();
+ break;
+ default:
+ break;
+ }
+}
+
template <class ELFT> void ELFDumper<ELFT>::printAttributes() {
W.startLine() << "Attributes not implemented.\n";
}
Modified: llvm/trunk/tools/llvm-readobj/ObjDumper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ObjDumper.h?rev=373731&r1=373730&r2=373731&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ObjDumper.h (original)
+++ llvm/trunk/tools/llvm-readobj/ObjDumper.h Fri Oct 4 04:59:06 2019
@@ -69,15 +69,7 @@ public:
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() { }
Modified: llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp?rev=373731&r1=373730&r2=373731&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp Fri Oct 4 04:59:06 2019
@@ -397,17 +397,6 @@ void reportWarning(Error Err, StringRef
} // 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 @@ static void dumpObject(const ObjectFile
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)
More information about the llvm-commits
mailing list