summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-02-07 10:12:25 +0000
committerEric Andersen <andersen@codepoet.org>2004-02-07 10:12:25 +0000
commit2e723e150ab9b11e658311d6dfe2a1c1e402b833 (patch)
tree3dd87f0a3bcc014b30ba226b7efbdb1c143b08fe /ldso
parentcdf8ceb36ff80e68c0ffbde96b20cb088a9fe59b (diff)
Step one, begin shuffling things around a bit
Diffstat (limited to 'ldso')
-rw-r--r--ldso/include/dl-elf.h7
-rw-r--r--ldso/include/ld_elf.h7
-rw-r--r--ldso/include/ldso.h46
-rw-r--r--ldso/ldso/Makefile2
-rw-r--r--ldso/ldso/dl-elf.c9
-rw-r--r--ldso/ldso/ldso.c122
-rw-r--r--ldso/ldso/readelflib1.c9
-rw-r--r--ldso/libdl/dlib.c10
-rw-r--r--ldso/libdl/libdl.c10
9 files changed, 135 insertions, 87 deletions
diff --git a/ldso/include/dl-elf.h b/ldso/include/dl-elf.h
index 34a3c62ad..04c450fc5 100644
--- a/ldso/include/dl-elf.h
+++ b/ldso/include/dl-elf.h
@@ -65,11 +65,14 @@ extern void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
extern int _dl_parse_relocation_information(struct dyn_elf *rpnt,
unsigned long rel_addr, unsigned long rel_size, int type);
extern struct elf_resolve * _dl_load_shared_library(int secure,
- struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname);
+ struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname,
+ int trace_loaded_objects);
extern struct elf_resolve * _dl_load_elf_shared_library(int secure,
struct dyn_elf **rpnt, char *libname);
-extern struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname);
+extern struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname,
+ int trace_loaded_objects);
extern int _dl_linux_resolve(void);
+extern int _dl_fixup(struct dyn_elf *rpnt, int flag);
/*
diff --git a/ldso/include/ld_elf.h b/ldso/include/ld_elf.h
index 34a3c62ad..04c450fc5 100644
--- a/ldso/include/ld_elf.h
+++ b/ldso/include/ld_elf.h
@@ -65,11 +65,14 @@ extern void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
extern int _dl_parse_relocation_information(struct dyn_elf *rpnt,
unsigned long rel_addr, unsigned long rel_size, int type);
extern struct elf_resolve * _dl_load_shared_library(int secure,
- struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname);
+ struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname,
+ int trace_loaded_objects);
extern struct elf_resolve * _dl_load_elf_shared_library(int secure,
struct dyn_elf **rpnt, char *libname);
-extern struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname);
+extern struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname,
+ int trace_loaded_objects);
extern int _dl_linux_resolve(void);
+extern int _dl_fixup(struct dyn_elf *rpnt, int flag);
/*
diff --git a/ldso/include/ldso.h b/ldso/include/ldso.h
index 621236fdf..15f76ee80 100644
--- a/ldso/include/ldso.h
+++ b/ldso/include/ldso.h
@@ -1,3 +1,6 @@
+#ifndef _LDSO_H_
+#define _LDSO_H_
+
#include <features.h>
/* Pull in compiler and arch stuff */
#include <stdlib.h>
@@ -30,3 +33,46 @@
#define __LINUX_COMPILER_H
#endif
+
+/* Global variables used within the shared library loader */
+extern char *_dl_library_path; /* Where we look for libraries */
+extern char *_dl_preload; /* Things to be loaded before the libs */
+extern char *_dl_ldsopath; /* Where the shared lib loader was found */
+extern const char *_dl_progname; /* The name of the executable being run */
+extern unsigned char *_dl_malloc_addr; /* Lets _dl_malloc use the already allocated memory page */
+extern unsigned char *_dl_mmap_zero; /* Also used by _dl_malloc */
+extern unsigned long *_dl_brkp; /* The end of the data segment for brk and sbrk */
+extern unsigned long *_dl_envp; /* The environment address */
+extern int _dl_secure; /* Are we dealing with setuid stuff? */
+
+#ifdef __SUPPORT_LD_DEBUG__
+extern char *_dl_debug;
+extern char *_dl_debug_symbols;
+extern char *_dl_debug_move;
+extern char *_dl_debug_reloc;
+extern char *_dl_debug_detail;
+extern char *_dl_debug_nofixups;
+extern char *_dl_debug_bindings;
+extern int _dl_debug_file;
+#else
+#define _dl_debug_file 2
+#endif
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+extern void *_dl_malloc(int size);
+extern char *_dl_getenv(const char *symbol, char **envp);
+extern void _dl_unsetenv(const char *symbol, char **envp);
+extern char *_dl_strdup(const char *string);
+extern void _dl_dprintf(int, const char *, ...);
+
+extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *app_tpnt,
+ unsigned long load_addr, unsigned long *hash_addr,
+ Elf32_auxv_t auxvt[AT_EGID + 1], char **envp, struct r_debug *debug_addr,
+ unsigned char *malloc_buffer, unsigned char *mmap_zero, char **argv);
+
+
+#endif /* _LDSO_H_ */
+
diff --git a/ldso/ldso/Makefile b/ldso/ldso/Makefile
index 46891c768..79c381bea 100644
--- a/ldso/ldso/Makefile
+++ b/ldso/ldso/Makefile
@@ -44,7 +44,7 @@ endif
XXFLAGS+=$(shell $(CC) -print-search-dirs | sed -ne "s/install: *\(.*\)/-I\1include/gp")
LDFLAGS=$(CPU_LDFLAGS-y) -shared --warn-common --export-dynamic --sort-common \
- -z combreloc --discard-locals --discard-all
+ -z combreloc --discard-locals --discard-all --no-undefined
CSRC= ldso.c #hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 6acf136c9..75c5972bf 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -166,7 +166,8 @@ search_for_named_library(const char *name, int secure, const char *path_list,
}
/* Check if the named library is already loaded... */
-struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname)
+struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname,
+ int trace_loaded_objects)
{
const char *pnt, *pnt1;
struct elf_resolve *tpnt1;
@@ -201,7 +202,7 @@ struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libnam
{
/* Abort attempts to load glibc, libc5, etc */
if ( libname[8]!='0') {
- if (!_dl_trace_loaded_objects) {
+ if (!trace_loaded_objects) {
_dl_dprintf(2, aborted_wrong_lib, libname, _dl_progname);
_dl_exit(1);
}
@@ -241,7 +242,7 @@ unsigned long _dl_internal_error_number;
extern char *_dl_ldsopath;
struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
- struct elf_resolve *tpnt, char *full_libname)
+ struct elf_resolve *tpnt, char *full_libname, int trace_loaded_objects)
{
char *pnt, *pnt1;
struct elf_resolve *tpnt1;
@@ -265,7 +266,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
/* 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))!=NULL)
+ if ((tpnt1=_dl_check_if_named_library_is_loaded(libname, trace_loaded_objects))!=NULL)
return tpnt1;
#if defined (__SUPPORT_LD_DEBUG__)
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 2d09c5a29..04dbdcae5 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -114,7 +114,7 @@
#define ELFMAGIC ELFMAG
/* This is a poor man's malloc, used prior to resolving our internal poor man's malloc */
-#define LD_MALLOC(SIZE) ((unsigned void *) (malloc_buffer += SIZE, malloc_buffer - SIZE)) ; REALIGN();
+#define LD_MALLOC(SIZE) ((void *) (malloc_buffer += SIZE, malloc_buffer - SIZE)) ; REALIGN();
/*
* Make sure that the malloc buffer is aligned on 4 byte boundary. For 64 bit
* platforms we may need to increase this to 8, but this is good enough for
@@ -125,7 +125,6 @@
char *_dl_library_path = 0; /* Where we look for libraries */
char *_dl_preload = 0; /* Things to be loaded before the libs. */
char *_dl_ldsopath = 0;
-static int _dl_be_lazy = RTLD_LAZY;
#ifdef __SUPPORT_LD_DEBUG__
char *_dl_debug = 0;
char *_dl_debug_symbols = 0;
@@ -140,7 +139,7 @@ int _dl_debug_file = 2;
#endif
static unsigned char *_dl_malloc_addr, *_dl_mmap_zero;
-static char *_dl_trace_loaded_objects = 0;
+static int _dl_secure = 0;
static int (*_dl_elf_main) (int, char **, char **);
struct r_debug *_dl_debug_addr = NULL;
unsigned long *_dl_brkp;
@@ -148,9 +147,6 @@ unsigned long *_dl_envp;
int _dl_fixup(struct dyn_elf *rpnt, int flag);
void _dl_debug_state(void);
char *_dl_get_last_path_component(char *path);
-static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *app_tpnt,
- unsigned long load_addr, unsigned long *hash_addr, Elf32_auxv_t auxvt[AT_EGID + 1],
- char **envp, struct r_debug *debug_addr);
#include "boot1_arch.h"
#include "_dl_progname.h" /* Pull in the value of _dl_progname */
@@ -166,29 +162,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
auxvt[0...N] Auxiliary Vector Table elements (mixed types)
*/
-#ifdef __SUPPORT_LD_DEBUG_EARLY__
-/* Debugging is especially tricky on PowerPC, since string literals
- * require relocations. Thus, you can't use _dl_dprintf() for
- * anything until the bootstrap relocations are finished. */
-static inline void hexprint(unsigned long x)
-{
- int i;
- char c;
-
- for (i = 0; i < 8; i++) {
- c = ((x >> 28) + '0');
- if (c > '9')
- c += 'a' - '9' - 1;
- _dl_write(1, &c, 1);
- x <<= 4;
- }
- c = '\n';
- _dl_write(1, &c, 1);
-}
-#endif
-
LD_BOOT(unsigned long args) __attribute__ ((unused));
-
LD_BOOT(unsigned long args)
{
unsigned int argc;
@@ -645,24 +619,16 @@ LD_BOOT(unsigned long args)
free to start using global variables, since these things have all been
fixed up by now. Still no function calls outside of this library ,
since the dynamic resolver is not yet ready. */
- _dl_get_ready_to_run(tpnt, app_tpnt, load_addr, hash_addr, auxvt, envp, debug_addr);
-
+ _dl_get_ready_to_run(tpnt, app_tpnt, load_addr, hash_addr,
+ auxvt, envp, debug_addr, malloc_buffer, mmap_zero, argv);
- /* Notify the debugger that all objects are now mapped in. */
- _dl_debug_addr->r_state = RT_CONSISTENT;
- _dl_debug_state();
-
- /* OK we are done here. Turn out the lights, and lock up. */
- _dl_elf_main = (int (*)(int, char **, char **)) auxvt[AT_ENTRY].a_un.a_fcn;
-
- /*
- * Transfer control to the application.
- */
+ /* Transfer control to the application. */
status = 0; /* Used on x86, but not on other arches */
#if defined (__SUPPORT_LD_DEBUG__)
if(_dl_debug) _dl_dprintf(_dl_debug_file,"\ntransfering control: %s\n\n", _dl_progname);
#endif
+ _dl_elf_main = (int (*)(int, char **, char **)) auxvt[AT_ENTRY].a_un.a_fcn;
START();
}
@@ -674,13 +640,15 @@ static void debug_fini (int status, void *arg)
}
#endif
-static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *app_tpnt,
- unsigned long load_addr, unsigned long *hash_addr, Elf32_auxv_t auxvt[AT_EGID + 1],
- char **envp, struct r_debug *debug_addr)
+void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *app_tpnt,
+ unsigned long load_addr, unsigned long *hash_addr,
+ Elf32_auxv_t auxvt[AT_EGID + 1], char **envp, struct r_debug *debug_addr,
+ unsigned char *malloc_buffer, unsigned char *mmap_zero, char **argv)
+
{
ElfW(Phdr) *ppnt;
char *lpntstr;
- int i, _dl_secure, goof = 0;
+ int i, goof = 0, be_lazy = RTLD_LAZY, trace_loaded_objects = 0;
struct dyn_elf *rpnt;
struct elf_resolve *tcurr;
struct elf_resolve *tpnt1;
@@ -690,10 +658,30 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
int (*_dl_on_exit) (void (*FUNCTION)(int STATUS, void *ARG),void*);
#endif
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+ /* Wahoo!!! */
+ SEND_STDERR("Cool, we managed to make a function call.\n");
+#endif
+
+ /* Make it so _dl_malloc can use the page of memory we have already
+ * allocated. We shouldn't need to grab any more memory. This must
+ * be first since things like _dl_dprintf() use _dl_malloc().... */
+ _dl_malloc_addr = malloc_buffer;
+ _dl_mmap_zero = mmap_zero;
+
/* Now we have done the mandatory linking of some things. We are now
- free to start using global variables, since these things have all been
- fixed up by now. Still no function calls outside of this library ,
- since the dynamic resolver is not yet ready. */
+ * free to start using global variables, since these things have all been
+ * fixed up by now. Still no function calls outside of this library ,
+ * since the dynamic resolver is not yet ready. */
+
+ if (argv[0]) {
+ _dl_progname = argv[0];
+ }
+
+ /* Start to build the tables of the modules that are required for
+ * this beast to run. We start with the basic executable, and then
+ * go from there. Eventually we will run across ourself, and we
+ * will need to properly deal with that as well. */
lpnt = (unsigned long *) (tpnt->dynamic_info[DT_PLTGOT] + load_addr);
tpnt->chains = hash_addr;
@@ -823,7 +811,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
Note that for SUID programs we ignore the settings in LD_LIBRARY_PATH */
{
if (_dl_getenv("LD_BIND_NOW", envp))
- _dl_be_lazy = 0;
+ be_lazy = 0;
if ((auxvt[AT_UID].a_un.a_val == -1 && _dl_suid_ok()) ||
(auxvt[AT_UID].a_un.a_val != -1 &&
@@ -895,9 +883,11 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
#endif
- _dl_trace_loaded_objects = _dl_getenv("LD_TRACE_LOADED_OBJECTS", envp);
+ if (_dl_getenv("LD_TRACE_LOADED_OBJECTS", envp) != NULL) {
+ trace_loaded_objects++;
+ }
#ifndef __LDSO_LDD_SUPPORT__
- if (_dl_trace_loaded_objects) {
+ if (trace_loaded_objects) {
_dl_dprintf(_dl_debug_file, "Use the ldd provided by uClibc\n");
_dl_exit(1);
}
@@ -942,7 +932,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
*str2 = '\0';
if (!_dl_secure || _dl_strchr(str, '/') == NULL)
{
- if ((tpnt1 = _dl_check_if_named_library_is_loaded(str)))
+ if ((tpnt1 = _dl_check_if_named_library_is_loaded(str, trace_loaded_objects)))
{
continue;
}
@@ -950,10 +940,10 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
if(_dl_debug) _dl_dprintf(_dl_debug_file, "\tfile='%s'; needed by '%s'\n",
str, _dl_progname);
#endif
- tpnt1 = _dl_load_shared_library(_dl_secure, &rpnt, NULL, str);
+ tpnt1 = _dl_load_shared_library(_dl_secure, &rpnt, NULL, str, trace_loaded_objects);
if (!tpnt1) {
#ifdef __LDSO_LDD_SUPPORT__
- if (_dl_trace_loaded_objects)
+ if (trace_loaded_objects)
_dl_dprintf(1, "\t%s => not found\n", str);
else
#endif
@@ -966,7 +956,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
_dl_dprintf(_dl_debug_file, "Loading:\t(%x) %s\n", tpnt1->loadaddr, tpnt1->libname);
#endif
#ifdef __LDSO_LDD_SUPPORT__
- if (_dl_trace_loaded_objects && tpnt1->usage_count==1) {
+ if (trace_loaded_objects && tpnt1->usage_count==1) {
/* this is a real hack to make ldd not print
* the library itself when run on a library. */
if (_dl_strcmp(_dl_progname, str) != 0)
@@ -1026,7 +1016,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
c = *cp;
*cp = '\0';
- if ((tpnt1 = _dl_check_if_named_library_is_loaded(cp2)))
+ if ((tpnt1 = _dl_check_if_named_library_is_loaded(cp2, trace_loaded_objects)))
{
continue;
}
@@ -1034,10 +1024,10 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
if(_dl_debug) _dl_dprintf(_dl_debug_file, "\tfile='%s'; needed by '%s'\n",
cp2, _dl_progname);
#endif
- tpnt1 = _dl_load_shared_library(0, &rpnt, NULL, cp2);
+ tpnt1 = _dl_load_shared_library(0, &rpnt, NULL, cp2, trace_loaded_objects);
if (!tpnt1) {
#ifdef __LDSO_LDD_SUPPORT__
- if (_dl_trace_loaded_objects)
+ if (trace_loaded_objects)
_dl_dprintf(1, "\t%s => not found\n", cp2);
else
#endif
@@ -1050,7 +1040,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
_dl_dprintf(_dl_debug_file, "Loading:\t(%x) %s\n", tpnt1->loadaddr, tpnt1->libname);
#endif
#ifdef __LDSO_LDD_SUPPORT__
- if (_dl_trace_loaded_objects && tpnt1->usage_count==1) {
+ if (trace_loaded_objects && tpnt1->usage_count==1) {
_dl_dprintf(1, "\t%s => %s (%x)\n", cp2,
tpnt1->libname, (unsigned) tpnt1->loadaddr);
}
@@ -1081,7 +1071,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
lpntstr = (char*) (tcurr->loadaddr + 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)))
+ if ((tpnt1 = _dl_check_if_named_library_is_loaded(name, trace_loaded_objects)))
{
continue;
}
@@ -1089,10 +1079,10 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
if(_dl_debug) _dl_dprintf(_dl_debug_file, "\tfile='%s'; needed by '%s'\n",
lpntstr, _dl_progname);
#endif
- if (!(tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr)))
+ if (!(tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr, trace_loaded_objects)))
{
#ifdef __LDSO_LDD_SUPPORT__
- if (_dl_trace_loaded_objects) {
+ if (trace_loaded_objects) {
_dl_dprintf(1, "\t%s => not found\n", lpntstr);
continue;
} else
@@ -1106,7 +1096,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
_dl_dprintf(_dl_debug_file, "Loading:\t(%x) %s\n", tpnt1->loadaddr, tpnt1->libname);
#endif
#ifdef __LDSO_LDD_SUPPORT__
- if (_dl_trace_loaded_objects && tpnt1->usage_count==1) {
+ if (trace_loaded_objects && tpnt1->usage_count==1) {
_dl_dprintf(1, "\t%s => %s (%x)\n", lpntstr, tpnt1->libname,
(unsigned) tpnt1->loadaddr);
}
@@ -1154,7 +1144,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
#ifdef __LDSO_LDD_SUPPORT__
/* End of the line for ldd.... */
- if (_dl_trace_loaded_objects) {
+ if (trace_loaded_objects) {
_dl_dprintf(1, "\t%s => %s (%x)\n", rpnt->dyn->libname + (_dl_strlen(_dl_ldsopath)) + 1,
rpnt->dyn->libname, rpnt->dyn->loadaddr);
_dl_exit(0);
@@ -1179,7 +1169,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
* to the GOT tables. We need to do this in reverse order so that COPY
* directives work correctly */
if (_dl_symbol_tables)
- goof += _dl_fixup(_dl_symbol_tables, _dl_be_lazy);
+ goof += _dl_fixup(_dl_symbol_tables, be_lazy);
/* OK, at this point things are pretty much ready to run. Now we
@@ -1279,6 +1269,10 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
}
#endif
}
+
+ /* Notify the debugger that all objects are now mapped in. */
+ _dl_debug_addr->r_state = RT_CONSISTENT;
+ _dl_debug_state();
}
/*
diff --git a/ldso/ldso/readelflib1.c b/ldso/ldso/readelflib1.c
index 6acf136c9..75c5972bf 100644
--- a/ldso/ldso/readelflib1.c
+++ b/ldso/ldso/readelflib1.c
@@ -166,7 +166,8 @@ search_for_named_library(const char *name, int secure, const char *path_list,
}
/* Check if the named library is already loaded... */
-struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname)
+struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname,
+ int trace_loaded_objects)
{
const char *pnt, *pnt1;
struct elf_resolve *tpnt1;
@@ -201,7 +202,7 @@ struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libnam
{
/* Abort attempts to load glibc, libc5, etc */
if ( libname[8]!='0') {
- if (!_dl_trace_loaded_objects) {
+ if (!trace_loaded_objects) {
_dl_dprintf(2, aborted_wrong_lib, libname, _dl_progname);
_dl_exit(1);
}
@@ -241,7 +242,7 @@ unsigned long _dl_internal_error_number;
extern char *_dl_ldsopath;
struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
- struct elf_resolve *tpnt, char *full_libname)
+ struct elf_resolve *tpnt, char *full_libname, int trace_loaded_objects)
{
char *pnt, *pnt1;
struct elf_resolve *tpnt1;
@@ -265,7 +266,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
/* 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))!=NULL)
+ if ((tpnt1=_dl_check_if_named_library_is_loaded(libname, trace_loaded_objects))!=NULL)
return tpnt1;
#if defined (__SUPPORT_LD_DEBUG__)
diff --git a/ldso/libdl/dlib.c b/ldso/libdl/dlib.c
index d09210acc..65c54ac42 100644
--- a/ldso/libdl/dlib.c
+++ b/ldso/libdl/dlib.c
@@ -32,9 +32,9 @@ static int __attribute__ ((unused)) foobar1 = (int) foobar; /* Use as pointer */
extern void _dl_dprintf(int, const char *, ...) __attribute__ ((__weak__, __alias__ ("foobar")));
extern char *_dl_find_hash(const char *, struct dyn_elf *, struct elf_resolve *, enum caller_type)
__attribute__ ((__weak__, __alias__ ("foobar")));
-extern struct elf_resolve * _dl_load_shared_library(int, struct dyn_elf **, struct elf_resolve *, char *)
+extern struct elf_resolve * _dl_load_shared_library(int, struct dyn_elf **, struct elf_resolve *, char *, int)
__attribute__ ((__weak__, __alias__ ("foobar")));
-extern struct elf_resolve * _dl_check_if_named_library_is_loaded(const char *full_libname)
+extern struct elf_resolve * _dl_check_if_named_library_is_loaded(const char *, int)
__attribute__ ((__weak__, __alias__ ("foobar")));
extern int _dl_fixup(struct dyn_elf *rpnt, int lazy)
__attribute__ ((__weak__, __alias__ ("foobar")));
@@ -79,7 +79,7 @@ int _dl_debug_file = 2;
char *_dl_library_path = 0;
char *_dl_ldsopath = 0;
struct r_debug *_dl_debug_addr = NULL;
-static char *_dl_malloc_addr, *_dl_mmap_zero;
+static unsigned char *_dl_malloc_addr, *_dl_mmap_zero;
#include "../ldso/_dl_progname.h" /* Pull in the name of ld.so */
#include "../ldso/hash.c"
#define _dl_trace_loaded_objects 0
@@ -179,7 +179,7 @@ void *_dlopen(const char *libname, int flag)
if(_dl_debug)
_dl_dprintf(_dl_debug_file, "Trying to dlopen '%s'\n", (char*)libname);
#endif
- tpnt = _dl_load_shared_library(0, &rpnt, tfrom, (char*)libname);
+ tpnt = _dl_load_shared_library(0, &rpnt, tfrom, (char*)libname, 0);
if (tpnt == NULL) {
_dl_unmap_cache();
return NULL;
@@ -226,7 +226,7 @@ void *_dlopen(const char *libname, int flag)
lpntstr, tcurr->libname);
#endif
- if (!(tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr))) {
+ if (!(tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr, 0))) {
goto oops;
}
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index d09210acc..65c54ac42 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -32,9 +32,9 @@ static int __attribute__ ((unused)) foobar1 = (int) foobar; /* Use as pointer */
extern void _dl_dprintf(int, const char *, ...) __attribute__ ((__weak__, __alias__ ("foobar")));
extern char *_dl_find_hash(const char *, struct dyn_elf *, struct elf_resolve *, enum caller_type)
__attribute__ ((__weak__, __alias__ ("foobar")));
-extern struct elf_resolve * _dl_load_shared_library(int, struct dyn_elf **, struct elf_resolve *, char *)
+extern struct elf_resolve * _dl_load_shared_library(int, struct dyn_elf **, struct elf_resolve *, char *, int)
__attribute__ ((__weak__, __alias__ ("foobar")));
-extern struct elf_resolve * _dl_check_if_named_library_is_loaded(const char *full_libname)
+extern struct elf_resolve * _dl_check_if_named_library_is_loaded(const char *, int)
__attribute__ ((__weak__, __alias__ ("foobar")));
extern int _dl_fixup(struct dyn_elf *rpnt, int lazy)
__attribute__ ((__weak__, __alias__ ("foobar")));
@@ -79,7 +79,7 @@ int _dl_debug_file = 2;
char *_dl_library_path = 0;
char *_dl_ldsopath = 0;
struct r_debug *_dl_debug_addr = NULL;
-static char *_dl_malloc_addr, *_dl_mmap_zero;
+static unsigned char *_dl_malloc_addr, *_dl_mmap_zero;
#include "../ldso/_dl_progname.h" /* Pull in the name of ld.so */
#include "../ldso/hash.c"
#define _dl_trace_loaded_objects 0
@@ -179,7 +179,7 @@ void *_dlopen(const char *libname, int flag)
if(_dl_debug)
_dl_dprintf(_dl_debug_file, "Trying to dlopen '%s'\n", (char*)libname);
#endif
- tpnt = _dl_load_shared_library(0, &rpnt, tfrom, (char*)libname);
+ tpnt = _dl_load_shared_library(0, &rpnt, tfrom, (char*)libname, 0);
if (tpnt == NULL) {
_dl_unmap_cache();
return NULL;
@@ -226,7 +226,7 @@ void *_dlopen(const char *libname, int flag)
lpntstr, tcurr->libname);
#endif
- if (!(tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr))) {
+ if (!(tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr, 0))) {
goto oops;
}