summaryrefslogtreecommitdiff
path: root/ldso/libdl
diff options
context:
space:
mode:
authorBernd Schmidt <bernds_cb1@t-online.de>2007-12-03 22:41:36 +0000
committerBernd Schmidt <bernds_cb1@t-online.de>2007-12-03 22:41:36 +0000
commit453094fb5857cddffe0ed05305806085ae3460c0 (patch)
tree49b9e4dffc05be1efc62bf4a0d2c7967d2f4330f /ldso/libdl
parent763c6d06bc87904923b1df920c031df4559df589 (diff)
Blackfin FD-PIC patch 1/6.
Add a new function _dl_free. In _dl_malloc, ensure we always get back a full page from mmap. Reset _dl_malloc_function and _dl_free_function when libdl is initialized.
Diffstat (limited to 'ldso/libdl')
-rw-r--r--ldso/libdl/libdl.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index f018c0a0d..f2303c52e 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -32,6 +32,7 @@
#include <ldso.h>
#include <stdio.h>
+#include <string.h>
#ifdef SHARED
@@ -51,6 +52,7 @@ extern struct elf_resolve *_dl_loaded_modules;
extern struct r_debug *_dl_debug_addr;
extern unsigned long _dl_error_number;
extern void *(*_dl_malloc_function)(size_t);
+extern void (*_dl_free_function) (void *p);
extern void _dl_run_init_array(struct elf_resolve *);
extern void _dl_run_fini_array(struct elf_resolve *);
#ifdef __LDSO_CACHE_SUPPORT__
@@ -67,6 +69,9 @@ extern char *_dl_debug;
#else /* SHARED */
+#define _dl_malloc malloc
+#define _dl_free free
+
/* When libdl is linked as a static library, we need to replace all
* the symbols that otherwise would have been loaded in from ldso... */
@@ -83,13 +88,15 @@ char *_dl_debug_bindings = 0;
int _dl_debug_file = 2;
#endif
const char *_dl_progname = ""; /* Program name */
+void *(*_dl_malloc_function)(size_t);
+void (*_dl_free_function) (void *p);
char *_dl_library_path = 0; /* Where we look for libraries */
char *_dl_ldsopath = 0; /* Location of the shared lib loader */
int _dl_errno = 0; /* We can't use the real errno in ldso */
size_t _dl_pagesize = PAGE_SIZE; /* Store the page size for use later */
/* This global variable is also to communicate with debuggers such as gdb. */
struct r_debug *_dl_debug_addr = NULL;
-#define _dl_malloc malloc
+
#include "../ldso/dl-array.c"
#include "../ldso/dl-debug.c"
#include LDSO_ELFINTERP
@@ -157,6 +164,7 @@ void *dlopen(const char *libname, int flag)
struct init_fini_list *tmp, *runp, *runp2, *dep_list;
unsigned int nlist, i;
struct elf_resolve **init_fini_list;
+ static int _dl_init = 0;
/* A bit of sanity checking... */
if (!(flag & (RTLD_LAZY|RTLD_NOW))) {
@@ -166,6 +174,11 @@ void *dlopen(const char *libname, int flag)
from = (ElfW(Addr)) __builtin_return_address(0);
+ if (!_dl_init) {
+ _dl_init++;
+ _dl_malloc_function = malloc;
+ _dl_free_function = free;
+ }
/* Cover the trivial case first */
if (!libname)
return _dl_symbol_tables;