Hi Tim,<br><br>Thanks a lot for the reply. <br><br>I tested libc.so which is a shared library. llvm-objdump also report some disassemble errors.<br><br>Could you please tell me more about $a, $t and $d symbols? How these symbols are used to define different regions? Where I can find this symbols in ELF object file?<br>
<br>Thanks,<br>David<br><br><br> <br><br>  <br>I'm now try to find a decoder of ARM instructions in oder<br><br><div class="gmail_quote">On Thu, Jun 7, 2012 at 3:57 AM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi David,<br>
<div class="im"><br>
> I've try to use llvm-objdump to disassemble some ARM binary, such as busybox<br>
> in android.<br>
><br>
> ./llvm-objdump -arch=arm -d busybox<br>
<br>
</div>It's probably assuming the wrong architecture revision. I don't have<br>
an android busybox handy, but I see similar on binaries compiled for<br>
ARMv7. The trick is to use:<br>
<br>
llvm-objdump -triple=armv7 -d whatever<br>
<br>
(ARMv7 covers virtually anything Android will be running on these days).<br>
<br>
There are a couple of other things to be wary of at the moment though:<br>
1. PC-relative data, as you said: ARM code often includes literal data<br>
inline with code, this could well *not* have a valid disassembly. In<br>
relocatable object files, these regions should be marked[*], but I<br>
believe LLVM has problems with that currently. In executable files<br>
(like "busybox") the regions won't necessarily even be marked.<br>
<br>
2. ARM object files may contain mixed ARM and Thumb code: two<br>
different instruction sets. Obviously, disassembling ARM as Thumb or<br>
the reverse won't give you anything sensible. Again, relocatable files<br>
mark these regions[*] but executables don't. If you know an what you<br>
want is thumb code, you can use the triple "thumbv7" instead for<br>
llvm-objdump.<br>
<br>
So a combination of those probably explains why you're getting<br>
problems and may improve matters, but it probably won't make things<br>
perfect (and arguably can't in the case of the ARM/Thumb distinction<br>
without reconstructing all possible control-flow graphs).<br>
<br>
Tim.<br>
<br>
[*] The marking is via symbols $a, $t and $d which reference the<br>
beginning each stretch of ARM code, Thumb code and Data.<br>
</blockquote></div><br>