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

jocke at uclibc.org jocke at uclibc.org
Sat Apr 23 16:54:06 UTC 2005


Author: jocke
Date: 2005-04-23 10:54:05 -0600 (Sat, 23 Apr 2005)
New Revision: 10167

Log:
Fix dlopen to handle circular dependency libs. Wouldn't surprise me if something else
broke. I hate libdl :(


Modified:
   trunk/uClibc/ldso/libdl/libdl.c


Changeset:
Modified: trunk/uClibc/ldso/libdl/libdl.c
===================================================================
--- trunk/uClibc/ldso/libdl/libdl.c	2005-04-23 07:00:33 UTC (rev 10166)
+++ trunk/uClibc/ldso/libdl/libdl.c	2005-04-23 16:54:05 UTC (rev 10167)
@@ -255,15 +255,28 @@
 				}
 				if (tpnt1->init_flag & DL_OPENED) {
 					/* Used to record RTLD_LOCAL scope */
-					tmp = alloca(sizeof(struct init_fini_list)); /* Allocates on stack, no need to free this memory */
+					tmp = alloca(sizeof(struct init_fini_list));
 					tmp->tpnt = tpnt1;
 					tmp->next = runp->tpnt->init_fini;
 					runp->tpnt->init_fini = tmp;
 
-					runp2->next = alloca(sizeof(*runp)); /* Allocates on stack, no need to free this memory */
-					runp2 = runp2->next;
-					runp2->tpnt = tpnt1;
-					runp2->next = NULL;
+					for (tmp=dep_list; tmp; tmp = tmp->next) {
+						if (tpnt1 == tmp->tpnt) { /* if match => cirular dependency, drop it */
+#ifdef __SUPPORT_LD_DEBUG__
+							if(_dl_debug)
+								fprintf(stderr, "Circular dependency, skipping '%s',\n",
+									tmp->tpnt->libname);
+#endif
+							tpnt1->usage_count--;
+							break;
+						}
+					}
+					if (!tmp) { /* Don't add if circular dependency detected */
+						runp2->next = alloca(sizeof(*runp));
+						runp2 = runp2->next;
+						runp2->tpnt = tpnt1;
+						runp2->next = NULL;
+					}
 				}
 			}
 		}




More information about the uClibc-cvs mailing list