llvm-bjdump and ELF-ARM/Thumb

Hi Everyone,

When I used llvm-objdump to disassemble an ELF armv7 or thumb I have this error message:

llvm-objdump: warning: invalid instruction encoding

This message appears directly into the output and the output is mostly wrong (the invalid instruction create a shift in the addresses) :

    1a6d: ff 2f e1 08 stmeq r1!, {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, sp} ^
    1a71: 30 90 e5 00 rsceq r9, r5, r0, lsr r0
    1a75: 10 a0 e1 00 rsceq r10, r1, r0, lsl r0
    1a79: 00 53 e3 1e cdpne p3, #14, c5, c3, c0, #0
llvm-objdump: warning: invalid instruction encoding
    1a7e: 2f 01 01 00 andeq r0, r1, pc, lsr #2
llvm-objdump: warning: invalid instruction encoding
    1a83: e3 13 ff 2f svchs #16716771
llvm-objdump: warning: invalid instruction encoding

The binaries I try to read are c++ dynamic libraries for Android.

I have used the following parameters:

-llvm-objcdump mylib.so -d -arch=arm
-llvm-objcdump mylib.so -d -arch=armv7
-llvm-objcdump mylib.so -d -arch=thumb

or with the following triples:

armv7-none-linux-android
thumbv7-none-linux-android

Does anyone know why I have this error? Am I missing some input parameters?

This is strange because it works great on iOS binaries (both thumb or arm).

Greetings,

Johan

What happens if you use the standard bunutils objdump e.g. from macports package arm-elf-binutils (if you’re on a Mac)?

The standard objdump does not recognised the format.

It works if I used an arm-linux-androideabi-objdump from the Android ndk but I am using the clang API to read binary inside my soft.

This is why I was only working with llvm-objdump.

After some digging, I found people with the same problem:

https://llvm.org/bugs/show_bug.cgi?id=15795
https://groups.google.com/forum/#!topic/llvm-dev/Kf3jXQLUJtM

Does anyone know if there is a solution now? I can’t find anything.

I found the problem, my libraries contains both ARM and Thumb instructions.

When I specified the triple for thumb, all the arm function where not correctly disassemble.

This creates a shift that has repercussion into the thumb function.

You can simply disassemble function per function and used the triple : thumbv7-unknown-unknown-macho or armv7-unknown-unknown-macho