LLVM  8.0.1
MCExternalSymbolizer.h
Go to the documentation of this file.
1 //===-- llvm/MC/MCExternalSymbolizer.h - ------------------------*- C++ -*-===//
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 // This file contains the declaration of the MCExternalSymbolizer class, which
11 // enables library users to provide callbacks (through the C API) to do the
12 // symbolization externally.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_MC_MCDISASSEMBLER_MCEXTERNALSYMBOLIZER_H
17 #define LLVM_MC_MCDISASSEMBLER_MCEXTERNALSYMBOLIZER_H
18 
19 #include "llvm-c/Disassembler.h"
21 #include <memory>
22 
23 namespace llvm {
24 
25 /// Symbolize using user-provided, C API, callbacks.
26 ///
27 /// See llvm-c/Disassembler.h.
29 protected:
30  /// \name Hooks for symbolic disassembly via the public 'C' interface.
31  /// @{
32  /// The function to get the symbolic information for operands.
34  /// The function to lookup a symbol name.
36  /// The pointer to the block of symbolic information for above call back.
37  void *DisInfo;
38  /// @}
39 
40 public:
42  std::unique_ptr<MCRelocationInfo> RelInfo,
43  LLVMOpInfoCallback getOpInfo,
44  LLVMSymbolLookupCallback symbolLookUp, void *disInfo)
45  : MCSymbolizer(Ctx, std::move(RelInfo)), GetOpInfo(getOpInfo),
46  SymbolLookUp(symbolLookUp), DisInfo(disInfo) {}
47 
48  bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &CommentStream,
49  int64_t Value, uint64_t Address, bool IsBranch,
50  uint64_t Offset, uint64_t InstSize) override;
51  void tryAddingPcLoadReferenceComment(raw_ostream &CommentStream,
52  int64_t Value,
53  uint64_t Address) override;
54 };
55 
56 }
57 
58 #endif
std::unique_ptr< MCRelocationInfo > RelInfo
Definition: MCSymbolizer.h:42
This class represents lattice values for constants.
Definition: AllocatorList.h:24
Symbolize using user-provided, C API, callbacks.
MCContext & Ctx
Definition: MCSymbolizer.h:41
void * DisInfo
The pointer to the block of symbolic information for above call back.
Definition: BitVector.h:938
int(* LLVMOpInfoCallback)(void *DisInfo, uint64_t PC, uint64_t Offset, uint64_t Size, int TagType, void *TagBuf)
The type for the operand information call back function.
Context object for machine code objects.
Definition: MCContext.h:63
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:161
MCExternalSymbolizer(MCContext &Ctx, std::unique_ptr< MCRelocationInfo > RelInfo, LLVMOpInfoCallback getOpInfo, LLVMSymbolLookupCallback symbolLookUp, void *disInfo)
Symbolize and annotate disassembled instructions.
Definition: MCSymbolizer.h:39
void tryAddingPcLoadReferenceComment(raw_ostream &CommentStream, int64_t Value, uint64_t Address) override
Try to add a comment on the PC-relative load.
bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &CommentStream, int64_t Value, uint64_t Address, bool IsBranch, uint64_t Offset, uint64_t InstSize) override
Try to add a symbolic operand instead of Value to the MCInst.
LLVM Value Representation.
Definition: Value.h:73
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
IRTranslator LLVM IR MI
const char *(* LLVMSymbolLookupCallback)(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
The type for the symbol lookup function.
LLVMSymbolLookupCallback SymbolLookUp
The function to lookup a symbol name.