Search code examples
assemblyx86-64att

What does 'callq *(%rax)' mean?


I'm in a gdb session to analyze a postmortem crash. I'm looking at disassemble output for a function and I see this:

=> 0x00007f8d354aed52 <+50>:    callq  *(%rax)

The => indicates that this was the instruction called at the time of the crash. So I got a seg fault calling the function at *(%rax). I'm pretty new to assembly. I see that parens around a register mean to deference (get the value at) that address. Thus (%rax) means to get the value of the pointer currently stored in %rax. What does the star decoration do on that? Does that further dereference that value (thus (%rax) is itself a pointer)? I'm having trouble googling *( assembly syntax.

This is x64 assembly generated from GCC 4.8 compiling C++ code.


Solution

  • The asterisk indicates that the call is an indirect call. This is to distinguish call foo (call function foo) from call *foo (call function stored in variable foo). The instruction callq *(%rax) loads a quad word (64 bits) from the address stored in rax and calls the function beginning at that quad word.

    Refer to the GNU assembler manual for details on the syntax.