mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-02 23:26:31 +00:00
[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:
BIN
test/tools/llvm-readobj/Inputs/reginfo.obj.elf-mipsel
Normal file
BIN
test/tools/llvm-readobj/Inputs/reginfo.obj.elf-mipsel
Normal file
Binary file not shown.
10
test/tools/llvm-readobj/mips-reginfo.test
Normal file
10
test/tools/llvm-readobj/mips-reginfo.test
Normal 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: }
|
@@ -58,6 +58,7 @@ public:
|
|||||||
void printAttributes() override;
|
void printAttributes() override;
|
||||||
void printMipsPLTGOT() override;
|
void printMipsPLTGOT() override;
|
||||||
void printMipsABIFlags() override;
|
void printMipsABIFlags() override;
|
||||||
|
void printMipsReginfo() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef ELFFile<ELFT> ELFO;
|
typedef ELFFile<ELFT> ELFO;
|
||||||
@@ -1424,3 +1425,30 @@ template <class ELFT> void ELFDumper<ELFT>::printMipsABIFlags() {
|
|||||||
W.printFlags("Flags 1", Flags->flags1, makeArrayRef(ElfMipsFlags1));
|
W.printFlags("Flags 1", Flags->flags1, makeArrayRef(ElfMipsFlags1));
|
||||||
W.printHex("Flags 2", Flags->flags2);
|
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]);
|
||||||
|
}
|
||||||
|
@@ -43,6 +43,7 @@ public:
|
|||||||
// Only implemented for MIPS ELF at this time.
|
// Only implemented for MIPS ELF at this time.
|
||||||
virtual void printMipsPLTGOT() { }
|
virtual void printMipsPLTGOT() { }
|
||||||
virtual void printMipsABIFlags() { }
|
virtual void printMipsABIFlags() { }
|
||||||
|
virtual void printMipsReginfo() { }
|
||||||
|
|
||||||
// Only implemented for PE/COFF.
|
// Only implemented for PE/COFF.
|
||||||
virtual void printCOFFImports() { }
|
virtual void printCOFFImports() { }
|
||||||
|
@@ -152,6 +152,10 @@ namespace opts {
|
|||||||
cl::opt<bool> MipsABIFlags("mips-abi-flags",
|
cl::opt<bool> MipsABIFlags("mips-abi-flags",
|
||||||
cl::desc("Display the MIPS.abiflags section"));
|
cl::desc("Display the MIPS.abiflags section"));
|
||||||
|
|
||||||
|
// -mips-reginfo
|
||||||
|
cl::opt<bool> MipsReginfo("mips-reginfo",
|
||||||
|
cl::desc("Display the MIPS .reginfo section"));
|
||||||
|
|
||||||
// -coff-imports
|
// -coff-imports
|
||||||
cl::opt<bool>
|
cl::opt<bool>
|
||||||
COFFImports("coff-imports", cl::desc("Display the PE/COFF import table"));
|
COFFImports("coff-imports", cl::desc("Display the PE/COFF import table"));
|
||||||
@@ -296,6 +300,8 @@ static void dumpObject(const ObjectFile *Obj) {
|
|||||||
Dumper->printMipsPLTGOT();
|
Dumper->printMipsPLTGOT();
|
||||||
if (opts::MipsABIFlags)
|
if (opts::MipsABIFlags)
|
||||||
Dumper->printMipsABIFlags();
|
Dumper->printMipsABIFlags();
|
||||||
|
if (opts::MipsReginfo)
|
||||||
|
Dumper->printMipsReginfo();
|
||||||
}
|
}
|
||||||
if (opts::COFFImports)
|
if (opts::COFFImports)
|
||||||
Dumper->printCOFFImports();
|
Dumper->printCOFFImports();
|
||||||
|
Reference in New Issue
Block a user