The presence of the cache in the dynamic link editor on GNU/Linux 386 is easily checked using the following command:
$ LD_DEBUG=statistics cat 16551: 16551: runtime linker statistics: 16551: total startup time in dynamic loader: 875905 clock cycles 16551: time needed for relocation: 626575 clock cycles (71.5%) 16551: number of relocations: 260 16551: number of relocations from cache: 99 16551: time needed to load objects: 146172 clock cycles (16.6%)
The important hint is the line labeled "number of relocations from cache". The presence of this line reveals that you have the symbol resolution cache.
The symbol resolution cache is not effective unless the shared libraries have been compiled with option -z combreloc. This is easily checked on GNU/Linux 386 using the following command:
$ readelf -S /usr/lib/libkdecore.so | grep REL
The presence of section .rel.dyn indicates that this library has been compiled with option combreloc. Otherwise you will see a number of sections named .rel.text, .rel.data, etc.
Program objprelink2 is solely designed for evaluating the benefits of the lazy resolution of virtual table entries. This is not a production tool. It works only on Linux/Intel platforms. The only reason to use it would be to quickly recompile KDE on a Linux box that does not offer the combreloc method. This will improve the responsiveness of KDE a little bit more than using the more tested combreloc method.
Program objprelink2 does not currently work with gcc-3.x.
You have been warned!
You must first obtain the source code from the Sourceforge CVS. Get instructions from the Sourceforge objprelink project page.
Use the following commands to compile objprelink2:
$ cd objprelink-2
$ configure
$ make
$ make install
You must have the BFD library available. Make sure that the BFD include file bfd.h matches the installed version of the BFD library. This will install a command named g++prelink.
To prepare a package with objprelink2, you just have to use g++prelink instead of the g++ compiler. It works on my machine and might even works for yours.
The following commands show an easy way to achieve this:
$ mkdir /tmp/bin $ ( cd /tmp/bin; ln -s /usr/local/bin/g++prelink g++ ) $ export PATH="/tmp/bin:$PATH" $ g++ -v Objprelink2 version 1.5 Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs gcc version 2.96 ...Then compile your package as usual.
Program g++prelink usually invokes the g++ compiler with the same arguments. However, when preparing a shared library, it performs the following steps:
Firstly, the virtual table entries should directly point to the PLT stub instead of using a relay stub in the text section. The relay stub is currently used by the post-processor to locate the relevant PLT stubs and also to generate dummy relocations to patch the PLT entries.
Secondly, the GNU linker seems unable to merge read-only constants during the incremental link step. This buglet uselessly increases the size of the data section.
Implementing the same ideas inside the GNU linker would suppress the need for the ten byte relay stubs, and also benefit from merged read-only constants.