Subject: Re: 'prebind' implementation
To: Bang Jun-Young <firstname.lastname@example.org>
From: Oleg Polyanski <Oleg.Polianski@team.telstraclear.co.nz>
Date: 08/28/2002 15:41:30
Bang Jun-Young <email@example.com> writes:
Before you start, could you please also consider some other sources
because the idea of the prebinding (or prelinking) tool has been
floating around for quite a while and it would be ashame to reinvent
the wheel again. Below are some links you might find useful:
I would also say that reading the gcc mailing archives for September
of 2001 is quite interesting, they discuss quite a lot of shared
object optimisation things, the keyword for search is "KDE" (do not
laugh at it, please).
It might be also worth reading IBM techbooks discussing linking,
binding, handling and loading of shared objects in AIX, even tough
we are more elvish than they are but the knowledge can be shared.
> I'm thinking about implementing 'prebind' utility. A rough idea is:
> - There is a new section in ELF called '.pplt' which stands for
> 'prebound plt'.
> - '.pplt' is generated and inserted into binaries by 'prebind'.
> - '.pplt' has resolved symbolic references, so there's no need to invoke
> dynamic linker, ld.elf_so(1), for unresolved references as current
> dynamic linking mechanism works. I expect we can get lots of time
> savings here.
> - ld.elf_so(1) should be modified accordingly. Once a dynamically
> linked binary is executed, ld.elf_so(1) first starts to analysis if
> '.pplt' in the binary is valid and applicable, and use it instead
> of '.plt'. If not, it falls back to using '.plt' (no performance
> gain in this case).
> - 'prebind' is mostly based on code from ld.elf_so(1).
> - 'prebind'ing process usually lies just before/after dynamically
> linked binaries are installed in the system (performed by
> 'make build').
> - One of limitations is that '.pplt' should be regenerated every time
> the shared objects the binary depends on are changed. Say there
> was libc.so.12.86 in /usr/lib, 'prebind' resolved symbolic
> references between /usr/bin/whoami and libc.so.12 and inserted
> '.pplt' to /usr/bin/whoami. A day you installs new libc.so.12.87 in
> /usr/lib without updating userland stuff. Symlink libc.so.12 is
> changed to point to libc.so.12.87 and '.pplt' in /usr/bin/whoami
> is no longer valid. It is still safely executed, but you can't get
> performance gain. You should run 'prebind' against all userland
> stuff which depend on libc.so.12 again.
> - There will be needed some kind of checksum mechanism to identify
> shared objects. I'm not sure if ELF has such an information as part
> of its specification (I haven't found yet).
> Any comments would be welcome and appreciated,
> Bang Jun-Young <firstname.lastname@example.org>