assemblygdbjump-table

Format of a jump table


I am reading an example on a course about jump tables. They call gdb x/8g 0x123456

The resulting output looks like:

0x123456    0x000000000000134234    0x0000000000005f424
0x123487    0x0000000000001dd1ac    0x000000000000ef327

I thought a jump table maps an address to the address of the code it should execute. Why then are there 3 columns (shouldn't it be 2?).


Solution

  • Why then are there 3 columns (shouldn't it be 2?)

    You didn't paste the real GDB output, which looked something like:

    0x123450    0x000000000000134234    0x0000000000005f424
    0x123460    0x0000000000001dd1ac    0x000000000000ef327
    

    (the first column is different). In programming, details matter.

    If you make the terminal narrower, then you'll get 2 columns, like this:

    0x123450    0x000000000000134234
    0x123458    0x0000000000005f424
    0x123460    0x0000000000001dd1ac
    0x123468    0x000000000000ef327
    

    As KerrekSB suggested, read the GDB manual to understand what x does. Hint: the first column doesn't really matter -- it's where the table itself is stored.