This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Jump to registers
- From: Fabian Cenedese <Cenedese at indel dot ch>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 14 Nov 2008 14:16:06 +0100
- Subject: Re: Jump to registers
At 13:54 14.11.2008 +0100, Alessandro Pellegrini wrote:
>Everything's working fine except for one
>scenario:
>mov $i, %eax
>incl (%eax)
>jmp .FancyFunction
>
>The incl (%eax)
>is a 2 byte instruction, the instrumented code would result in:
>
>mov
>$i, %eax
>call MyFunction
>nopw
>
>If somewhere else in the code there is a
>jmp to the third line of this example (jmp .FancyFunction), eip will
>point in the middle of the address of the call, in the best case
>arising a SIGILL signal, in the worst case producing undefined
>behaviour.
Wouldn't it be enough to rearrange your replacement code to have
the nop in the beginning? The your jump would be at the same
address again.
bye Fabi