What is the difference between memory indirect call and register indirect call?
I’m trying to learn something about linux rootkit detection, how can I recognize such calls in disassembled memory? How do they look in C language before compiling?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Memory indirect call is a call which takes the address of the callee from the memory and register indirect call takes the address from the register accordingly.
Implementation of calls is very dependent on the architecture and compiler used. On x86, both memory and register calls are possible, so it’s up to compiler to choose what’s optimal.
Take a look on a simple test:
The generated assembly is (gcc 4.6.1 w/o any optimizations):
In all cases our calls were translated into
call *%eax, which is a memory indirect call executing the function located at address pointed by%eax. Adding optimization messes the structure, but mechanics remains the register call.Calling a shared dynamic library (see example here) resulted in just
call <function_name>. Consulting the x86 Developer Manual,callaccepts either register, either memory, or pointer operand. Such a call is being treated by linker on startup and the name of the function is being substituted by the actual memory address. So, calling a shared library results (in the end) in a memory indirect call.Apart from such easily reproduced cases, you can encounter operations with immediate address, such as
call dword ptr ds:[00923030h](described here) or analogousjmp. I can’t provide a reasonable explanation where do they come from.Distinguishing between register and memory calls is pretty easy then: just look on the operand.
If you’re interested in rootkit detection, it might be a good idea to just take some existing rootkit and look on it’s sources and generated assembly side-by-side.
I’m not very experienced with compilers and architecture so I can mistake things a little.
Hope it helps.