RFR: 8315038: Capstone disassembler stops when it sees a bad instruction
Andrew Haley
aph at openjdk.org
Sat Sep 16 15:29:46 UTC 2023
On Fri, 15 Sep 2023 14:56:10 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> Some thoughts: that linked page claims this is only available on the `next` branch, but I see this option is available in the 5.0.1 release from 3 weeks ago (https://github.com/capstone-engine/capstone/releases/tag/5.0.1). That is good.
Yeah. I was wondering about whether to do a `#ifdef CS_OPT_SKIPDATA` backwards-compatibility hack, but a disassembler that just stops in strange places is so misleading as to be a liability.
> The page also explains that this option works by skipping bytes until capstone finds something that it can disassemble, which might not be correct. If there is an issue with the approach proposed by this patch in the future, we might want to look at the `CS_OPT_SKIPDATA_SETUP`, which seems to allow specifying a custom callback that figures out the number of bytes to skip. (Do you have any thoughts about that?).
The default seems pretty smart in the way that it works, and I doubt we can do any better.
The main use of undefined "instructions" in compiled methods is RISC processors, which tend to disallow concurrent code patching. To solve that problem we've used embedded data that's accessed by PC-relative loads. Because RISCs tend to have fixed-size instructions, SKIPDATA always gets it right.
> Either way, this patch seems like an improvement over the status quo, so I think we can move forward with it.
Thanks.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15763#issuecomment-1722253450
More information about the build-dev
mailing list