[LLVMdev] Looking for ideas on how to make llvm-objdump handle both arm and thumb disassembly from the same object file

Eric Christopher echristo at gmail.com
Fri Aug 8 17:56:19 PDT 2014


On Thu, Aug 7, 2014 at 7:09 AM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
>> The implementation of llvm-objdump does have a MachODump.cpp for use with the -m option that I could do the a similar hack otool(1) like hack and special case 32-bit ARM cpus.  And at least it contains the ugliness.  But this does not really help the non -m case and I suspect ELF objects may face a similar problem.
>
> My gut feeling would be to do this first and keep an eye for how to
> refactor it when we want to add support for ELF or for things like
> mips16.
>
> CCing Eric since he is now the expert on the target/subtarget relationship.
>

Sure. Probably the easiest way would be to take all of the disparate
classes and throw them under the MCSubtargetInfo as best as can be
done, then you can just create a single object for each target you
want to disassemble for in the binary. arm/thumb mips/mips16 might be
a bit more difficult as you'll need to swap on a function by function
basis, but as long as you've got an index of subtargets to handle
disassembly it should be possible. Right now the arm/thumb interface
is a bit wonky there, but I think mips/mips16 should work - at least
it does for code generation, I haven't looked heavily at the
disassembler in a while.

If you're interested in going down this path though I'll give it some
thought and see what I can do.

-eric




More information about the llvm-dev mailing list