summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-08-19 14:15:39 +0000
committerEric Andersen <andersen@codepoet.org>2003-08-19 14:15:39 +0000
commit274c1217a4519c9b310ec9c9810ab0a801628cfe (patch)
tree7282332ea72da9dbf44e668a944476fb0fbbddfc /ldso
parentfebf8aecdc7a78b49bf955748f45711b08d5bee6 (diff)
I just realized we need global symbol resolution for everything in
a chain of dependent libraries or libraries that depend on other shared libraries will not work! So with a well placed dyn_chain->flags |= RTLD_GLOBAL; everything is now working perfectly!!! Sweet!!!! This patch also removes some leftover junk from my previous efforts.
Diffstat (limited to 'ldso')
-rw-r--r--ldso/libdl/dlib.c66
-rw-r--r--ldso/libdl/libdl.c66
2 files changed, 10 insertions, 122 deletions
diff --git a/ldso/libdl/dlib.c b/ldso/libdl/dlib.c
index 9ca624962..6d287a794 100644
--- a/ldso/libdl/dlib.c
+++ b/ldso/libdl/dlib.c
@@ -127,7 +127,6 @@ void *_dlopen(const char *libname, int flag)
struct dyn_elf *dpnt;
static int dl_init = 0;
ElfW(Addr) from;
- const char *libname1, *libname2, *ptr;
struct elf_resolve *tpnt1;
void (*dl_brk) (void);
@@ -167,33 +166,6 @@ void *_dlopen(const char *libname, int flag)
tfrom = tpnt;
}
- /* Skip over any initial initial './' and '/' stuff to
- * get the short form libname with no path garbage */
- libname1 = libname;
- ptr = _dl_strrchr(libname1, '/');
- if (ptr) {
- libname1 = ptr + 1;
- }
-
-
- /* Weed out duplicates early to avoid function aliasing */
- for (tpnt1 = _dl_loaded_modules; tpnt1; tpnt1 = tpnt1->next) {
- /* Skip over any initial initial './' and '/' stuff to
- * get the short form libname with no path garbage */
- libname2 = tpnt1->libname;
- ptr = _dl_strrchr(libname2, '/');
- if (ptr) {
- libname2 = ptr + 1;
- }
-
- if (_dl_strcmp(libname1, libname2) == 0) {
- /* Well, that was certainly easy */
- return tpnt1;
- }
- }
-
-
-
/* Try to load the specified library */
#ifdef __SUPPORT_LD_DEBUG__
_dl_dprintf(_dl_debug_file, "Trying to dlopen '%s'\n", (char*)libname);
@@ -223,6 +195,7 @@ void *_dlopen(const char *libname, int flag)
{
Elf32_Dyn *dpnt;
char *lpntstr;
+ const char *libname1, *ptr;
for (dpnt = (Elf32_Dyn *) tcurr->dynamic_addr; dpnt->d_tag; dpnt++) {
if (dpnt->d_tag == DT_NEEDED) {
lpntstr = (char*)tcurr->loadaddr + tcurr->dynamic_info[DT_STRTAB] +
@@ -243,46 +216,19 @@ void *_dlopen(const char *libname, int flag)
goto oops;
}
-#if 0
- {
- struct elf_resolve *tpnt2;
- /* Weed out duplicates early to avoid function aliasing */
- for (tpnt2 = _dl_loaded_modules; tpnt2; tpnt2 = tpnt2->next) {
- /* Skip over any initial initial './' and '/' stuff to
- * get the short form libname with no path garbage */
- libname2 = tpnt2->libname;
- ptr = _dl_strrchr(libname2, '/');
- if (ptr) {
- libname2 = ptr + 1;
- }
-
- if (_dl_strcmp(libname1, libname2) == 0) {
- /* Well, that was certainly easy */
-#ifdef __SUPPORT_LD_DEBUG__
- _dl_dprintf(_dl_debug_file, "\tLibrary '%s' needed by '%s' "
- "already loaded\n", lpntstr, tcurr->libname);
-#endif
- continue;
- }
- }
- }
-#endif
#ifdef __SUPPORT_LD_DEBUG__
_dl_dprintf(_dl_debug_file, "Trying to load '%s', needed by '%s'\n",
lpntstr, tcurr->libname);
#endif
-#if 1
if (!(tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr))) {
goto oops;
}
-#else
- if (!(tpnt1 = _dlopen(lpntstr, flag))) {
- goto oops;
- }
-#endif
+ /* We need global symbol resolution for everything
+ * in the dependent chain */
+ dyn_chain->flags |= RTLD_GLOBAL;
rpnt->next = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
_dl_memset (rpnt->next, 0, sizeof (struct dyn_elf));
@@ -315,7 +261,7 @@ void *_dlopen(const char *libname, int flag)
* Now we go through and look for REL and RELA records that indicate fixups
* to the GOT tables. We need to do this in reverse order so that COPY
* directives work correctly */
- if (_dl_fixup(dyn_chain->dyn, (flag & RTLD_LAZY)))
+ if (_dl_fixup(dyn_chain->dyn, (dyn_chain->flags & RTLD_LAZY)))
goto oops;
#ifdef __SUPPORT_LD_DEBUG__
@@ -343,11 +289,9 @@ void *_dlopen(const char *libname, int flag)
}
}
-#if 1
#ifdef __SUPPORT_LD_DEBUG__
_dlinfo();
#endif
-#endif
#ifdef __PIC__
/* Find the last library so we can run things in the right order */
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 9ca624962..6d287a794 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -127,7 +127,6 @@ void *_dlopen(const char *libname, int flag)
struct dyn_elf *dpnt;
static int dl_init = 0;
ElfW(Addr) from;
- const char *libname1, *libname2, *ptr;
struct elf_resolve *tpnt1;
void (*dl_brk) (void);
@@ -167,33 +166,6 @@ void *_dlopen(const char *libname, int flag)
tfrom = tpnt;
}
- /* Skip over any initial initial './' and '/' stuff to
- * get the short form libname with no path garbage */
- libname1 = libname;
- ptr = _dl_strrchr(libname1, '/');
- if (ptr) {
- libname1 = ptr + 1;
- }
-
-
- /* Weed out duplicates early to avoid function aliasing */
- for (tpnt1 = _dl_loaded_modules; tpnt1; tpnt1 = tpnt1->next) {
- /* Skip over any initial initial './' and '/' stuff to
- * get the short form libname with no path garbage */
- libname2 = tpnt1->libname;
- ptr = _dl_strrchr(libname2, '/');
- if (ptr) {
- libname2 = ptr + 1;
- }
-
- if (_dl_strcmp(libname1, libname2) == 0) {
- /* Well, that was certainly easy */
- return tpnt1;
- }
- }
-
-
-
/* Try to load the specified library */
#ifdef __SUPPORT_LD_DEBUG__
_dl_dprintf(_dl_debug_file, "Trying to dlopen '%s'\n", (char*)libname);
@@ -223,6 +195,7 @@ void *_dlopen(const char *libname, int flag)
{
Elf32_Dyn *dpnt;
char *lpntstr;
+ const char *libname1, *ptr;
for (dpnt = (Elf32_Dyn *) tcurr->dynamic_addr; dpnt->d_tag; dpnt++) {
if (dpnt->d_tag == DT_NEEDED) {
lpntstr = (char*)tcurr->loadaddr + tcurr->dynamic_info[DT_STRTAB] +
@@ -243,46 +216,19 @@ void *_dlopen(const char *libname, int flag)
goto oops;
}
-#if 0
- {
- struct elf_resolve *tpnt2;
- /* Weed out duplicates early to avoid function aliasing */
- for (tpnt2 = _dl_loaded_modules; tpnt2; tpnt2 = tpnt2->next) {
- /* Skip over any initial initial './' and '/' stuff to
- * get the short form libname with no path garbage */
- libname2 = tpnt2->libname;
- ptr = _dl_strrchr(libname2, '/');
- if (ptr) {
- libname2 = ptr + 1;
- }
-
- if (_dl_strcmp(libname1, libname2) == 0) {
- /* Well, that was certainly easy */
-#ifdef __SUPPORT_LD_DEBUG__
- _dl_dprintf(_dl_debug_file, "\tLibrary '%s' needed by '%s' "
- "already loaded\n", lpntstr, tcurr->libname);
-#endif
- continue;
- }
- }
- }
-#endif
#ifdef __SUPPORT_LD_DEBUG__
_dl_dprintf(_dl_debug_file, "Trying to load '%s', needed by '%s'\n",
lpntstr, tcurr->libname);
#endif
-#if 1
if (!(tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr))) {
goto oops;
}
-#else
- if (!(tpnt1 = _dlopen(lpntstr, flag))) {
- goto oops;
- }
-#endif
+ /* We need global symbol resolution for everything
+ * in the dependent chain */
+ dyn_chain->flags |= RTLD_GLOBAL;
rpnt->next = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
_dl_memset (rpnt->next, 0, sizeof (struct dyn_elf));
@@ -315,7 +261,7 @@ void *_dlopen(const char *libname, int flag)
* Now we go through and look for REL and RELA records that indicate fixups
* to the GOT tables. We need to do this in reverse order so that COPY
* directives work correctly */
- if (_dl_fixup(dyn_chain->dyn, (flag & RTLD_LAZY)))
+ if (_dl_fixup(dyn_chain->dyn, (dyn_chain->flags & RTLD_LAZY)))
goto oops;
#ifdef __SUPPORT_LD_DEBUG__
@@ -343,11 +289,9 @@ void *_dlopen(const char *libname, int flag)
}
}
-#if 1
#ifdef __SUPPORT_LD_DEBUG__
_dlinfo();
#endif
-#endif
#ifdef __PIC__
/* Find the last library so we can run things in the right order */