Sources Bugzilla – Bug 344
Bogus dl test: elf/tst-dlopenrpath.c and elf/tst-dlopenrpathmod.c
Last modified: 2004-09-12 19:28:46 UTC
Either elf/tst-dlopenrpath.c is bogus or open_path in elf/dl-load.c is wrong. open_path has /* Try to open NAME in one of the directories in *DIRSP. Return the fd, or -1. If successful, fill in *REALNAME with the malloc'd full directory name. If it turns out that none of the directories in *DIRSP exists, *DIRSP is replaced with (void *) -1, and the old value is free()d if MAY_FREE_DIRS is true. */ static int open_path (const char *name, size_t namelen, int preloaded, struct r_search_path_struct *sps, char **realname, struct filebuf *fbp) So when a DSO has a DT_RPATH which isn't used to locate a DT_NEEDED entry, that DT_RPATH may be ignored for this DSO later on for any dlopen calls made from the DSO. elf/tst-dlopenrpathmod.c has xxxxx (RPATH) Library rpath: [$ORIGIN/test-subdir] If DT_RPATH is searched when loading tst-dlopenrpathmod.so for some reason, DT_RPATH will be ignored for dlopen calls in tst-dlopenrpathmod.so. I got couldn't open in-subdir.so from foo
Created attachment 172 [details] A testcase gcc -c -fPIC -g -O2 -D_LARGEFILE64_SOURCE tst-dlopenrpathmod.c gcc -shared -o tst-dlopenrpathmod.so tst-dlopenrpathmod.o -ldl -lpopt -Wl,-rpath,/export/home/hjl/bugs/libc/dl/test-subdir gcc -o foo -g -O2 -D_LARGEFILE64_SOURCE tst-dlopenrpath.c /export/home/hjl/bugs/libc/dl/tst-dlopenrpathmod.so -ldl rm -rf test-subdir cp -af tst-dlopenrpathmod.so firstobj.so /export/build/gnu/glibc-nptl-3.4/build-i686-linux/elf/ld-linux.so.2 --library-path /export/build/gnu/glibc-nptl-3.4/build-i686-linux:/export/build/gnu/glibc-nptl-3.4/build-i686-linux/dlfcn ./foo couldn't open in-subdir.so from foo: in-subdir.so: cannot open shared object file: No such file or directory make: [all] Error 1 (ignored) /export/build/gnu/glibc-nptl-3.4/build-i686-linux/elf/ld-linux.so.2 --library-path /export/build/gnu/glibc-nptl-3.4/build-i686-linux:/export/build/gnu/glibc-nptl-3.4/build-i686-linux/dlfcn ./foo
*** This bug has been marked as a duplicate of 333 ***