summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldso/ldso/ldso.c6
-rw-r--r--ldso/libdl/libdl.c8
2 files changed, 4 insertions, 10 deletions
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 5afc4a8f7..4c6817e6d 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -45,7 +45,7 @@ int _dl_secure = 1; /* Are we dealing with setuid stuff? */
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 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
/* 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 @@ static int _dl_suid_ok(void)
return 0;
}
-void *(*_dl_malloc_function) (size_t size) = NULL;
void *_dl_malloc(int size)
{
void *retval;
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 8199a7598..837ce0dc9 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -144,14 +144,6 @@ void *dlopen(const char *libname, int flag)
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;