llvm/tools
Ahmed Bougacha 2c94d0faa0 Add MCSymbolizer for symbolic/annotated disassembly.
This is a basic first step towards symbolization of disassembled
instructions. This used to be done using externally provided (C API)
callbacks. This patch introduces:
- the MCSymbolizer class, that mimics the same functions that were used
  in the X86 and ARM disassemblers to symbolize immediate operands and
  to annotate loads based off PC (for things like c string literals).
- the MCExternalSymbolizer class, which implements the old C API.
- the MCRelocationInfo class, which provides a way for targets to
  translate relocations (either object::RelocationRef, or disassembler
  C API VariantKinds) to MCExprs.
- the MCObjectSymbolizer class, which does symbolization using what it
  finds in an object::ObjectFile. This makes simple symbolization (with
  no fancy relocation stuff) work for all object formats!
- x86-64 Mach-O and ELF MCRelocationInfos.
- A basic ARM Mach-O MCRelocationInfo, that provides just enough to
  support the C API VariantKinds.

Most of what works in otool (the only user of the old symbolization API
that I know of) for x86-64 symbolic disassembly (-tvV) works, namely:
- symbol references: call _foo; jmp 15 <_foo+50>
- relocations:       call _foo-_bar; call _foo-4
- __cf?string:       leaq 193(%rip), %rax ## literal pool for "hello"
Stub support is the main missing part (because libObject doesn't know,
among other things, about mach-o indirect symbols).

As for the MCSymbolizer API, instead of relying on the disassemblers
to call the tryAdding* methods, maybe this could be done automagically
using InstrInfo? For instance, even though PC-relative LEAs are used
to get the address of string literals in a typical Mach-O file, a MOV
would be used in an ELF file. And right now, the explicit symbolization
only recognizes PC-relative LEAs. InstrInfo should have already have
most of what is needed to know what to symbolize, so this can
definitely be improved.

I'd also like to remove object::RelocationRef::getValueString (it seems
only used by relocation printing in objdump), as simply printing the
created MCExpr is definitely enough (and cleaner than string concats).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182625 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-24 00:39:57 +00:00
..
bugpoint Use only explicit bool conversion operators 2013-05-15 07:36:59 +00:00
bugpoint-passes [CMake] bugpoint-passes should not be built in "all", when LLVM_BUILD_TOOLS is OFF. 2013-01-22 01:44:00 +00:00
gold Sort the #include lines for tools/... 2012-12-04 10:44:52 +00:00
llc Replace uses of the deprecated std::auto_ptr with OwningPtr. 2013-04-12 10:56:28 +00:00
lli Print uint64_t -debug text correctly on 32-bit hosts 2013-05-19 09:55:06 +00:00
llvm-ar Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
llvm-as Replace uses of the deprecated std::auto_ptr with OwningPtr. 2013-04-12 10:56:28 +00:00
llvm-bcanalyzer Add static cast to unsigned char whenever a character classification function is called with a signed char argument, in order to avoid assertions in Windows Debug configuration. 2013-02-12 21:21:59 +00:00
llvm-config Re-enable support for --program-prefix. 2012-10-01 18:40:32 +00:00
llvm-cov Remove accidental commit. 2012-11-07 18:39:32 +00:00
llvm-diff Manually update the dependencies in the Makefiles. It turns out that all 2013-03-26 03:45:47 +00:00
llvm-dis Replace uses of the deprecated std::auto_ptr with OwningPtr. 2013-04-12 10:56:28 +00:00
llvm-dwarfdump Add support for the pubnames section to llvm-dwarfdump. 2013-02-12 16:20:28 +00:00
llvm-extract Replace uses of the deprecated std::auto_ptr with OwningPtr. 2013-04-12 10:56:28 +00:00
llvm-jitlistener Manually update the dependencies in the Makefiles. It turns out that all 2013-03-26 03:45:47 +00:00
llvm-link Optimize llvm-link too. 2013-05-04 05:30:49 +00:00
llvm-mc Remove the MachineMove class. 2013-05-13 01:16:13 +00:00
llvm-mcmarkup MC: Simple example parser for MC assembly markup. 2012-10-31 23:24:13 +00:00
llvm-nm [Object][Archive] Improve performance. 2013-02-03 10:48:50 +00:00
llvm-objdump Add MCSymbolizer for symbolic/annotated disassembly. 2013-05-24 00:39:57 +00:00
llvm-prof Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
llvm-ranlib Replace uses of the deprecated std::auto_ptr with OwningPtr. 2013-04-12 10:56:28 +00:00
llvm-readobj Introduce convenience typedefs for the 4 ELF object types. 2013-05-09 13:13:28 +00:00
llvm-rtdyld Minor changes to the MCJITTest unittests to use the correct API for finalizing 2013-05-17 10:01:46 +00:00
llvm-shlib Add support for the OpenBSD for Bitrig. 2012-08-06 20:52:18 +00:00
llvm-size Sort the #include lines for tools/... 2012-12-04 10:44:52 +00:00
llvm-stress Manually update the dependencies in the Makefiles. It turns out that all 2013-03-26 03:45:47 +00:00
llvm-symbolizer At Jim Grosbach's request detemplate Object/MachO.h. 2013-04-18 18:08:55 +00:00
lto The command line options need to be processed before we create the TargetMachine. 2013-05-23 21:21:50 +00:00
macho-dump Use llvm/Object/MachO.h in macho-dumper. Drop the old macho parser. 2013-04-26 20:07:33 +00:00
obj2yaml Use std::list so that we have a stable iterator. 2013-05-21 18:53:50 +00:00
opt Add DebugIR pass -- emits IR file and replace source lines with IR lines in MD 2013-05-08 20:44:14 +00:00
yaml2obj Fix the configure build. 2013-05-17 23:20:58 +00:00
CMakeLists.txt Move yaml2obj to tools too. 2013-04-05 20:00:35 +00:00
LLVMBuild.txt Adding tests for the Intel JIT event listener's MCJIT support. 2012-11-21 20:38:26 +00:00
Makefile Move yaml2obj to tools too. 2013-04-05 20:00:35 +00:00