macho-dump.cpp (218885) | macho-dump.cpp (221337) |
---|---|
1//===-- macho-dump.cpp - Mach Object Dumping Tool -------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 35 unchanged lines hidden (view full) --- 44} 45 46static void Warning(const Twine &Msg) { 47 Message("warning", Msg); 48} 49 50/// 51 | 1//===-- macho-dump.cpp - Mach Object Dumping Tool -------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 35 unchanged lines hidden (view full) --- 44} 45 46static void Warning(const Twine &Msg) { 47 Message("warning", Msg); 48} 49 50/// 51 |
52static int DumpHeader(MachOObject &Obj) { 53 // Read the header. 54 const macho::Header &Hdr = Obj.getHeader(); 55 outs() << "('cputype', " << Hdr.CPUType << ")\n"; 56 outs() << "('cpusubtype', " << Hdr.CPUSubtype << ")\n"; 57 outs() << "('filetype', " << Hdr.FileType << ")\n"; 58 outs() << "('num_load_commands', " << Hdr.NumLoadCommands << ")\n"; 59 outs() << "('load_commands_size', " << Hdr.SizeOfLoadCommands << ")\n"; 60 outs() << "('flag', " << Hdr.Flags << ")\n"; 61 62 // Print extended header if 64-bit. 63 if (Obj.is64Bit()) { 64 const macho::Header64Ext &Hdr64 = Obj.getHeader64Ext(); 65 outs() << "('reserved', " << Hdr64.Reserved << ")\n"; 66 } 67 68 return 0; 69} 70 | |
71static void DumpSegmentCommandData(StringRef Name, 72 uint64_t VMAddr, uint64_t VMSize, 73 uint64_t FileOffset, uint64_t FileSize, 74 uint32_t MaxProt, uint32_t InitProt, 75 uint32_t NumSections, uint32_t Flags) { 76 outs() << " ('segment_name', '"; 77 outs().write_escaped(Name, /*UseHexEscapes=*/true) << "')\n"; 78 outs() << " ('vm_addr', " << VMAddr << ")\n"; --- 292 unchanged lines hidden (view full) --- 371 return Error("unable to read input: '" + ec.message() + "'"); 372 373 // Construct the Mach-O wrapper object. 374 OwningPtr<MachOObject> InputObject( 375 MachOObject::LoadFromBuffer(InputBuffer.take(), &ErrorStr)); 376 if (!InputObject) 377 return Error("unable to load object: '" + ErrorStr + "'"); 378 | 52static void DumpSegmentCommandData(StringRef Name, 53 uint64_t VMAddr, uint64_t VMSize, 54 uint64_t FileOffset, uint64_t FileSize, 55 uint32_t MaxProt, uint32_t InitProt, 56 uint32_t NumSections, uint32_t Flags) { 57 outs() << " ('segment_name', '"; 58 outs().write_escaped(Name, /*UseHexEscapes=*/true) << "')\n"; 59 outs() << " ('vm_addr', " << VMAddr << ")\n"; --- 292 unchanged lines hidden (view full) --- 352 return Error("unable to read input: '" + ec.message() + "'"); 353 354 // Construct the Mach-O wrapper object. 355 OwningPtr<MachOObject> InputObject( 356 MachOObject::LoadFromBuffer(InputBuffer.take(), &ErrorStr)); 357 if (!InputObject) 358 return Error("unable to load object: '" + ErrorStr + "'"); 359 |
379 if (int Res = DumpHeader(*InputObject)) 380 return Res; | 360 // Print the header 361 InputObject->printHeader(outs()); |
381 382 // Print the load commands. 383 int Res = 0; 384 outs() << "('load_commands', [\n"; 385 for (unsigned i = 0; i != InputObject->getHeader().NumLoadCommands; ++i) 386 if ((Res = DumpLoadCommand(*InputObject, i))) 387 break; 388 outs() << "])\n"; 389 390 return Res; 391} | 362 363 // Print the load commands. 364 int Res = 0; 365 outs() << "('load_commands', [\n"; 366 for (unsigned i = 0; i != InputObject->getHeader().NumLoadCommands; ++i) 367 if ((Res = DumpLoadCommand(*InputObject, i))) 368 break; 369 outs() << "])\n"; 370 371 return Res; 372} |