
On Čt 11-03-21 11:21:40, Libor Pechacek wrote:
On St 10-03-21 14:29:00, Gabriel F. T. Gomes wrote:
Hi, Libor...
You did everything right...
On Wed, 10 Mar 2021, Libor Pechacek wrote:
$ gcc -Wl,-rpath,. -L. -o main main.c -lworkload
^ ^ ... it is very unfortunate that you hit a usability bug. It would have worked if you had used $PWD instead of '.', such as:
$ gcc -Wl,-rpath,$PWD -L$PWD -o main main.c -lworkload
Indeed! Now it works! :)
Nicolai reminded me about the magic $ORIGIN token. The demo works even better with that one. Encouraged by the success, I've entertained the idea of getting rid of the LD_PRELOAD. So, I tried: $ gcc -Wl,-rpath,\$ORIGIN -Wl,-rpath,/data/src/libpulp/lib/.libs -L. \ -L ../lib/.libs/ -o main main.c -lworkload -lpulp And, voilà! I can just run "main" and live patch it without any extra hassle. Before I start exploring this possibility further, do you think that it's OK to leverage the dynamic linker for preloading libpulp? I can imagine users may want to build "live patchable" applications, and perhaps also patchable shared libraries. In that can thay may want reference libpulp from the shared library. Thoughts? Libor -- Libor Pechacek SUSE Labs Remember to have fun...