[uClibc-cvs] svn commit: trunk/uClibc/ldso: ldso libdl

jocke at uclibc.org jocke at uclibc.org
Sat Apr 23 05:16:31 UTC 2005


Author: jocke
Date: 2005-04-22 23:16:30 -0600 (Fri, 22 Apr 2005)
New Revision: 10162

Log:
Cleanup library loading.


Modified:
   trunk/uClibc/ldso/ldso/dl-elf.c
   trunk/uClibc/ldso/ldso/ldso.c
   trunk/uClibc/ldso/libdl/libdl.c


Changeset:
Modified: trunk/uClibc/ldso/ldso/dl-elf.c
===================================================================
--- trunk/uClibc/ldso/ldso/dl-elf.c	2005-04-23 03:26:54 UTC (rev 10161)
+++ trunk/uClibc/ldso/ldso/dl-elf.c	2005-04-23 05:16:30 UTC (rev 10162)
@@ -273,13 +273,14 @@
 	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);

Modified: trunk/uClibc/ldso/ldso/ldso.c
===================================================================
--- trunk/uClibc/ldso/ldso/ldso.c	2005-04-23 03:26:54 UTC (rev 10161)
+++ trunk/uClibc/ldso/ldso/ldso.c	2005-04-23 05:16:30 UTC (rev 10162)
@@ -411,11 +411,6 @@
 			*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 @@
 				}
 			}
 
-next_lib:
 			*str2 = c;
 			str = str2;
 			while (*str == ':' || *str == ' ' || *str == '\t')
@@ -515,12 +509,6 @@
 				/*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 @@
 #endif
 			}
 
-next_lib2:
 			/* find start of next library */
 			*cp = c;
 			for ( /*nada */ ; *cp && *cp == ' '; cp++)
@@ -580,10 +567,6 @@
 				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 @@
 						    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
+					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);
-						}
+					{
+						_dl_dprintf(2, "%s: can't load library '%s'\n", _dl_progname, lpntstr);
+						_dl_exit(16);
 					}
 				}
 

Modified: trunk/uClibc/ldso/libdl/libdl.c
===================================================================
--- trunk/uClibc/ldso/libdl/libdl.c	2005-04-23 03:26:54 UTC (rev 10161)
+++ trunk/uClibc/ldso/libdl/libdl.c	2005-04-23 05:16:30 UTC (rev 10162)
@@ -44,8 +44,6 @@
 	__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 @@
 	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 @@
 				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));




More information about the uClibc-cvs mailing list