brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.7 KiB · 6999a35 Raw
171 lines · c
1/*===-- llvm-c/DisassemblerTypedefs.h -----------------------------*- C -*-===*\2|*                                                                            *|3|* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|4|* Exceptions.                                                                *|5|* See https://llvm.org/LICENSE.txt for license information.                  *|6|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|7|*                                                                            *|8|*===----------------------------------------------------------------------===*/9 10#ifndef LLVM_C_DISASSEMBLERTYPES_H11#define LLVM_C_DISASSEMBLERTYPES_H12 13#include "llvm-c/DataTypes.h"14#ifdef __cplusplus15#include <cstddef>16#else17#include <stddef.h>18#endif19 20/**21 * @addtogroup LLVMCDisassembler22 *23 * @{24 */25 26/**27 * An opaque reference to a disassembler context.28 */29typedef void *LLVMDisasmContextRef;30 31/**32 * The type for the operand information call back function.  This is called to33 * get the symbolic information for an operand of an instruction.  Typically34 * this is from the relocation information, symbol table, etc.  That block of35 * information is saved when the disassembler context is created and passed to36 * the call back in the DisInfo parameter.  The instruction containing operand37 * is at the PC parameter.  For some instruction sets, there can be more than38 * one operand with symbolic information.  To determine the symbolic operand39 * information for each operand, the bytes for the specific operand in the40 * instruction are specified by the Offset parameter and its byte widith is the41 * OpSize parameter.  For instructions sets with fixed widths and one symbolic42 * operand per instruction, the Offset parameter will be zero and InstSize43 * parameter will be the instruction width.  The information is returned in44 * TagBuf and is Triple specific with its specific information defined by the45 * value of TagType for that Triple.  If symbolic information is returned the46 * function * returns 1, otherwise it returns 0.47 */48typedef int (*LLVMOpInfoCallback)(void *DisInfo, uint64_t PC, uint64_t Offset,49                                  uint64_t OpSize, uint64_t InstSize,50                                  int TagType, void *TagBuf);51 52/**53 * The initial support in LLVM MC for the most general form of a relocatable54 * expression is "AddSymbol - SubtractSymbol + Offset".  For some Darwin targets55 * this full form is encoded in the relocation information so that AddSymbol and56 * SubtractSymbol can be link edited independent of each other.  Many other57 * platforms only allow a relocatable expression of the form AddSymbol + Offset58 * to be encoded.59 *60 * The LLVMOpInfoCallback() for the TagType value of 1 uses the struct61 * LLVMOpInfo1.  The value of the relocatable expression for the operand,62 * including any PC adjustment, is passed in to the call back in the Value63 * field.  The symbolic information about the operand is returned using all64 * the fields of the structure with the Offset of the relocatable expression65 * returned in the Value field.  It is possible that some symbols in the66 * relocatable expression were assembly temporary symbols, for example67 * "Ldata - LpicBase + constant", and only the Values of the symbols without68 * symbol names are present in the relocation information.  The VariantKind69 * type is one of the Target specific #defines below and is used to print70 * operands like "_foo@GOT", ":lower16:_foo", etc.71 */72struct LLVMOpInfoSymbol1 {73  uint64_t Present;  /* 1 if this symbol is present */74  const char *Name;  /* symbol name if not NULL */75  uint64_t Value;    /* symbol value if name is NULL */76};77 78struct LLVMOpInfo1 {79  struct LLVMOpInfoSymbol1 AddSymbol;80  struct LLVMOpInfoSymbol1 SubtractSymbol;81  uint64_t Value;82  uint64_t VariantKind;83};84 85/**86 * The operand VariantKinds for symbolic disassembly.87 */88#define LLVMDisassembler_VariantKind_None 0 /* all targets */89 90/**91 * The ARM target VariantKinds.92 */93#define LLVMDisassembler_VariantKind_ARM_HI16 1 /* :upper16: */94#define LLVMDisassembler_VariantKind_ARM_LO16 2 /* :lower16: */95 96/**97 * The ARM64 target VariantKinds.98 */99#define LLVMDisassembler_VariantKind_ARM64_PAGE       1 /* @page */100#define LLVMDisassembler_VariantKind_ARM64_PAGEOFF    2 /* @pageoff */101#define LLVMDisassembler_VariantKind_ARM64_GOTPAGE    3 /* @gotpage */102#define LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF 4 /* @gotpageoff */103#define LLVMDisassembler_VariantKind_ARM64_TLVP       5 /* @tvlppage */104#define LLVMDisassembler_VariantKind_ARM64_TLVOFF     6 /* @tvlppageoff */105 106/**107 * The type for the symbol lookup function.  This may be called by the108 * disassembler for things like adding a comment for a PC plus a constant109 * offset load instruction to use a symbol name instead of a load address value.110 * It is passed the block information is saved when the disassembler context is111 * created and the ReferenceValue to look up as a symbol.  If no symbol is found112 * for the ReferenceValue NULL is returned.  The ReferenceType of the113 * instruction is passed indirectly as is the PC of the instruction in114 * ReferencePC.  If the output reference can be determined its type is returned115 * indirectly in ReferenceType along with ReferenceName if any, or that is set116 * to NULL.117 */118typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo,119                                                uint64_t ReferenceValue,120                                                uint64_t *ReferenceType,121                                                uint64_t ReferencePC,122                                                const char **ReferenceName);123/**124 * The reference types on input and output.125 */126/* No input reference type or no output reference type. */127#define LLVMDisassembler_ReferenceType_InOut_None 0128 129/* The input reference is from a branch instruction. */130#define LLVMDisassembler_ReferenceType_In_Branch 1131/* The input reference is from a PC relative load instruction. */132#define LLVMDisassembler_ReferenceType_In_PCrel_Load 2133 134/* The input reference is from an ARM64::ADRP instruction. */135#define LLVMDisassembler_ReferenceType_In_ARM64_ADRP 0x100000001136/* The input reference is from an ARM64::ADDXri instruction. */137#define LLVMDisassembler_ReferenceType_In_ARM64_ADDXri 0x100000002138/* The input reference is from an ARM64::LDRXui instruction. */139#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXui 0x100000003140/* The input reference is from an ARM64::LDRXl instruction. */141#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXl 0x100000004142/* The input reference is from an ARM64::ADR instruction. */143#define LLVMDisassembler_ReferenceType_In_ARM64_ADR 0x100000005144 145/* The output reference is to as symbol stub. */146#define LLVMDisassembler_ReferenceType_Out_SymbolStub 1147/* The output reference is to a symbol address in a literal pool. */148#define LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr 2149/* The output reference is to a cstring address in a literal pool. */150#define LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr 3151 152/* The output reference is to a Objective-C CoreFoundation string. */153#define LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref 4154/* The output reference is to a Objective-C message. */155#define LLVMDisassembler_ReferenceType_Out_Objc_Message 5156/* The output reference is to a Objective-C message ref. */157#define LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref 6158/* The output reference is to a Objective-C selector ref. */159#define LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref 7160/* The output reference is to a Objective-C class ref. */161#define LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref 8162 163/* The output reference is to a C++ symbol name. */164#define LLVMDisassembler_ReferenceType_DeMangled_Name 9165 166/**167 * @}168 */169 170#endif171