Subject: Re: New idea on ELF prebinding
To: Luke Mewburn <>
From: Bang Jun-Young <>
List: tech-userlevel
Date: 11/22/2002 16:27:30
On Fri, Nov 22, 2002 at 05:48:43PM +1100, Luke Mewburn wrote:
> On Fri, Nov 22, 2002 at 03:18:28PM +0900, Bang Jun-Young wrote:
>   | Here's the summary of what I have been thinking about ELF prebinding
>   | since a couple times of objections from people against my previous
>   | not-good implementation ;-):
> some minor issues.
>   | - Every binary, including executable and shared object, has .csum
>   |   section inserted by ld(1) at compile time. It is 32-bit long and
>   |   used for storing checksum (CRC32) of the binary.
> i'd prefer md5 or sha1 as a hash.

The basic idea is to use the checksum as a filename to lookup. For
example, if the checksum is FB369ADB, then ld.elf_so(1) tries to
find a file of the same name in /usr/libdata/reloc. So you don't
have to worry about moving binaries.

I thought about MD5 as well, but it is too long to be used as a file
name. Probably a better method would be needed...

>   | - Actual prebinding and prerelocation is done by ld.elf_so(1). After 
>   |   ld.elf_so(1) loads a binary for the first time, it creates a disk
>   |   file in /usr/libexec/reloc (say it "cache") and writes all of the
> /var/db/reloc (persistent) or /var/run/reloc (lost at reboot) are
> better locations...

(Euch, it was a typo. /usr/libexec/reloc -> /usr/libdata/reloc).

/var/db/reloc is good.

>   |   relocated GOT and PLT sections in memory to the file (checksum and
>   |   other necessary information as well). In any subsequent execution
>   |   of the same binary, ld.elf_so(1) no longer performs relocation.
>   |   Instead it loads cache from the disk file previously created and
>   |   compares cache information and in-memory data. If they don't differ,
>   |   it patches GOT/PLT pointers so that they point to locations in the
>   |   cache. But if they differ, ld.elf_so(1) will do the same job. 
>   | 
>   | - As time goes by, there will be more caches stored in /usr/libexec/reloc.
>   |   If needed, elfreld(1) daemon regularly check if they are still valid, and
>   |   removes invalid files. Or you can remove all of them, and ld.elf_so(1)
>   |   will perform the same job again for each binary it loads.
> do we even need an elfreld daemon?  does it matter if the cache grows.

So that someone won't complain about ever-growing cache directory. ;-)

Thanks for your comments,


Bang Jun-Young <>