Bug 89637

Summary: Valgrind can't find .so via embedded rpath with $ORIGIN
Product: [Developer tools] valgrind Reporter: Frank Wallingford <frank.wallingford>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: NOR    
Version: 2.2.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Frank Wallingford 2004-09-16 17:07:07 UTC
Starting with (I think) valgrind 2.1.2, valgrind no longer finds shared
libraries via the rpath embedded in the executable if it contains a reference to
$ORIGIN. Valgrind 2.0 worked, and I've also tested 2.2.0, which does not work.

If the embedded path is absolute (does not use $ORIGIN), it works fine.

Example:

shared.c:
  int foo() { return 42; }

test.c:
  extern int foo();
  int main() { return foo(); }

$ cd /tmp
$ gcc -shared shared.c -o libshared.so
$ gcc test.c -o test -L. -lshared -Wl,-rpath,'$ORIGIN'
$ cd ~
$ ldd /tmp/test
$ /tmp/test
$ valgrind --tool=memcheck /tmp/test

My system:

$ uname -a
Linux topgun 2.6.8-1-mts #8 Mon Aug 16 15:42:31 EDT 2004 i686 Pentium III
(Coppermine) unknown GNU/Linux

$ valgrind --version
valgrind-2.2.0

$ gcc --version
gcc (GCC) 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)
Comment 1 Tom Hughes 2004-09-25 12:18:34 UTC
This happens because glibc does a readlink on /proc/self/exe in order to resolve $ORIGIN for an executable and as we know from bug 86921 that doesn't work under valgrind.

*** This bug has been marked as a duplicate of 86921 ***