1 //===-- llvm-objdump.h ----------------------------------------------------===// 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 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_OBJDUMP_H 11 #define LLVM_OBJDUMP_H 12 13 #include "llvm/ADT/StringRef.h" 14 #include "llvm/Support/CommandLine.h" 15 #include "llvm/Support/DataTypes.h" 16 #include "llvm/Support/MemoryObject.h" 17 18 namespace llvm { 19 20 namespace object { 21 class COFFObjectFile; 22 class ObjectFile; 23 class RelocationRef; 24 } 25 class error_code; 26 27 extern cl::opt<std::string> TripleName; 28 extern cl::opt<std::string> ArchName; 29 30 // Various helper functions. 31 bool error(error_code ec); 32 bool RelocAddressLess(object::RelocationRef a, object::RelocationRef b); 33 void DumpBytes(StringRef bytes); 34 void DisassembleInputMachO(StringRef Filename); 35 void printCOFFUnwindInfo(const object::COFFObjectFile* o); 36 void printELFFileHeader(const object::ObjectFile *o); 37 38 class StringRefMemoryObject : public MemoryObject { 39 virtual void anchor(); 40 StringRef Bytes; 41 public: StringRefMemoryObject(StringRef bytes)42 StringRefMemoryObject(StringRef bytes) : Bytes(bytes) {} 43 getBase()44 uint64_t getBase() const { return 0; } getExtent()45 uint64_t getExtent() const { return Bytes.size(); } 46 readByte(uint64_t Addr,uint8_t * Byte)47 int readByte(uint64_t Addr, uint8_t *Byte) const { 48 if (Addr >= getExtent()) 49 return -1; 50 *Byte = Bytes[Addr]; 51 return 0; 52 } 53 }; 54 55 } 56 57 #endif 58