microsoft / llvm-mctoll

llvm-mctoll
Other
814 stars 123 forks source link

Failed to decode instruction on armeabi-v7a shared library #28

Open andrewleech opened 5 years ago

andrewleech commented 5 years ago

I'm hoping to use llvm-mctoll to rebuild a legacy Android armeabi-v7a binary library for 64-bit support. Not sure if this is really an expected goal of the project of not?

I've built the current master of with cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX=/mnt/c/Users/anl/llvm-mctoll/install/llvm /mnt/c/Users/anl/llvm-mctoll/src/llvm/ -DLLVM_TARGETS_TO_BUILD="ARM" which appears to have build correctly.

Trying to run it against the native library however results in a lot of warnings

./llvm-mctoll/build/llvm/bin/llvm-mctoll -d libproxy.so
**** Warning: Failed to decode instruction
    c1c4:       d4 ff ff ff <unknown>
**** Warning: Failed to decode instruction
    c920:       d4 fa ff ff <unknown>
**** Warning: Failed to decode instruction
    c924:       e4 fb ff ff <unknown>
**** Warning: Failed to decode instruction
    c928:       50 fb ff ff <unknown>
**** Warning: Failed to decode instruction
    c92c:       58 fa ff ff <unknown>
**** Warning: Failed to decode instruction
    d87c:       14 f9 ff ff <unknown>
**** Warning: Failed to decode instruction
    d884:       4c f8 ff ff <unknown>

< A couple of pages of this >

**** Warning: Failed to decode instruction
   385a4:       78 ec ff ff <unknown>
**** Warning : Index 1dd8 not found
**** Warning : Index 319d8 not found

FWIW this is the library I'm hoping to convert/rebuild: https://gitlab.com/alelec/navdy/alelec_navdy_client/blob/master/src/main/jniLibs/armeabi-v7a/libproxy.so

Thanks.

bharadwajy commented 5 years ago

Thanks for considering llvm-mctoll.

I notice that the DSO is a 32-bit ARM binary and if I understand your intent correctly, it appears that you would like to raise the 32-bit DSO to LLVM IR and re-compile as a 64-bit DSO. If that is so, it does seem to be a reasonable situation for llvm-mctoll to be used in - although I'd not expect the resulting 64-bit raised binary to use 64-bit pointers.

Looking at the output you quoted, it appears that the ARM binary has instructions that llvm-mctoll does not yet have the ability to raise. Sorry about that. We are continuously working to expand the set of ARM (and X86-64) instructions that are raised in the tool. Any help is highly appreciated.

Thanks!