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