1 //===-- llvm-objdump.h ----------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_OBJDUMP_H
11 #define LLVM_OBJDUMP_H
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/CommandLine.h"
15 #include "llvm/Support/DataTypes.h"
16 #include "llvm/Support/MemoryObject.h"
27 extern cl::opt<std::string> TripleName;
28 extern cl::opt<std::string> ArchName;
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);
38 class StringRefMemoryObject : public MemoryObject {
39 virtual void anchor();
43 StringRefMemoryObject(StringRef bytes, uint64_t Base = 0)
44 : Bytes(bytes), Base(Base) {}
46 uint64_t getBase() const { return Base; }
47 uint64_t getExtent() const { return Bytes.size(); }
49 int readByte(uint64_t Addr, uint8_t *Byte) const {
50 if (Addr >= Base + getExtent() || Addr < Base)
52 *Byte = Bytes[Addr - Base];