llvm-6502/lib/MC
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
..
MCDisassembler Add MCSymbolizer for symbolic/annotated disassembly. 2013-05-24 00:39:57 +00:00
MCParser Fix two typo 2013-05-14 23:36:24 +00:00
CMakeLists.txt Add MCSymbolizer for symbolic/annotated disassembly. 2013-05-24 00:39:57 +00:00
ELFObjectWriter.cpp Remove MCELFObjectTargetWriter::adjustFixupOffset hack 2013-05-15 15:07:42 +00:00
LLVMBuild.txt
MachObjectWriter.cpp
Makefile
MCAsmBackend.cpp
MCAsmInfo.cpp Remove unused DwarfSectionOffsetDirective string 2013-04-22 22:49:11 +00:00
MCAsmInfoCOFF.cpp Remove unused DwarfSectionOffsetDirective string 2013-04-22 22:49:11 +00:00
MCAsmInfoDarwin.cpp
MCAsmStreamer.cpp Add support for subsections to the ELF assembler. Fixes PR8717. 2013-04-17 21:18:16 +00:00
MCAssembler.cpp Add support for subsections to the ELF assembler. Fixes PR8717. 2013-04-17 21:18:16 +00:00
MCAtom.cpp
MCCodeEmitter.cpp
MCCodeGenInfo.cpp
MCContext.cpp
MCDisassembler.cpp Add MCSymbolizer for symbolic/annotated disassembly. 2013-05-24 00:39:57 +00:00
MCDwarf.cpp Remove the MachineMove class. 2013-05-13 01:16:13 +00:00
MCELF.cpp
MCELFObjectTargetWriter.cpp Cleanup relocation sorting for ELF. 2013-05-15 18:22:01 +00:00
MCELFStreamer.cpp Add support for subsections to the ELF assembler. Fixes PR8717. 2013-04-17 21:18:16 +00:00
MCExpr.cpp [PowerPC] Clean up generation of ha16() / lo16() markers 2013-05-23 22:26:41 +00:00
MCExternalSymbolizer.cpp Add MCSymbolizer for symbolic/annotated disassembly. 2013-05-24 00:39:57 +00:00
MCInst.cpp
MCInstPrinter.cpp
MCInstrAnalysis.cpp
MCLabel.cpp
MCMachObjectTargetWriter.cpp
MCMachOStreamer.cpp Add support for subsections to the ELF assembler. Fixes PR8717. 2013-04-17 21:18:16 +00:00
MCModule.cpp
MCNullStreamer.cpp Add support for subsections to the ELF assembler. Fixes PR8717. 2013-04-17 21:18:16 +00:00
MCObjectFileInfo.cpp [SystemZ] Update non-pic DWARF encodings 2013-05-06 17:28:30 +00:00
MCObjectStreamer.cpp Add support for subsections to the ELF assembler. Fixes PR8717. 2013-04-17 21:18:16 +00:00
MCObjectSymbolizer.cpp Add MCSymbolizer for symbolic/annotated disassembly. 2013-05-24 00:39:57 +00:00
MCObjectWriter.cpp
MCPureStreamer.cpp Add support for subsections to the ELF assembler. Fixes PR8717. 2013-04-17 21:18:16 +00:00
MCRegisterInfo.cpp
MCRelocationInfo.cpp Add MCSymbolizer for symbolic/annotated disassembly. 2013-05-24 00:39:57 +00:00
MCSection.cpp
MCSectionCOFF.cpp Add support for subsections to the ELF assembler. Fixes PR8717. 2013-04-17 21:18:16 +00:00
MCSectionELF.cpp Add support for subsections to the ELF assembler. Fixes PR8717. 2013-04-17 21:18:16 +00:00
MCSectionMachO.cpp Add support for subsections to the ELF assembler. Fixes PR8717. 2013-04-17 21:18:16 +00:00
MCStreamer.cpp MCStreamer: Also clear vector of W64UnwindInfos on reset(). 2013-05-07 21:14:15 +00:00
MCSubtargetInfo.cpp
MCSymbol.cpp
MCSymbolizer.cpp Add MCSymbolizer for symbolic/annotated disassembly. 2013-05-24 00:39:57 +00:00
MCValue.cpp
MCWin64EH.cpp
SubtargetFeature.cpp
WinCOFFObjectWriter.cpp COFF: Fix weak external aliases. 2013-04-22 18:48:56 +00:00
WinCOFFStreamer.cpp