Consider the following function:
extern void test1(void);extern void test2(void) { test1();}
This is the code gcc generates without -fpic
on amd64 Linux:
test2: jmp test1
When I compile with -fpic
, gcc explicitly calls through the PLT to enable symbol interposition:
test2: jmp test1@PLT
This however is not strictly needed for position independent code and could be left out if I don't want to support. If necessary, the linker rewrites the jump target to the PLT symbol anyway.
How can I, without changing the source code and without making the compiled code unsuitable for a shared library, make function calls go directly to their targets instead of going explicitly through the PLT?