[llvm-readobj] Print MIPS .reginfo section content

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239856 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Simon Atanasyan 2015-06-16 21:47:43 +00:00
parent e2d3e4467e
commit 3bcfd461f6
5 changed files with 45 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,10 @@
RUN: llvm-readobj -mips-reginfo %p/Inputs/reginfo.obj.elf-mipsel | FileCheck %s
CHECK: MIPS RegInfo {
CHECK-NEXT: GP: 0x7FEF
CHECK-NEXT: General Mask: 0xB00001F6
CHECK-NEXT: Co-Proc Mask0: 0x0
CHECK-NEXT: Co-Proc Mask1: 0x0
CHECK-NEXT: Co-Proc Mask2: 0x0
CHECK-NEXT: Co-Proc Mask3: 0x0
CHECK-NEXT: }

View File

@ -58,6 +58,7 @@ public:
void printAttributes() override;
void printMipsPLTGOT() override;
void printMipsABIFlags() override;
void printMipsReginfo() override;
private:
typedef ELFFile<ELFT> ELFO;
@ -1424,3 +1425,30 @@ template <class ELFT> void ELFDumper<ELFT>::printMipsABIFlags() {
W.printFlags("Flags 1", Flags->flags1, makeArrayRef(ElfMipsFlags1));
W.printHex("Flags 2", Flags->flags2);
}
template <class ELFT> void ELFDumper<ELFT>::printMipsReginfo() {
const Elf_Shdr *Shdr = findSectionByName(*Obj, ".reginfo");
if (!Shdr) {
W.startLine() << "There is no .reginfo section in the file.\n";
return;
}
ErrorOr<ArrayRef<uint8_t>> Sec = Obj->getSectionContents(Shdr);
if (!Sec) {
W.startLine() << "The .reginfo section is empty.\n";
return;
}
if (Sec->size() != sizeof(Elf_Mips_RegInfo<ELFT>)) {
W.startLine() << "The .reginfo section has a wrong size.\n";
return;
}
auto *Reginfo = reinterpret_cast<const Elf_Mips_RegInfo<ELFT> *>(Sec->data());
DictScope GS(W, "MIPS RegInfo");
W.printHex("GP", Reginfo->ri_gp_value);
W.printHex("General Mask", Reginfo->ri_gprmask);
W.printHex("Co-Proc Mask0", Reginfo->ri_cprmask[0]);
W.printHex("Co-Proc Mask1", Reginfo->ri_cprmask[1]);
W.printHex("Co-Proc Mask2", Reginfo->ri_cprmask[2]);
W.printHex("Co-Proc Mask3", Reginfo->ri_cprmask[3]);
}

View File

@ -43,6 +43,7 @@ public:
// Only implemented for MIPS ELF at this time.
virtual void printMipsPLTGOT() { }
virtual void printMipsABIFlags() { }
virtual void printMipsReginfo() { }
// Only implemented for PE/COFF.
virtual void printCOFFImports() { }

View File

@ -152,6 +152,10 @@ namespace opts {
cl::opt<bool> MipsABIFlags("mips-abi-flags",
cl::desc("Display the MIPS.abiflags section"));
// -mips-reginfo
cl::opt<bool> MipsReginfo("mips-reginfo",
cl::desc("Display the MIPS .reginfo section"));
// -coff-imports
cl::opt<bool>
COFFImports("coff-imports", cl::desc("Display the PE/COFF import table"));
@ -296,6 +300,8 @@ static void dumpObject(const ObjectFile *Obj) {
Dumper->printMipsPLTGOT();
if (opts::MipsABIFlags)
Dumper->printMipsABIFlags();
if (opts::MipsReginfo)
Dumper->printMipsReginfo();
}
if (opts::COFFImports)
Dumper->printCOFFImports();