[uClibc-cvs] CVS update of uClibc/ldso (ldso/ldso.c libdl/libdl.c)

Joakim Tjernlund jocke at codepoet.org
Thu Aug 26 14:17:11 UTC 2004


    Date: Thursday, August 26, 2004 @ 08:17:11
  Author: jocke
    Path: /var/cvs/uClibc/ldso

Modified: ldso/ldso.c (1.113 -> 1.114) libdl/libdl.c (1.51 -> 1.52)

Let ldso find libc's malloc function and set _dl_malloc_function.
This removes some crap in libdl.c(and future libs which needs
to access ldso functions).
What do you think?


Index: uClibc/ldso/ldso/ldso.c
diff -u uClibc/ldso/ldso/ldso.c:1.113 uClibc/ldso/ldso/ldso.c:1.114
--- uClibc/ldso/ldso/ldso.c:1.113	Thu Aug 26 05:30:47 2004
+++ uClibc/ldso/ldso/ldso.c	Thu Aug 26 08:17:08 2004
@@ -45,7 +45,7 @@
 int _dl_errno                  = 0;     /* We can't use the real errno in ldso */
 size_t _dl_pagesize            = 0;		/* Store the page size for use later */
 struct r_debug *_dl_debug_addr = NULL;  /* Used to communicate with the gdb debugger */
-
+void *(*_dl_malloc_function) (size_t size) = NULL;
 
 
 #ifdef __SUPPORT_LD_DEBUG__
@@ -776,6 +776,9 @@
 	/* Notify the debugger that all objects are now mapped in.  */
 	_dl_debug_addr->r_state = RT_CONSISTENT;
 	_dl_debug_state();
+
+	/* Find the real malloc function and make ldso functions use that from now on */
+	 _dl_malloc_function = (void (*)(size_t)) (intptr_t) _dl_find_hash("malloc", _dl_symbol_tables, ELF_RTYPE_CLASS_PLT);
 }
 
 char *_dl_getenv(const char *symbol, char **envp)
@@ -827,7 +830,6 @@
 	return 0;
 }
 
-void *(*_dl_malloc_function) (size_t size) = NULL;
 void *_dl_malloc(int size)
 {
 	void *retval;
Index: uClibc/ldso/libdl/libdl.c
diff -u uClibc/ldso/libdl/libdl.c:1.51 uClibc/ldso/libdl/libdl.c:1.52
--- uClibc/ldso/libdl/libdl.c:1.51	Thu Aug 26 08:00:03 2004
+++ uClibc/ldso/libdl/libdl.c	Thu Aug 26 08:17:10 2004
@@ -144,14 +144,6 @@
 
 	from = (ElfW(Addr)) __builtin_return_address(0);
 
-	/* Have the dynamic linker use the regular malloc function now */
-	if (!dl_init) {
-		dl_init++;
-#if defined (__LIBDL_SHARED__)
-		_dl_malloc_function = malloc;
-#endif
-	}
-
 	/* Cover the trivial case first */
 	if (!libname)
 		return _dl_symbol_tables;



More information about the uClibc-cvs mailing list