1 |
DISCLAIMER: Prelink is experimental and ^may^ break EVERYTHING |
2 |
( having said this I have suffered no serious breakages, but others |
3 |
have) |
4 |
|
5 |
Recently I have started working on prelinking in gentoo. |
6 |
|
7 |
When a shared executable is run all the references to functions in |
8 |
shared libraries have to be cross referenced and offsets applied to the |
9 |
function pointers. Prelink modifies the executables so that this work is |
10 |
done before the binary is run. This speeds start up times by a large |
11 |
factor (up to 50% for some applications like mozilla and KDE). |
12 |
|
13 |
To use prelink you need a prelink enabled glibc (2.3.1 satisfies this), |
14 |
and a new version of binutils (2.13.90.0.10 will do). |
15 |
|
16 |
I have put a masked prelink ebuild into portage, this provides the tool |
17 |
that modifies the binaries. Emerge it and read "man prelink" for more |
18 |
details. |
19 |
|
20 |
Now the portage details: |
21 |
|
22 |
Prelink needs to be rerun on shared librarys and executables every time |
23 |
their dependant librarys get modified. So when you upgrade a library |
24 |
prelink needs to be rerun on the executables. This means the md5sum of a |
25 |
binary will change from the portage digest. |
26 |
|
27 |
There is a work around for that, prelink has the ability to spool out |
28 |
the original binary's contents to stdout. This can be harnessed by |
29 |
portage. The details how to do so follow: |
30 |
|
31 |
On Install: |
32 |
1) The MD5sun is first calculated for the CONTENTS file |
33 |
2) The files are merged (installed) into the filesystem |
34 |
3) prelink is run on all the installed binaries and libraries |
35 |
|
36 |
On Uninstall: |
37 |
* If the file is an executable / library pipe it though prelink when |
38 |
calculating the MD5sum. |
39 |
|
40 |
All the above would be ifdefed out if some PRELINK_ENABLE variable was |
41 |
not set somewhere (eg. make.global), so there will be no slowdown for |
42 |
ppl not using prelink. |
43 |
|
44 |
Note: the prelink command cannot be put in |
45 |
/usr/lib/portage/bin/prepallstrip as prelink may have to be rerun on the |
46 |
file causing the MD5sum to change again. |
47 |
|
48 |
Also some small bash script needs to be made to allow the user to |
49 |
re-prelink files after a library upgrade. Prelinking doesn't take long, |
50 |
prelinking from scratch /usr/bin only takes a few minutes. This could be |
51 |
in a cron-job or manually run by the user though a new portage command. |
52 |
|
53 |
Note: re-prelinking a file is very quick, so it may be feasible to |
54 |
prelink all dependants in emerge after the library install. But this |
55 |
would require reverse dependency checking. |
56 |
|
57 |
Once the details are fixed, I will happing code this up and submit the |
58 |
patches. |
59 |
|
60 |
Food for thought, |
61 |
|
62 |
Stefan |
63 |
|
64 |
-- |
65 |
Stefan Jones <cretin@g.o> |
66 |
Gentoo Linux |
67 |
|
68 |
|
69 |
-- |
70 |
gentoo-dev@g.o mailing list |