Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 454
firebush Avatar asked Oct 29 '25 07:10

firebush


1 Answers

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.

like image 119
fuz Avatar answered Oct 31 '25 06:10

fuz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!