[compiler-rt] [win/asan] GetInstructionSize: Add test for `8D A4 24 ...`. (PR #119794)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 20:48:32 PST 2024
bernhardu wrote:
> If I haven't misunderstood, the point of `rel_offset` is for adjusting an **RIP-relative address** to refer to the same address after the instruction is copied (moved) to a new location for the hotpatch/trampoline hooking techniques.
>
> `[esp + XX XX XX XX]` is an ESP-relative address, which shouldn't need adjustment, so this change looks dubious to me.
>
> Also, considering that on x86 (not x86_64) there is no PC-relative addressing (outside of near jump/call), setting `rel_offset` for any instructions not guarded by `#if SANITIZER_WINDOWS_x64` is probably wrong.
> > `[esp + XX XX XX XX]` is an ESP-relative address, which shouldn't need adjustment, so this change looks dubious to me.
>
> +1 I don't think this should set rel_offset.
Thank you for the explanations, that part was obviously not completely clear to me.
I pushed a new version of this patch to just include this test line with rel_offset=0,
and changing the comment to better reflect the meaning of rel_offset.
Just for the background I am trying to get the tests as correct as I can by using
an external lib [bddisasm](https://github.com/bitdefender/bddisasm).
With your explanation I found now it provides a value `RIP relative`,
and if that is flagged using as rel_offset the "displacement offset" (like in this [local patch](https://github.com/llvm/llvm-project/pull/113085/commits/31685b2f000023fe8e9426cdcce87eccd7c3de56) ).
(Unfortunately I was not able to get something similar out of llvm/tablegen. Linking the llvm disassembler into the interception might be out of reach, but wouldn't it be possible to link it into the Interception-x86_64-Test.exe? This would make it possible to verify the test list "on the fly".)
https://github.com/llvm/llvm-project/pull/119794
More information about the llvm-commits
mailing list