Reputation: 71
I'm creating a driver for 32 and 64 bit Linux OS. One of the requirements is that all of the code needs to be self contained with no call outs. On 64-bit I've no issues, but on 32-bit GCC seems to add a call instruction to the next byte. After searching a bit I found this link:
http://forum.soft32.com/linux/Strange-problem-disassembling-shared-lib-ftopict439936.html
Is there a way to disable this on 32-bit Linux?
Example: 32 bit disassembly:
<testfunc>:
0: push %ebp
1: mov %esp, %ebp
3: call 4 <test_func+0x4>
<...some operation on ebx as mentioned in the link above>
64 bit disassebmly:
<testfunc>:
0: push %rbp
1: mov %rsp, %rbp
3: <...no call here>
There is no call in the "testfunc" at all. Even then why is 32-bit compiler adding these "call" instructions? Any help is appreciated.
Upvotes: 2
Views: 498
Reputation: 71
This call instruction to the next byte is coming from function profiling for "gprof" tool. I was able to get rid of these "call" instruction by removing the "-pg" option from compilation.
Since it was a driver, this was being picked up from Linux kernel config - CONFIG_FUNCTION_TRACER.
Upvotes: 0
Reputation: 62086
What you're seeing in 32-bit disassembly may be a way to make the code position-independent. Remember that call
pushes onto the stack the return address, which is equal eip
+constant? In 64-bit mode there is rip
-relative addressing. In 32-bit there isn't. So this call may be simulate that instruction-pointer-relative addressing.
Upvotes: 4