Shared objects (* .so) on Unix-like systems are inefficient due to character interpolation: every access to the global variable inside .so requires a GOT search and every call from one function to another inside .so requires a PLT search. So I was glad to see that gcc version 5.1 added the -fno-semantic-interposition option. However, when I try to do .so, when one function calls another without using PLT, I get an error:
moving R_X86_64_PC32 with the symbol `functionname 'cannot be used when creating a shared object; recompile with -fPIC
I expected the -fno-semantic-interposition option to clear this error message, but it is not. -mcmodel = large doesn't help either. The reference to the function is really position-independent, which actually confirms the error message (R_X86_64_PC32 means transferring 32-bit 32-bit in 64-bit mode). -fPIC does not really mean position independence, as it implies a name, it actually means using GOT and PLT.
I cannot use __attribute__((visibility ("hidden")))
because the called function and the calling object are compiled in separate files (the calling object is in C ++, called the function in assembly).
I tried to make a list of assemblies to see what the -fno-semantic-interposition option does. I found out that it refers to a local alias when one function calls another in one file, but when calling a function in another file, it still uses PLT.
(g ++ version is 5.2.1 Ubuntu, 64-bit mode).
Is there a way to get the linker to cross-reference inside .so without looking for a GOT / PLT?
source share