summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
Diffstat (limited to 'ldso')
-rw-r--r--ldso/ldso/dl-elf.c7
-rw-r--r--ldso/ldso/ldso.c37
-rw-r--r--ldso/libdl/libdl.c22
3 files changed, 19 insertions, 47 deletions
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 089fca986..558eeaa20 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -273,13 +273,14 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
if (pnt1) {
libname = pnt1 + 1;
}
-#if 0
+
/* Critical step! Weed out duplicates early to avoid
* function aliasing, which wastes memory, and causes
* really bad things to happen with weaks and globals. */
- if ((tpnt1=_dl_check_if_named_library_is_loaded(libname, trace_loaded_objects))!=NULL)
+ if ((tpnt1=_dl_check_if_named_library_is_loaded(libname, trace_loaded_objects))!=NULL) {
+ tpnt1->usage_count++;
return tpnt1;
-#endif
+ }
#if defined (__SUPPORT_LD_DEBUG__)
if(_dl_debug) _dl_dprintf(_dl_debug_file, "\tfind library='%s'; searching\n", libname);
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 17ee2c5d6..54da613aa 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -411,11 +411,6 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
*str2 = '\0';
if (!_dl_secure || _dl_strchr(str, '/') == NULL) {
- if ((tpnt1 = _dl_check_if_named_library_is_loaded(str, trace_loaded_objects))) {
- tpnt1->usage_count++;
- goto next_lib;
- }
-
#if defined (__SUPPORT_LD_DEBUG__)
if(_dl_debug)
_dl_dprintf(_dl_debug_file,
@@ -458,7 +453,6 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
}
}
-next_lib:
*str2 = c;
str = str2;
while (*str == ':' || *str == ' ' || *str == '\t')
@@ -515,12 +509,6 @@ next_lib:
/*nada */ ;
c = *cp;
*cp = '\0';
-
- if ((tpnt1 = _dl_check_if_named_library_is_loaded(cp2, trace_loaded_objects))) {
- tpnt1->usage_count++;
- goto next_lib2;
- }
-
#if defined (__SUPPORT_LD_DEBUG__)
if(_dl_debug)
_dl_dprintf(_dl_debug_file,
@@ -556,7 +544,6 @@ next_lib:
#endif
}
-next_lib2:
/* find start of next library */
*cp = c;
for ( /*nada */ ; *cp && *cp == ' '; cp++)
@@ -580,10 +567,6 @@ next_lib2:
lpntstr = (char*) (tcurr->dynamic_info[DT_STRTAB] + dpnt->d_un.d_val);
name = _dl_get_last_path_component(lpntstr);
- if ((tpnt1 = _dl_check_if_named_library_is_loaded(name, trace_loaded_objects))) {
- tpnt1->usage_count++;
- }
-
#if defined (__SUPPORT_LD_DEBUG__)
if(_dl_debug)
_dl_dprintf(_dl_debug_file,
@@ -591,18 +574,16 @@ next_lib2:
lpntstr, _dl_progname);
#endif
- if (!tpnt1) {
- if (!(tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr, trace_loaded_objects))) {
+ if (!(tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr, trace_loaded_objects))) {
#ifdef __LDSO_LDD_SUPPORT__
- if (trace_loaded_objects) {
- _dl_dprintf(1, "\t%s => not found\n", lpntstr);
- continue;
- } else
-#endif
- {
- _dl_dprintf(2, "%s: can't load library '%s'\n", _dl_progname, lpntstr);
- _dl_exit(16);
- }
+ if (trace_loaded_objects) {
+ _dl_dprintf(1, "\t%s => not found\n", lpntstr);
+ continue;
+ } else
+#endif
+ {
+ _dl_dprintf(2, "%s: can't load library '%s'\n", _dl_progname, lpntstr);
+ _dl_exit(16);
}
}
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 26b17fc86..222c7743f 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -44,8 +44,6 @@ extern char *_dl_find_hash(const char *, struct dyn_elf *, struct elf_resolve *,
__attribute__ ((__weak__));
extern struct elf_resolve * _dl_load_shared_library(int, struct dyn_elf **,
struct elf_resolve *, char *, int) __attribute__ ((__weak__));
-extern struct elf_resolve * _dl_check_if_named_library_is_loaded(const char *, int)
- __attribute__ ((__weak__));
extern int _dl_fixup(struct dyn_elf *rpnt, int lazy)
__attribute__ ((__weak__));
extern void _dl_protect_relro(struct elf_resolve * tpnt)
@@ -178,11 +176,8 @@ void *dlopen(const char *libname, int flag)
if(_dl_debug)
fprintf(stderr, "Trying to dlopen '%s'\n", (char*)libname);
#endif
- tpnt = _dl_check_if_named_library_is_loaded((char *)libname, 0);
- if (!(tpnt))
- tpnt = _dl_load_shared_library(0, &rpnt, tfrom, (char*)libname, 0);
- else
- tpnt->usage_count++;
+ tpnt = _dl_load_shared_library(0, &rpnt, tfrom, (char*)libname, 0);
+
if (tpnt == NULL) {
_dl_unmap_cache();
return NULL;
@@ -239,24 +234,19 @@ void *dlopen(const char *libname, int flag)
lpntstr = (char*) (runp->tpnt->dynamic_info[DT_STRTAB] +
dpnt->d_un.d_val);
name = _dl_get_last_path_component(lpntstr);
- tpnt1 = _dl_check_if_named_library_is_loaded(name, 0);
#ifdef __SUPPORT_LD_DEBUG__
if(_dl_debug)
fprintf(stderr, "Trying to load '%s', needed by '%s'\n",
lpntstr, runp->tpnt->libname);
#endif
- if (tpnt1) {
- tpnt1->usage_count++;
- } else {
- tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr, 0);
- if (!tpnt1)
- goto oops;
- tpnt1->init_flag |= DL_OPENED;
+ tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr, 0);
+ if (!tpnt1)
+ goto oops;
- }
tpnt1->rtld_flags |= (flag & RTLD_GLOBAL);
if (tpnt1->usage_count == 1) {
+ tpnt1->init_flag |= DL_OPENED;
/* This list is for dlsym() and relocation */
dyn_ptr->next = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
_dl_memset (dyn_ptr->next, 0, sizeof (struct dyn_elf));