What is the jmpq command doing in this example

MichaelGofron picture MichaelGofron · Oct 24, 2014 · Viewed 43.6k times · Source

We are using gdb debugger to read assembly functions.

In assembly, we have the following instructions: mov 0xc(%rsp),%eax jmpq *0x402390(,%rax,8)

At memory location *0x402390 we have the value 0x8e. In register rax, we have the second integer input for this particular function (could use variable y).

From our analysis, we have deduced that this function takes in three variables (x, y, z) and that they can be found at memory location (rsp), (rsp + 8), (rsp + 12) respectively.

We would like to know what is going on in jmpq *0x402390(,%rax,8). Is it jumping to the instruction at (0x8e + rax*8)? If so, how can we find out what that instruction is called?

This is the full dump of assembler code for the function phase_3:

Full assembly function

Answer

Celsius_Xu picture Celsius_Xu · Jun 22, 2018

Bomb-lab right lol?

This operation jmpq *0x402390(,%rax,8) is for jumping directly to the absolute address stored at
8 * %rax + 0x402390

If you do x/16gx 0x402390 in gdb (inspect 16 "giant words" in hexadecimal starting at 0x402390) you will find an address table looks like the following:(i have a different lab so it's not the same as yours)

 0x402880:  0x0000000000400fee  0x000000000040102b
 0x402890:  0x0000000000400ff5  0x0000000000400ffc
 0x4028a0:  0x0000000000401003  0x000000000040100a
 0x4028b0:  0x0000000000401011  0x0000000000401018

Where all these addresses all point back to the a single mov operation immediately after jmpq *0x402390(,%rax,8)