0
  1. LD_LIBRARY_PATH=/otherRoot/lib/ valgrind myProg
  2. chroot /otherRoot valgrind myProg

When running the first command, valgrind gives me errors about a stripped dynamic linker because it apparently is not using the one in /otherRoot/lib. Using the second command, it finds my the appropriate .so and works.

For reference, I have valgrind installed in the "normal root" and "otherRoot" as well.

Why does valgrind/myProg not search for the .so in /otherRoot/lib first?

user2725742
  • 398
  • 2
  • 12

1 Answers1

0

When running the first command, valgrind gives me errors about a stripped dynamic linker because it apparently is not using the one in /otherRoot/lib.

The dynamic loader your program uses doesn't (can't) depend on LD_LIBRARY_PATH, because it is the kernel the loads the dynamic loader (and the kernel generally doesn't care about environment variables). More info here.

Outside of chroot, the "wrong" dynamic loader is used with or without valgrind. You can confirm this by pausing myProg and examining /proc/$PID/maps for it.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362