summaryrefslogtreecommitdiff
path: root/include/llvm-c/Disassembler.h
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2011-04-11 18:08:50 +0000
committerKevin Enderby <enderby@apple.com>2011-04-11 18:08:50 +0000
commitbd3327654b5708f1ba92aff3ab25b1bbf5034797 (patch)
tree560fde902b2414f053380fe98f0bc1d2b7c2d366 /include/llvm-c/Disassembler.h
parent0fb215a154a5f9f54eea1ce8b006ba9bce5defa1 (diff)
downloadllvm-bd3327654b5708f1ba92aff3ab25b1bbf5034797.tar.gz
llvm-bd3327654b5708f1ba92aff3ab25b1bbf5034797.tar.bz2
llvm-bd3327654b5708f1ba92aff3ab25b1bbf5034797.tar.xz
Adding support for printing operands symbolically to llvm's public 'C'
disassembler API. Hooked this up to the ARM target so such tools as Darwin's otool(1) can now print things like branch targets for example this: blx _puts instead of this: blx #-36 And even print the expression encoded in the Mach-O relocation entried for things like this: movt r0, :upper16:((_foo-_bar)+1234) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129284 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm-c/Disassembler.h')
-rw-r--r--include/llvm-c/Disassembler.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/include/llvm-c/Disassembler.h b/include/llvm-c/Disassembler.h
index 63ed9df88e..dda7111ca2 100644
--- a/include/llvm-c/Disassembler.h
+++ b/include/llvm-c/Disassembler.h
@@ -48,6 +48,49 @@ typedef int (*LLVMOpInfoCallback)(void *DisInfo,
void *TagBuf);
/**
+ * The initial support in LLVM MC for the most general form of a relocatable
+ * expression is "AddSymbol - SubtractSymbol + Offset". For some Darwin targets
+ * this full form is encoded in the relocation information so that AddSymbol and
+ * SubtractSymbol can be link edited independent of each other. Many other
+ * platforms only allow a relocatable expression of the form AddSymbol + Offset
+ * to be encoded.
+ *
+ * The LLVMOpInfoCallback() for the TagType value of 1 uses the struct
+ * LLVMOpInfo1. The value of the relocatable expression for the operand,
+ * including any PC adjustment, is passed in to the call back in the Value
+ * field. The symbolic information about the operand is returned using all
+ * the fields of the structure with the Offset of the relocatable expression
+ * returned in the Value field. It is possible that some symbols in the
+ * relocatable expression were assembly temporary symbols, for example
+ * "Ldata - LpicBase + constant", and only the Values of the symbols without
+ * symbol names are present in the relocation information. The VariantKind
+ * type is one of the Target specific #defines below and is used to print
+ * operands like "_foo@GOT", ":lower16:_foo", etc.
+ */
+struct LLVMOpInfoSymbol1 {
+ uint64_t Present; /* 1 if this symbol is present */
+ char *Name; /* symbol name if not NULL */
+ uint64_t Value; /* symbol value if name is NULL */
+};
+struct LLVMOpInfo1 {
+ struct LLVMOpInfoSymbol1 AddSymbol;
+ struct LLVMOpInfoSymbol1 SubtractSymbol;
+ uint64_t Value;
+ uint64_t VariantKind;
+};
+
+/**
+ * The operand VariantKinds for symbolic disassembly.
+ */
+#define LLVMDisassembler_VariantKind_None 0 /* all targets */
+
+/**
+ * The ARM target VariantKinds.
+ */
+#define LLVMDisassembler_VariantKind_ARM_HI16 1 /* :upper16: */
+#define LLVMDisassembler_VariantKind_ARM_LO16 2 /* :lower16: */
+
+/**
* The type for the symbol lookup function. This may be called by the
* disassembler for such things like adding a comment for a PC plus a constant
* offset load instruction to use a symbol name instead of a load address value.