[PATCH] D73531: [llvm-objdump] avoid crash disassembling unknown instruction

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 03:46:35 PST 2020


jhenderson added a comment.

I think I understand. Let me restate my understanding to check:

1. A disassembler doesn't understand some part of the machine code and consequently generates an <unknown> response in the disassembly.
2. The point at which it tries to carry on is incorrect (presumably because the amount of data it read for the operands or whatever wasn't correct).
3. Consequently, something later is parsed incorrectly (because we're no longer parsing the real instructions), causing it to be treated as a call instruction or whatever, but due to the mis-parse, llvm-objdump tries to load non-existent operands and crashes.

Assuming that's correct, it seems like there are potentially two separate issues here. 1) The disassembler should have read the instruction right in the first place, assuming it was a valid instruction. 2) If it was an invalid instruction, leading to later mis-parses, there needs to be safer error checking (i.e. not assertions or crashes), which can handle things potentially being wrong.

One question from your example: if the `cb` byte isn't a valid instruction, why does it get treated as a call/branch instruction?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73531/new/

https://reviews.llvm.org/D73531





More information about the llvm-commits mailing list