Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 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 | |
Michael J. Spencer | eef7b62 | 2012-12-05 20:12:35 +0000 | [diff] [blame^] | 20 | namespace object { |
| 21 | class COFFObjectFile; |
| 22 | class RelocationRef; |
| 23 | } |
| 24 | class error_code; |
| 25 | |
Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 26 | extern cl::opt<std::string> TripleName; |
| 27 | extern cl::opt<std::string> ArchName; |
| 28 | |
| 29 | // Various helper functions. |
Michael J. Spencer | eef7b62 | 2012-12-05 20:12:35 +0000 | [diff] [blame^] | 30 | bool error(error_code ec); |
| 31 | bool RelocAddressLess(object::RelocationRef a, object::RelocationRef b); |
Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 32 | void DumpBytes(StringRef bytes); |
Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 33 | void DisassembleInputMachO(StringRef Filename); |
Michael J. Spencer | eef7b62 | 2012-12-05 20:12:35 +0000 | [diff] [blame^] | 34 | void printCOFFUnwindInfo(const object::COFFObjectFile* o); |
Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 35 | |
| 36 | class StringRefMemoryObject : public MemoryObject { |
David Blaikie | 2d24e2a | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 37 | virtual void anchor(); |
Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 38 | StringRef Bytes; |
| 39 | public: |
| 40 | StringRefMemoryObject(StringRef bytes) : Bytes(bytes) {} |
| 41 | |
| 42 | uint64_t getBase() const { return 0; } |
Derek Schuff | adef06a | 2012-02-29 01:09:06 +0000 | [diff] [blame] | 43 | uint64_t getExtent() const { return Bytes.size(); } |
Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 44 | |
Derek Schuff | adef06a | 2012-02-29 01:09:06 +0000 | [diff] [blame] | 45 | int readByte(uint64_t Addr, uint8_t *Byte) const { |
Benjamin Kramer | 0b8b771 | 2011-09-19 17:56:04 +0000 | [diff] [blame] | 46 | if (Addr >= getExtent()) |
| 47 | return -1; |
| 48 | *Byte = Bytes[Addr]; |
| 49 | return 0; |
| 50 | } |
| 51 | }; |
| 52 | |
| 53 | } |
| 54 | |
| 55 | #endif |