My previous patch had added a couple of asserts to the disassembler.
The problem with this is that the disassembler is not just used for the
text section it is also used to disassemble the data section of an
object where the bytes do not necessarily represent instructions. If the
data in the data section happens to look like an illegal instruction
then llvm-objdump will assert on data because it is finding an illegal
instruction that is not actually an instruction at all.
Details
- Reviewers
lei nemanjai amyk - Group Reviewers
Restricted Project - Commits
- rG11fbd0c6abc9: [PowerPC] Remove asserts from the disassembler.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp | ||
---|---|---|
121 | Little confused. From the function name and its parameter seems like this function should only be called for instructions. Is it possible that there is a wrong call to this function? For example, for data, we should not decode fpr RC as there is no RC for data at all? |
Could we also update the description of the patch to specify what My previous patch means (as in, which patch)?
llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-dfp.txt | ||
---|---|---|
27 ↗ | (On Diff #518928) | Might be a silly question, but I have a clarification question. |
llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp | ||
---|---|---|
118 | The removed assertion should have been changed to if (...) return DecodeStatus::Fail; so that random data is not decoded into invalid instructions. |
Please note that this assert can trip even when disassembling with --disassemble and not just -disassemble-all. Namely, the offending word can appear in the text section (for example, the AIX traceback table, etc.).
This is very similar to https://reviews.llvm.org/rGc86f8d4276ae
llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp | ||
---|---|---|
118–119 | Lets not just remove these. Please change it to something like: if (RegNo > 30 || (RegNo & 1)) return MCDisassembler::Fail; |
Added the conditions so that we return DecodeStatus::Fail instead of asserting.
llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp | ||
---|---|---|
121 | It is not an incorrect call to the function. The disassembler will call this whenever it tries to disassemble anything that looks like it might be an instruction. As other people in the comments mentioned I need to stop the assert and instead just return a failure to disassemble. | |
llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-dfp.txt | ||
27 ↗ | (On Diff #518928) | No, we don't want to decode an incorrect instruction. The initial issue was that we would decode an instruction that was part of the data section or (as Nemanja pointed out) part of the AIX traceback table and those bytes just happened to look like an instruction but an invalid instruction. When I had the asserts in there the disassembler would assert and we don't want that. |
llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp | ||
---|---|---|
351 | Did you just miss this one or is there a reason you didn't address this comment? |
llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp | ||
---|---|---|
351 | Sorry, I did miss this one. |
While we're at it, we can turn this one into a disassembly failure rather than an assert.