microsoft / llvm-mctoll

llvm-mctoll
Other
816 stars 125 forks source link

Failed to lift simple ARM binary #187

Open Silipwn opened 2 years ago

Silipwn commented 2 years ago

Hello, I was trying to lift a simple ARM binary, but mctoll crashes with Assertion Failure.

Error:

llvm-mctoll: /mnt/data/silipwn/llvm-project/llvm/include/llvm/MC/MCInstrInfo.h:64: const llvm::MCInstrDesc& llvm::MCInstrInfo::get(unsigned int) const: Assertion `Opcode < NumOpcodes && "Invalid opcode!"' failed.

Stack trace

Stack dump:
0.      Program arguments: llvm-mctoll -d hello_test_arm
 #0 0x000055bb62146ddc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /mnt/data/silipwn/llvm-project/llvm/lib/Support/Unix/Signals.inc:573:0
 #1 0x000055bb62144e74 llvm::sys::RunSignalHandlers() /mnt/data/silipwn/llvm-project/llvm/lib/Support/Signals.cpp:103:0
 #2 0x000055bb6214557e SignalHandler(int) /mnt/data/silipwn/llvm-project/llvm/lib/Support/Unix/Signals.inc:397:0
 #3 0x00007f73700ec980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x00007f736ed19e87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f736ed1b7f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f736ed0b3fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f736ed0b472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
 #8 0x000055bb61922137 llvm::MachineOperand::getImm() const /mnt/data/silipwn/llvm-project/llvm/include/llvm/CodeGen/MachineOperand.h:547:0
 #9 0x000055bb61922137 llvm::getAddressFromInstr(llvm::MachineInstr const*, unsigned int) (.part.114) /mnt/data/silipwn/llvm-project/llvm/lib/Target/X86/X86InstrBuilder.h:114:0
#10 0x000055bb626bddd5 llvm::MachineFunction::getBlockNumbered(unsigned int) const /mnt/data/silipwn/llvm-project/llvm/include/llvm/CodeGen/MachineFunction.h:789:0
#11 0x000055bb626bddd5 llvm::mctoll::MCInstRaiser::buildCFG(llvm::MachineFunction&, llvm::MCInstrAnalysis const*, llvm::MCInstrInfo const*) /mnt/data/silipwn/llvm-project/llvm/tools/llvm-mctoll/Raiser/MCInstRaiser.cpp:167:0
#12 0x000055bb626bf29a llvm::mctoll::ModuleRaiser::runMachineFunctionPasses() /mnt/data/silipwn/llvm-project/llvm/tools/llvm-mctoll/Raiser/ModuleRaiser.cpp:191:0
#13 0x000055bb619c81df disassembleObject(llvm::object::ObjectFile const*, bool) (.constprop.604) /mnt/data/silipwn/llvm-project/llvm/tools/llvm-mctoll/llvm-mctoll.cpp:1281:0
#14 0x000055bb61974eef llvm::Expected<llvm::object::OwningBinary<llvm::object::Binary>>::assertIsChecked() const /mnt/data/silipwn/llvm-project/llvm/include/llvm/Support/Error.h:713:0
#15 0x000055bb61974eef llvm::Expected<llvm::object::OwningBinary<llvm::object::Binary>>::~Expected() /mnt/data/silipwn/llvm-project/llvm/include/llvm/Support/Error.h:551:0
#16 0x000055bb61974eef dumpInput /mnt/data/silipwn/llvm-project/llvm/tools/llvm-mctoll/llvm-mctoll.cpp:1406:0
#17 0x000055bb61974eef void (*std::for_each<__gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>, void (*)(llvm::StringRef)>(__gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>, __gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>, void (*)(llvm::StringRef)))(llvm::StringRef) /usr/include/c++/7/bits/stl_algo.h:3884:0
#18 0x000055bb61974eef main /mnt/data/silipwn/llvm-project/llvm/tools/llvm-mctoll/llvm-mctoll.cpp:1590:0
#19 0x00007f736ecfcc87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#20 0x000055bb619b85ba _start (/mnt/data/silipwn/llvm-project/build/bin/llvm-mctoll+0x7665ba)

The binary is also attached crash.zip

The binary was compiled in a Ubuntu Bionic docker container, with gcc-arm-linux-gnueabi and gcc-multilib

bharadwajy commented 1 year ago

Thanks for the bug report. Added appropriate tag and will look at it. As always, any help is welcome.