FS#7182 - ARM Disassembler

Attached to Project: Rockbox
Opened by Toni (ahellmann) - Thursday, 17 May 2007, 15:56 GMT
Last edited by Barry Wardell (barrywardell) - Wednesday, 01 August 2007, 22:28 GMT
Task Type Patches
Category Operating System/Drivers
Status Closed
Assigned To No-one
Operating System PortalPlayer-based
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


First approach of a simple ARM disassembler.
Compared to the gnu objdump it has following enhancements:
- shows 'const' data in the disassembly
- shows calculated 'const' data (i.e. mov rx, #v1 followed by sub/add rx, rx, #v2)
- skips disassembly of accessed 'const' data
Currently thumb disassembly is not supported. The binary input must not exceed 8MB.
This task depends upon

Closed by  Barry Wardell (barrywardell)
Wednesday, 01 August 2007, 22:28 GMT
Reason for closing:  Accepted
Additional comments about closing:  Committed to SVN
Comment by Dave Chapman (linuxstb) - Friday, 18 May 2007, 07:20 GMT
I've been trying to compile this under Linux, but am getting odd behaviour.

The offsets for branches (and other instructions) are being decoded wrongly. e.g. when running the supplied win32 .exe, I would get "b 0x20" in the output, but with my version compiled for Linux (32-bit x86) I get "b 0xa800020".

I'm attaching my modified version of your code, which includes a Makefile. Can anyone get this working? My attempts at debugging have failed.

The only changes I made to the two .c files were the following:

diff -r ORIG/disasm_arm.c new/disasm_arm.c
> #include <stdint.h>
< off = (ULONG)((unsigned __int64)(val&0xff) << (32 - 2 * ((val >> 8) & 15))) | ((val&0xff) >> 2 * ((val >> 8) & 15));
> off = (ULONG)((uint64_t)(val&0xff) << (32 - 2 * ((val >> 8) & 15))) | ((val&0xff) >> 2 * ((val >> 8) & 15));
diff -r ORIG/main.c new/main.c
< void main(int argc, char **argv)
> int main(int argc, char **argv)
< printf(" disassembles input file to 'disasm.txt'");
> printf(" disassembles input file to 'disasm.txt'\\n");
< }
\\ No newline at end of file
> }
Comment by Dave Chapman (linuxstb) - Monday, 28 May 2007, 11:49 GMT
I've found the problems, and attach an updated version of this disassembler which compiles cleanly (no warnings with -Wall) on Linux x86. It produces identical output (on my single test file...) to the Windows binary included in the original patch.

Toni - what are your plans for this disassembler? I think it could be nice if it was added to Rockbox SVN - maybe in something like a "utils" directory at the same level as apps, tools, firmware etc could be created for tools like this - and we can keep "tools" for tools required to build/install Rockbox.
Comment by Barry Wardell (barrywardell) - Saturday, 28 July 2007, 22:47 GMT
I came across an endianness problem when I tried using this on my PPC Mac. Attached is an updated version that now works well on my Mac. The only change is in ensuring to convert from little endian to host format when reading in the data.

I agree that it would be great to see this in SVN. Do you plan on working on it further?
Comment by Barry Wardell (barrywardell) - Saturday, 28 July 2007, 23:19 GMT
And another endianness problem, this time when the const data was being read. Fixed version attached.