简体   繁体   中英

Assembly jmp memory expression

Im dissasembling something for a project, and I encountered with the following line

jmp *0x80498c0(,%eax,4)

What exactly is that jump instruction trying to do? This is in a gdb environment.

Thanks

This is an indirect jump.

The instruction calculates the location [0x80498c0 + eax*4] , loads the value stored there and jumps to the address stored at this location.

This kind of code is quite common seen in jumptables, often after a C switch instruction or equivalent.

Edit: The * is specific to the AT&T syntax. It's a mnemonic for dereference , like in C. It is needed in the case the part in the braces is missing - jmp 0x80498c0 would just jump to this address, where jmp *0x80498c0 jumps to the target of the pointer stored in 0x80498c0.

see the Referencing memory: section here
A 32-bit addressing can be seen as follows (AT&T format)

immed32(basepointer,indexpointer,indexscale)

This is translated as the value at address given by

immed32 + basepointer + indexpointer * indexscale

For example, to address a[i] where "a" is an array of integers, you could write

(%eax, %ebx, 4)

such that eax register holds the base pointer of a and ebx has the index i.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM