Reputation: 9512
I see the following instruction in gdb
jmp *0x804a09c(,%eax,4)
Just prior to exececution I types these commands:
(gdb)p/x *0x804a09c
$40 = 0x8048e0e
(gdb) p $eax
$41 = 6
So when I try to calculate the address I will jump to, I get:
(gdb) p/x *0x804a09c + 4*$eax
0x8048e26
However, the jump actually goes to address 0x8048ead. What's wrong with my calculation?
Upvotes: 0
Views: 1083
Reputation:
jmp *0x804a09c(,%eax,4)
means to jump to the address that is stored at the result of this calculation0x804a09c(,%eax,4)
, the *
on the whole not on just 0x804a09c
. AT&T syntax can be misleading, Intel syntax is more clear here:
jmp DWORD PTR [eax*4+0x804a09c]
so it should be:
(gdb) p/x *(0x804a09c + 4 * $eax)
Upvotes: 5