Просмотр исходного кода

Use executables RPATH/RUNPATH when searching for libraries.

Patch by Steve Ellcey <sellcey@imgtec.com> on uClibc mailinglist.
Waldemar Brodkorb 11 лет назад
Родитель
Сommit
9728de1929
2 измененных файлов с 21 добавлено и 0 удалено
  1. 9 0
      extra/Configs/Config.in
  2. 12 0
      ldso/ldso/dl-elf.c

+ 9 - 0
extra/Configs/Config.in

@@ -420,6 +420,15 @@ config LDSO_RUNPATH
 	  Usage of RUNPATH tags is not too common, so disabling this feature
 	  Usage of RUNPATH tags is not too common, so disabling this feature
 	  should be safe for most people.
 	  should be safe for most people.
 
 
+config LDSO_RUNPATH_OF_EXECUTABLE
+	bool "Use executables RPATH/RUNPATH when searching for libraries."
+	depends on LDSO_RUNPATH
+	default n
+	help
+	  Use the executables RPATH/RUNPATH to find to find libraries even
+	  though this behavour is not standard.  Setting this option causes
+	  the uclibc dynamic linker behavour to match the glibc dynamic linker.
+
 config LDSO_SAFE_RUNPATH
 config LDSO_SAFE_RUNPATH
 	bool "Allow only RUNPATH beginning with /"
 	bool "Allow only RUNPATH beginning with /"
 	depends on LDSO_RUNPATH
 	depends on LDSO_RUNPATH

+ 12 - 0
ldso/ldso/dl-elf.c

@@ -266,6 +266,18 @@ struct elf_resolve *_dl_load_shared_library(unsigned rflags, struct dyn_elf **rp
 		if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt, NULL)) != NULL)
 		if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt, NULL)) != NULL)
 			return tpnt1;
 			return tpnt1;
 	}
 	}
+#ifdef __LDSO_RUNPATH_OF_EXECUTABLE__
+        /*
+         * Try the DT_RPATH of the executable itself.
+         */
+        pnt = (char *) _dl_loaded_modules->dynamic_info[DT_RPATH];
+        if (pnt) {
+                pnt += (unsigned long) _dl_loaded_modules->dynamic_info[DT_STRTAB];
+                _dl_if_debug_dprint("\tsearching exe's RPATH='%s'\n", pnt);
+                if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL)
+                        return tpnt1;
+        }
+#endif
 #endif
 #endif
 
 
 	/*
 	/*