View Single Post
Old 04-08-09, 12:59 AM   #5
polpo
Registered User
 
Join Date: Mar 2004
Posts: 8
Default Re: libGL.so.1 "takes over" dynamic library loading

A testcase is attached. It generates two executables, one that links against libGL, and one that doesn't. The executable calls a function inside liblib1.so, which then calls dlopen on liblib2.so, which is in a different directory. The different RPATHs on the main executable and the liblib1.so lets everything find what it needs.

177 program output:
Code:
iscott@iscott-laptop:~/work/dlopen-testcase> ./main-gl
Found liblib2.so.
iscott@iscott-laptop:~/work/dlopen-testcase> ./main-nogl
Found liblib2.so.
177 LD_DEBUG output:
Code:
      8520:	file=liblib2.so [0];  needed by /home/iscott/work/dlopen-testcase/liblib1.so [0]
      8520:	find library=liblib2.so [0]; searching
      8520:	 search path=/home/iscott/work/dlopen-testcase/lib2/tls/x86_64:/home/iscott/work/dlopen-testcase/lib2/tls:/home/iscott/work/dlopen-testcase/lib2/x86_64:/home/iscott/work/dlopen-testcase/lib2		(RPATH from file /home/iscott/work/dlopen-testcase/liblib1.so)
180 program output:
Code:
iscott@iscott-laptop:~/work/dlopen-testcase> ./main-gl
Could not find liblib2.so.
iscott@iscott-laptop:~/work/dlopen-testcase> ./main-nogl
Found liblib2.so.
180 LD_DEBUG output:
Code:
     10413:	file=liblib2.so [0];  needed by /usr/lib64/libGL.so.1 [0]
     10413:	find library=liblib2.so [0]; searching
     10413:	 search path=/home/iscott/work/dlopen-testcase		(RPATH from file ./main-gl)
If libGL is wrapping dlopen, that means that the RPATH of the library doing the dlopen call will be ignored, and instead the RPATH of the main executable is used. This presents a problem and I don't see any way around it aside from not wrapping dlopen.
Attached Files
File Type: gz dlopen-testcase.tar.gz (656 Bytes, 59 views)

Last edited by polpo; 04-08-09 at 02:01 PM. Reason: fix paths
polpo is offline   Reply With Quote