llvm.org GIT mirror llvm / 3bcfd46
[llvm-readobj] Print MIPS .reginfo section content git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239856 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Atanasyan 5 years ago
5 changed file(s) with 45 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 RUN: llvm-readobj -mips-reginfo %p/Inputs/reginfo.obj.elf-mipsel | FileCheck %s
1
2 CHECK: MIPS RegInfo {
3 CHECK-NEXT: GP: 0x7FEF
4 CHECK-NEXT: General Mask: 0xB00001F6
5 CHECK-NEXT: Co-Proc Mask0: 0x0
6 CHECK-NEXT: Co-Proc Mask1: 0x0
7 CHECK-NEXT: Co-Proc Mask2: 0x0
8 CHECK-NEXT: Co-Proc Mask3: 0x0
9 CHECK-NEXT: }
5757 void printAttributes() override;
5858 void printMipsPLTGOT() override;
5959 void printMipsABIFlags() override;
60 void printMipsReginfo() override;
6061
6162 private:
6263 typedef ELFFile ELFO;
14231424 W.printFlags("Flags 1", Flags->flags1, makeArrayRef(ElfMipsFlags1));
14241425 W.printHex("Flags 2", Flags->flags2);
14251426 }
1427
1428 template void ELFDumper::printMipsReginfo() {
1429 const Elf_Shdr *Shdr = findSectionByName(*Obj, ".reginfo");
1430 if (!Shdr) {
1431 W.startLine() << "There is no .reginfo section in the file.\n";
1432 return;
1433 }
1434 ErrorOr> Sec = Obj->getSectionContents(Shdr);
1435 if (!Sec) {
1436 W.startLine() << "The .reginfo section is empty.\n";
1437 return;
1438 }
1439 if (Sec->size() != sizeof(Elf_Mips_RegInfo)) {
1440 W.startLine() << "The .reginfo section has a wrong size.\n";
1441 return;
1442 }
1443
1444 auto *Reginfo = reinterpret_cast *>(Sec->data());
1445
1446 DictScope GS(W, "MIPS RegInfo");
1447 W.printHex("GP", Reginfo->ri_gp_value);
1448 W.printHex("General Mask", Reginfo->ri_gprmask);
1449 W.printHex("Co-Proc Mask0", Reginfo->ri_cprmask[0]);
1450 W.printHex("Co-Proc Mask1", Reginfo->ri_cprmask[1]);
1451 W.printHex("Co-Proc Mask2", Reginfo->ri_cprmask[2]);
1452 W.printHex("Co-Proc Mask3", Reginfo->ri_cprmask[3]);
1453 }
4242 // Only implemented for MIPS ELF at this time.
4343 virtual void printMipsPLTGOT() { }
4444 virtual void printMipsABIFlags() { }
45 virtual void printMipsReginfo() { }
4546
4647 // Only implemented for PE/COFF.
4748 virtual void printCOFFImports() { }
150150 // -mips-abi-flags
151151 cl::opt MipsABIFlags("mips-abi-flags",
152152 cl::desc("Display the MIPS.abiflags section"));
153
154 // -mips-reginfo
155 cl::opt MipsReginfo("mips-reginfo",
156 cl::desc("Display the MIPS .reginfo section"));
153157
154158 // -coff-imports
155159 cl::opt
295299 Dumper->printMipsPLTGOT();
296300 if (opts::MipsABIFlags)
297301 Dumper->printMipsABIFlags();
302 if (opts::MipsReginfo)
303 Dumper->printMipsReginfo();
298304 }
299305 if (opts::COFFImports)
300306 Dumper->printCOFFImports();