blob: 9f5a8c3db973892239cbd56b879e2130618903e5 [file] [log] [blame]
Benjamin Kramer0b8b7712011-09-19 17:56:04 +00001//===-- 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
Michael J. Spencereef7b622012-12-05 20:12:35 +000020namespace object {
21 class COFFObjectFile;
22 class RelocationRef;
23}
24class error_code;
25
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000026extern cl::opt<std::string> TripleName;
27extern cl::opt<std::string> ArchName;
28
29// Various helper functions.
Michael J. Spencereef7b622012-12-05 20:12:35 +000030bool error(error_code ec);
31bool RelocAddressLess(object::RelocationRef a, object::RelocationRef b);
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000032void DumpBytes(StringRef bytes);
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000033void DisassembleInputMachO(StringRef Filename);
Michael J. Spencereef7b622012-12-05 20:12:35 +000034void printCOFFUnwindInfo(const object::COFFObjectFile* o);
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000035
36class StringRefMemoryObject : public MemoryObject {
David Blaikie2d24e2a2011-12-20 02:50:00 +000037 virtual void anchor();
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000038 StringRef Bytes;
39public:
40 StringRefMemoryObject(StringRef bytes) : Bytes(bytes) {}
41
42 uint64_t getBase() const { return 0; }
Derek Schuffadef06a2012-02-29 01:09:06 +000043 uint64_t getExtent() const { return Bytes.size(); }
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000044
Derek Schuffadef06a2012-02-29 01:09:06 +000045 int readByte(uint64_t Addr, uint8_t *Byte) const {
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000046 if (Addr >= getExtent())
47 return -1;
48 *Byte = Bytes[Addr];
49 return 0;
50 }
51};
52
53}
54
55#endif