Skip to content

x86inc: Improve ELF PIC support for external function calls

Henrik Gramner requested to merge gramner/x264:x86inc_elf_ext_pic_call into master

PLT/GOT indirections are required in some cases. Most commonly when calling functions from other shared libraries, but also in some scenarios when calling functions with default symbol visibility even within the same component on certain elf64 platforms.

On elf64 we can simply use PLT relocations for all calls to external functions. Since the linker is able to eliminate unnecessary PLT indirections with the final output binary being identical to non-PLT relocations there isn't really any downside to doing so. This mimics what regular compilers normally do for calls to external functions.

On elf32 with PIC we can use a function pointer from the GOT when calling external functions, similar to what regular compilers do when using -fno-plt. Since this both introduces overhead and clobbers one register, which could potentially have been used for custom calling conventions when calling other asm functions within the same library, it's only performed for functions declared using 'cextern_naked'.

Merge request reports