blob: ca7bced635f81a6bcf52e70814917df2c79c04bb [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;
Michael J. Spencerb2c064c2013-01-06 03:56:49 +000022 class ObjectFile;
Michael J. Spencereef7b622012-12-05 20:12:35 +000023 class RelocationRef;
24}
25class error_code;
26
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000027extern cl::opt<std::string> TripleName;
28extern cl::opt<std::string> ArchName;
29
30// Various helper functions.
Michael J. Spencereef7b622012-12-05 20:12:35 +000031bool error(error_code ec);
32bool RelocAddressLess(object::RelocationRef a, object::RelocationRef b);
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000033void DumpBytes(StringRef bytes);
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000034void DisassembleInputMachO(StringRef Filename);
Michael J. Spencereef7b622012-12-05 20:12:35 +000035void printCOFFUnwindInfo(const object::COFFObjectFile* o);
Michael J. Spencerb2c064c2013-01-06 03:56:49 +000036void printELFFileHeader(const object::ObjectFile *o);
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000037
38class StringRefMemoryObject : public MemoryObject {
David Blaikie2d24e2a2011-12-20 02:50:00 +000039 virtual void anchor();
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000040 StringRef Bytes;
41public:
42 StringRefMemoryObject(StringRef bytes) : Bytes(bytes) {}
43
44 uint64_t getBase() const { return 0; }
Derek Schuffadef06a2012-02-29 01:09:06 +000045 uint64_t getExtent() const { return Bytes.size(); }
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000046
Derek Schuffadef06a2012-02-29 01:09:06 +000047 int readByte(uint64_t Addr, uint8_t *Byte) const {
Benjamin Kramer0b8b7712011-09-19 17:56:04 +000048 if (Addr >= getExtent())
49 return -1;
50 *Byte = Bytes[Addr];
51 return 0;
52 }
53};
54
55}
56
57#endif