This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump] Handle invalid instruction gracefully on ARM
ClosedPublic

Authored by evgeny777 on Jun 29 2017, 7:22 AM.

Details

Summary

I have several stripped ARM binaries, which can't be correctly disassembled by llvm-objdump, because they intermix code with data. For instance compiling and disassembling this file:

.text
  b l0
  .inst 0xffffffff
l0:

results in this output:

$a.0:
       0:	00 00 00 ea 	b	#0 <l0>
       4:	ff  <unknown>
       5:	ff ff ff 00 	ldrshteq	pc, [pc], #255

and after applying this patch the result is the same as GNU objdump has:

$a.0:
       0:	00 00 00 ea 	b	#0 <l0>
       4:	ff ff ff ff  <unknown>

This happens because ARMDisasembler returns zero size when it fails to parse an instruction. On the contrary AArch64Disassembler always returns 4, so aarch64 binaries are disassembled correctly.

Diff Detail

Event Timeline

evgeny777 created this revision.Jun 29 2017, 7:22 AM
t.p.northover accepted this revision.Jun 29 2017, 7:55 AM
t.p.northover added a subscriber: t.p.northover.

Looks fine to me. Next step, enable the crystal ball for Thumb!

This revision is now accepted and ready to land.Jun 29 2017, 7:55 AM
This revision was automatically updated to reflect the committed changes.