Skip to content

Prelink

Shane Peelar edited this page Apr 14, 2020 · 1 revision

GentooLTO Prelink

The default GentooLTO configuration uses lazy binding for symbol resolution. This helps with program startup time, but requires the use of a PLT.

Another apporoach is to use -fno-plt in your CFLAGS, which eliminates the PLT from your executables. This inhibits lazy binding, so all symbols are resolved at program startup time, which will of course increase your startup times. It has the benefit of making shared library calls faster, however, since they go through only the GOT and not the PLT.

One way to improve startup times with -fno-plt is to use Gentoo Prelink. It requires the -99999999 version from Portage with a patch that allows it to work with -fno-plt executables. This patch has been submitted upstream but is also included here, alongside another patch to help with glibc 2.31 compatibility.

Using prelink, startup times should be on par with lazy binding when using -fno-plt.

Beware that prelink isn't well supported -- you use it at your own risk and it is possible to break your system with it! So far, it seems to be stable on my own system, but YMMV!