RUN: llvm-readobj -A %p/Inputs/abiflags.obj.elf-mips | \
RUN: FileCheck -check-prefix=BE32 %s
+RUN: llvm-readelf -A %p/Inputs/abiflags.obj.elf-mipsel | \
+RUN: FileCheck -check-prefix=GNU-EL64 %s
+RUN: llvm-readelf -A %p/Inputs/abiflags.obj.elf-mips | \
+RUN: FileCheck -check-prefix=GNU-BE32 %s
+
EL64: MIPS ABI Flags {
EL64-NEXT: Version: 0
EL64-NEXT: ISA: MIPS64r5
BE32-NEXT: ]
BE32-NEXT: Flags 2: 0x0
BE32-NEXT: }
+
+GNU-EL64: MIPS ABI Flags Version: 0
+GNU-EL64-EMPTY:
+GNU-EL64-NEXT: ISA: MIPS64r5
+GNU-EL64-NEXT: GPR size: 64
+GNU-EL64-NEXT: CPR1 size: 64
+GNU-EL64-NEXT: CPR2 size: 0
+GNU-EL64-NEXT: FP ABI: Hard float (double precision)
+GNU-EL64-NEXT: ISA Extension: Cavium Networks Octeon3
+GNU-EL64-NEXT: ASEs: DSP, DSPR2, VZ
+GNU-EL64-NEXT: FLAGS 1: 00000001
+GNU-EL64-NEXT: FLAGS 2: 00000000
+
+GNU-BE32: MIPS ABI Flags Version: 0
+GNU-BE32-EMPTY:
+GNU-BE32-NEXT: ISA: MIPS32r2
+GNU-BE32-NEXT: GPR size: 32
+GNU-BE32-NEXT: CPR1 size: 0
+GNU-BE32-NEXT: CPR2 size: 0
+GNU-BE32-NEXT: FP ABI: Soft float
+GNU-BE32-NEXT: ISA Extension: None
+GNU-BE32-NEXT: ASEs: DSP, DSPR2, microMIPS
+GNU-BE32-NEXT: FLAGS 1: 00000001
+GNU-BE32-NEXT: FLAGS 2: 00000000
void printAttributes();
void printMipsPLTGOT();
- void printMipsABIFlags();
void printMipsReginfo();
void printMipsOptions();
virtual void printStackSizeEntry(uint64_t Size, StringRef FuncName) = 0;
virtual void printMipsGOT(const MipsGOTParser<ELFT> &Parser) = 0;
virtual void printMipsPLT(const MipsGOTParser<ELFT> &Parser) = 0;
+ virtual void printMipsABIFlags(const ELFObjectFile<ELFT> *Obj) = 0;
const ELFDumper<ELFT> *dumper() const { return Dumper; }
protected:
void printStackSizeEntry(uint64_t Size, StringRef FuncName) override;
void printMipsGOT(const MipsGOTParser<ELFT> &Parser) override;
void printMipsPLT(const MipsGOTParser<ELFT> &Parser) override;
+ void printMipsABIFlags(const ELFObjectFile<ELFT> *Obj) override;
private:
struct Field {
void printStackSizeEntry(uint64_t Size, StringRef FuncName) override;
void printMipsGOT(const MipsGOTParser<ELFT> &Parser) override;
void printMipsPLT(const MipsGOTParser<ELFT> &Parser) override;
+ void printMipsABIFlags(const ELFObjectFile<ELFT> *Obj) override;
private:
void printRelocation(const ELFO *Obj, Elf_Rela Rel, const Elf_Shdr *SymTab);
printAttributes();
break;
case EM_MIPS:
- printMipsABIFlags();
+ ELFDumperStyle->printMipsABIFlags(ObjF);
printMipsOptions();
printMipsReginfo();
printMipsPLTGOT();
}
}
-template <class ELFT> void ELFDumper<ELFT>::printMipsABIFlags() {
- const ELFFile<ELFT> *Obj = ObjF->getELFFile();
- const Elf_Shdr *Shdr =
- findSectionByName(*Obj, ObjF->getFileName(), ".MIPS.abiflags");
- if (!Shdr) {
- W.startLine() << "There is no .MIPS.abiflags section in the file.\n";
- return;
- }
- ArrayRef<uint8_t> Sec =
- unwrapOrError(ObjF->getFileName(), Obj->getSectionContents(Shdr));
- if (Sec.size() != sizeof(Elf_Mips_ABIFlags<ELFT>)) {
- W.startLine() << "The .MIPS.abiflags section has a wrong size.\n";
- return;
- }
-
- auto *Flags = reinterpret_cast<const Elf_Mips_ABIFlags<ELFT> *>(Sec.data());
-
- raw_ostream &OS = W.getOStream();
- DictScope GS(W, "MIPS ABI Flags");
-
- W.printNumber("Version", Flags->version);
- W.startLine() << "ISA: ";
- if (Flags->isa_rev <= 1)
- OS << format("MIPS%u", Flags->isa_level);
- else
- OS << format("MIPS%ur%u", Flags->isa_level, Flags->isa_rev);
- OS << "\n";
- W.printEnum("ISA Extension", Flags->isa_ext, makeArrayRef(ElfMipsISAExtType));
- W.printFlags("ASEs", Flags->ases, makeArrayRef(ElfMipsASEFlags));
- W.printEnum("FP ABI", Flags->fp_abi, makeArrayRef(ElfMipsFpABIType));
- W.printNumber("GPR size", getMipsRegisterSize(Flags->gpr_size));
- W.printNumber("CPR1 size", getMipsRegisterSize(Flags->cpr1_size));
- W.printNumber("CPR2 size", getMipsRegisterSize(Flags->cpr2_size));
- W.printFlags("Flags 1", Flags->flags1, makeArrayRef(ElfMipsFlags1));
- W.printHex("Flags 2", Flags->flags2);
-}
-
template <class ELFT>
static void printMipsReginfoData(ScopedPrinter &W,
const Elf_Mips_RegInfo<ELFT> &Reginfo) {
}
}
+template <class ELFT>
+void GNUStyle<ELFT>::printMipsABIFlags(const ELFObjectFile<ELFT> *ObjF) {
+ const ELFFile<ELFT> *Obj = ObjF->getELFFile();
+ const Elf_Shdr *Shdr =
+ findSectionByName(*Obj, ObjF->getFileName(), ".MIPS.abiflags");
+ if (!Shdr)
+ return;
+
+ ArrayRef<uint8_t> Sec =
+ unwrapOrError(ObjF->getFileName(), Obj->getSectionContents(Shdr));
+ if (Sec.size() != sizeof(Elf_Mips_ABIFlags<ELFT>))
+ reportError(createError(".MIPS.abiflags section has a wrong size"),
+ ObjF->getFileName());
+
+ auto *Flags = reinterpret_cast<const Elf_Mips_ABIFlags<ELFT> *>(Sec.data());
+
+ OS << "MIPS ABI Flags Version: " << Flags->version << "\n\n";
+ OS << "ISA: MIPS" << int(Flags->isa_level);
+ if (Flags->isa_rev > 1)
+ OS << "r" << int(Flags->isa_rev);
+ OS << "\n";
+ OS << "GPR size: " << getMipsRegisterSize(Flags->gpr_size) << "\n";
+ OS << "CPR1 size: " << getMipsRegisterSize(Flags->cpr1_size) << "\n";
+ OS << "CPR2 size: " << getMipsRegisterSize(Flags->cpr2_size) << "\n";
+ OS << "FP ABI: " << printEnum(Flags->fp_abi, makeArrayRef(ElfMipsFpABIType))
+ << "\n";
+ OS << "ISA Extension: "
+ << printEnum(Flags->isa_ext, makeArrayRef(ElfMipsISAExtType)) << "\n";
+ if (Flags->ases == 0)
+ OS << "ASEs: None\n";
+ else
+ // FIXME: Print each flag on a separate line.
+ OS << "ASEs: " << printFlags(Flags->ases, makeArrayRef(ElfMipsASEFlags))
+ << "\n";
+ OS << "FLAGS 1: " << format_hex_no_prefix(Flags->flags1, 8, false) << "\n";
+ OS << "FLAGS 2: " << format_hex_no_prefix(Flags->flags2, 8, false) << "\n";
+ OS << "\n";
+}
+
template <class ELFT> void LLVMStyle<ELFT>::printFileHeaders(const ELFO *Obj) {
const Elf_Ehdr *E = Obj->getHeader();
{
}
}
}
+
+template <class ELFT>
+void LLVMStyle<ELFT>::printMipsABIFlags(const ELFObjectFile<ELFT> *ObjF) {
+ const ELFFile<ELFT> *Obj = ObjF->getELFFile();
+ const Elf_Shdr *Shdr =
+ findSectionByName(*Obj, ObjF->getFileName(), ".MIPS.abiflags");
+ if (!Shdr) {
+ W.startLine() << "There is no .MIPS.abiflags section in the file.\n";
+ return;
+ }
+ ArrayRef<uint8_t> Sec =
+ unwrapOrError(ObjF->getFileName(), Obj->getSectionContents(Shdr));
+ if (Sec.size() != sizeof(Elf_Mips_ABIFlags<ELFT>)) {
+ W.startLine() << "The .MIPS.abiflags section has a wrong size.\n";
+ return;
+ }
+
+ auto *Flags = reinterpret_cast<const Elf_Mips_ABIFlags<ELFT> *>(Sec.data());
+
+ raw_ostream &OS = W.getOStream();
+ DictScope GS(W, "MIPS ABI Flags");
+
+ W.printNumber("Version", Flags->version);
+ W.startLine() << "ISA: ";
+ if (Flags->isa_rev <= 1)
+ OS << format("MIPS%u", Flags->isa_level);
+ else
+ OS << format("MIPS%ur%u", Flags->isa_level, Flags->isa_rev);
+ OS << "\n";
+ W.printEnum("ISA Extension", Flags->isa_ext, makeArrayRef(ElfMipsISAExtType));
+ W.printFlags("ASEs", Flags->ases, makeArrayRef(ElfMipsASEFlags));
+ W.printEnum("FP ABI", Flags->fp_abi, makeArrayRef(ElfMipsFpABIType));
+ W.printNumber("GPR size", getMipsRegisterSize(Flags->gpr_size));
+ W.printNumber("CPR1 size", getMipsRegisterSize(Flags->cpr1_size));
+ W.printNumber("CPR2 size", getMipsRegisterSize(Flags->cpr2_size));
+ W.printFlags("Flags 1", Flags->flags1, makeArrayRef(ElfMipsFlags1));
+ W.printHex("Flags 2", Flags->flags2);
+}