Consider the following function:
extern void test1(void);
extern void test2(void) {
test1();
}
This is the code gcc generates without
If you can't change the source code, you could use a big-hammer: -Bsymbolic linker flag:
When creating a shared library, bind references to global symbols to the definition within the shared library, if any. Normally, it is possible for a program linked against a shared library to override the definition within the shared library. This option is only meaningful on ELF platforms which support shared libraries.
But beware that it will break if some parts of the library rely on symbol interposition. I'd recommend to go with hiding functions that don't need to be exported (by annotating them with __attribute__((visibility("hidden")))
) or calling them through hidden aliases (specifically designed to do PLT-less intra-library calls in a controlled fashion).