Vous pouvez trouver une version en français ici

Addrpath, a tool to add an arbitrary rpath to an ELF executable

About addrpath

For the moment this tool works on normal and PIE executables. Unfortunately, the linux kernel has an incorrect support of ELF, so it needs a patch (restoring a correct behaviour) to work. There is a workaround for non patched kernels, but it tends to make programs segfault(2007-05-27 : Seems corrected). Addrpath should work on all 32 bits targets of linux, and for a 64 bits architecture porting it should be as simple as :
sed 's/32/64/g' addrpath.c > addrpath64.c
The libbfd has bad assumptions about locations of some sections, so don't try to strip binaries passed through addrpath.

2007-06-04 Update : This tool seems to work out of the box on OpenBSD, with very small changes to the code (but not to the principle, and no hack seems necessary). define -DBSD.

Instructions

What is it?

That's a small utility which allows one to add an arbitrary rpath to an ELF binary.

Where?

Here : ftp://quatramaran.ens.fr/pub/quentin/addrpath (the most recent is addrpath.c). You will also find the kernel patch there.

Compiling

gcc -std=c99 -Wextra -Wall -O3 -o addrpath addrpath.c
If you really want to try it on a non patched kernel, you can add a -DBROKEN_KERNEL, but it does not work well.

2007-05-27 Update : It should work better now (but seems still broken on PIE. ld.so fault?)
2007-06-04 Update : please define -DBSD if you want to try it on OpenBSD (i tried it just a bit so this is experimental. But isn't all this experimental?)

Usage

./addrpath file rpath newfile

How does it work?

The program moves the .dynstr section to the end of loaded data, cats the new rpath to it, moves the program headers there, adds a PT_LOAD segment to load the new dynstr and the dynamic table. If necessary it also moves the .dynamic section to add the rpath tag. The old sections are renamed in .olddynstr and if applicable .olddynamic, and the type of .olddynamic is changed into PROGBITS.

To Do

Recognize an executable which has already passed through addrpath.

Check to see if the present rpath has enough room to fit the new one.

Bugs

Please report them.