[uClibc-cvs] svn commit: trunk/uClibc/ldso: include ldso libdl
jocke at uclibc.org
jocke at uclibc.org
Wed Jun 1 14:08:14 UTC 2005
Author: jocke
Date: 2005-06-01 08:08:13 -0600 (Wed, 01 Jun 2005)
New Revision: 10445
Log:
Initial support for both RUNPATH support.
RPATH sematics changed to match RUNPATH. Only difference is
that RPATH is searched before LD_LIBRARY_PATH and RUNPATH
after. This is not complete but better than the current mess(I think).
Modified:
trunk/uClibc/ldso/include/dl-elf.h
trunk/uClibc/ldso/ldso/dl-elf.c
trunk/uClibc/ldso/libdl/libdl.c
Changeset:
Modified: trunk/uClibc/ldso/include/dl-elf.h
===================================================================
--- trunk/uClibc/ldso/include/dl-elf.h 2005-05-31 16:26:04 UTC (rev 10444)
+++ trunk/uClibc/ldso/include/dl-elf.h 2005-06-01 14:08:13 UTC (rev 10445)
@@ -84,6 +84,10 @@
dynamic_info[DT_BIND_NOW] = 1;
if (dpnt->d_tag == DT_TEXTREL)
dynamic_info[DT_TEXTREL] = 1;
+ if (dpnt->d_tag == DT_RUNPATH)
+ dynamic_info[DT_RPATH] = 0;
+ if (dpnt->d_tag == DT_RPATH && dynamic_info[DT_RUNPATH])
+ dynamic_info[DT_RPATH] = 0;
} else if (dpnt->d_tag < DT_LOPROC) {
if (dpnt->d_tag == DT_RELOCCOUNT)
dynamic_info[DT_RELCONT_IDX] = dpnt->d_un.d_val;
Modified: trunk/uClibc/ldso/ldso/dl-elf.c
===================================================================
--- trunk/uClibc/ldso/ldso/dl-elf.c 2005-05-31 16:26:04 UTC (rev 10444)
+++ trunk/uClibc/ldso/ldso/dl-elf.c 2005-06-01 14:08:13 UTC (rev 10445)
@@ -304,23 +304,17 @@
}
/*
- * The ABI specifies that RPATH is searched before LD_*_PATH or
+ * The ABI specifies that RPATH is searched before LD_LIBRARY_PATH or
* the default path of /usr/lib. Check in rpath directories.
*/
- for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
- if (tpnt->libtype == elf_executable) {
- pnt = (char *) tpnt->dynamic_info[DT_RPATH];
- if (pnt) {
- pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
+ pnt = (tpnt ? (char *) tpnt->dynamic_info[DT_RPATH] : NULL);
+ if (pnt) {
+ pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
#if defined (__SUPPORT_LD_DEBUG__)
- if(_dl_debug) _dl_dprintf(_dl_debug_file, "\tsearching RPATH='%s'\n", pnt);
+ if(_dl_debug) _dl_dprintf(_dl_debug_file, "\tsearching RPATH='%s'\n", pnt);
#endif
- if ((tpnt1 = search_for_named_library(libname, secure, pnt, rpnt)) != NULL)
- {
- return tpnt1;
- }
- }
- }
+ if ((tpnt1 = search_for_named_library(libname, secure, pnt, rpnt)) != NULL)
+ return tpnt1;
}
/* Check in LD_{ELF_}LIBRARY_PATH, if specified and allowed */
@@ -333,6 +327,18 @@
return tpnt1;
}
}
+ /*
+ * The ABI specifies that RUNPATH is searched after LD_LIBRARY_PATH.
+ */
+ pnt = (tpnt ? (char *)tpnt->dynamic_info[DT_RUNPATH] : NULL);
+ if (pnt) {
+ pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
+#if defined (__SUPPORT_LD_DEBUG__)
+ if(_dl_debug) _dl_dprintf(_dl_debug_file, "\tsearching RUNPATH='%s'\n", pnt);
+#endif
+ if ((tpnt1 = search_for_named_library(libname, secure, pnt, rpnt)) != NULL)
+ return tpnt1;
+ }
/*
* Where should the cache be searched? There is no such concept in the
Modified: trunk/uClibc/ldso/libdl/libdl.c
===================================================================
--- trunk/uClibc/ldso/libdl/libdl.c 2005-05-31 16:26:04 UTC (rev 10444)
+++ trunk/uClibc/ldso/libdl/libdl.c 2005-06-01 14:08:13 UTC (rev 10445)
@@ -128,7 +128,7 @@
void *dlopen(const char *libname, int flag)
{
- struct elf_resolve *tpnt, *tfrom, *tcurr=NULL;
+ struct elf_resolve *tpnt, *tfrom;
struct dyn_elf *dyn_chain, *rpnt = NULL, *dyn_ptr, *relro_ptr, *handle;
struct dyn_elf *dpnt;
ElfW(Addr) from;
@@ -155,7 +155,7 @@
/*
* Try and locate the module we were called from - we
- * need this so that we get the correct RPATH. Note that
+ * need this so that we get the correct RPATH/RUNPATH. Note that
* this is the current behavior under Solaris, but the
* ABI+ specifies that we should only use the RPATH from
* the application. Thus this may go away at some time
@@ -239,7 +239,7 @@
fprintf(stderr, "Trying to load '%s', needed by '%s'\n",
lpntstr, runp->tpnt->libname);
#endif
- tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr, 0);
+ tpnt1 = _dl_load_shared_library(0, &rpnt, runp->tpnt, lpntstr, 0);
if (!tpnt1)
goto oops;
More information about the uClibc-cvs
mailing list