Re: [RFA] amd64 displaced stepping support

Stan Shebs
2009-01-27T01:33:49Z

Doug Evans wrote:
> Hi. I took a crack at implementing displaced stepping support for amd64.
>
Ooh nice! And fortuitous timing, I was supposed to write this very code
next week...
> Using the disassembler to compute instruction lengths is awkward, I know.
> It's needed in order to compute the address of rip-relative addressing.
> The address is %rip + address-of-next-insn + displacement,
> and the displacement is only 32 bits so it's not guaranteed to be enough
> to cover the distance between the original instruction and its copy.
> To compensate I compute an unused integer reg, set it to
> %rip + address-of-next-insn, and rewrite the insn to use base+disp addressing.
> I think the GNU tools need a general-purpose library of ISA-related tools.
> Until then, I went with the disassembler. The code is laid out such that
> when a better implementation of computing insn lengths comes along, it
> can be easily dropped in.
>
My kneejerk would be to borrow libopcodes.
> This also includes a testcase! :-)
> Plus I added a testcase for the i386 case.
>
> Ok to check in?
>
I read it and it seems sensible, I'm the not the displaced stepping
maven though.

Stan