Index: tools/llvm-readobj/MachODumper.cpp =================================================================== --- tools/llvm-readobj/MachODumper.cpp +++ tools/llvm-readobj/MachODumper.cpp @@ -39,6 +39,9 @@ void printUnwindInfo() override; private: + template + void printFileHeaders(const MachHeader &Header); + void printSymbol(const SymbolRef &Symbol); void printRelocation(const RelocationRef &Reloc); @@ -205,7 +208,23 @@ } void MachODumper::printFileHeaders() { - W.startLine() << "FileHeaders not implemented.\n"; + if (!Obj->is64Bit()) { + printFileHeaders(Obj->getHeader()); + } else { + printFileHeaders(Obj->getHeader64()); + } +} + +template +void MachODumper::printFileHeaders(const MachHeader &Header) { + DictScope H(W, "MachHeader"); + W.printHex("Magic", Header.magic); + W.printNumber("CpuType", Header.cputype); + W.printNumber("CpuSubtype", Header.cpusubtype); + W.printNumber("FileType", Header.filetype); + W.printNumber("NumOfCommands", Header.ncmds); + W.printNumber("SizeOfCommands", Header.sizeofcmds); + W.printHex("Flags", Header.flags); } void MachODumper::printSections() {