[uClibc-cvs] CVS update of uClibc/ldso (Makefile include/.cvsignore include/ldso.h ldso/.cvsignore ldso/Makefile ldso/dl-elf.c ldso/ldso.c libdl/Makefile libdl/libdl.c)
Erik Andersen
andersen at codepoet.org
Fri Jul 30 03:32:42 UTC 2004
Date: Thursday, July 29, 2004 @ 21:32:41
Author: andersen
Path: /var/cvs/uClibc/ldso
Modified: Makefile (1.28 -> 1.29) include/.cvsignore (1.1 -> 1.2)
include/ldso.h (1.12 -> 1.13) ldso/.cvsignore (1.8 -> 1.9)
ldso/Makefile (1.57 -> 1.58) ldso/dl-elf.c (1.73 -> 1.74)
ldso/ldso.c (1.100 -> 1.101) libdl/Makefile (1.36 -> 1.37)
libdl/libdl.c (1.45 -> 1.46)
Teach libdl to use normal libc symbols whenever possible, i.e. malloc
rather than _dl_malloc, fprintf rather than _dl_printf, etc.
-Erik
Index: uClibc/ldso/Makefile
diff -u uClibc/ldso/Makefile:1.28 uClibc/ldso/Makefile:1.29
--- uClibc/ldso/Makefile:1.28 Tue Feb 10 02:26:46 2004
+++ uClibc/ldso/Makefile Thu Jul 29 21:32:39 2004
@@ -36,7 +36,13 @@
echo "Not building libdl"
endif
-headers:
+include/dl-progname.h: Makefile
+ echo "const char *_dl_progname=\""$(UCLIBC_LDSO)"\";" \
+ > include/dl-progname.h
+ echo -e "#include \"$(TARGET_ARCH)/elfinterp.c\"" \
+ >> include/dl-progname.h
+
+headers: include/dl-progname.h
$(LN) -fs $(TOPDIR)../include/elf.h include/
$(LN) -fs ../ldso/$(TARGET_ARCH)/dl-startup.h include/
$(LN) -fs ../ldso/$(TARGET_ARCH)/dl-syscalls.h include/
@@ -45,4 +51,5 @@
clean:
set -e ; for d in $(ALL_SUBDIRS) ; do $(MAKE) -C $$d $@ ; done
-find . -name '*~' | xargs $(RM)
- $(RM) include/elf.h include/boot1_arch.h include/ld_syscalls.h include/ld_sysdep.h
+ $(RM) include/elf.h include/boot1_arch.h include/ld_syscalls.h \
+ include/ld_sysdep.h include/dl-progname.h
Index: uClibc/ldso/include/.cvsignore
diff -u uClibc/ldso/include/.cvsignore:1.1 uClibc/ldso/include/.cvsignore:1.2
--- uClibc/ldso/include/.cvsignore:1.1 Tue Aug 19 00:05:30 2003
+++ uClibc/ldso/include/.cvsignore Thu Jul 29 21:32:40 2004
@@ -1,4 +1,6 @@
+dl-arch.h
+dl-progname.h
+dl-startup.h
+dl-syscalls.h
+dl-sysdep.h
elf.h
-ld_syscalls.h
-ld_sysdep.h
-boot1_arch.h
Index: uClibc/ldso/include/ldso.h
diff -u uClibc/ldso/include/ldso.h:1.12 uClibc/ldso/include/ldso.h:1.13
--- uClibc/ldso/include/ldso.h:1.12 Fri Jul 16 07:23:21 2004
+++ uClibc/ldso/include/ldso.h Thu Jul 29 21:32:40 2004
@@ -46,6 +46,7 @@
extern unsigned long *_dl_envp; /* The environment address */
extern int _dl_secure; /* Are we dealing with setuid stuff? */
extern size_t _dl_pagesize; /* Store the page size for use later */
+extern const char *_dl_progname; /* The name of the shared library loader */
#ifdef __SUPPORT_LD_DEBUG__
extern char *_dl_debug;
Index: uClibc/ldso/ldso/.cvsignore
diff -u uClibc/ldso/ldso/.cvsignore:1.8 uClibc/ldso/ldso/.cvsignore:1.9
--- uClibc/ldso/ldso/.cvsignore:1.8 Tue Feb 10 02:26:47 2004
+++ uClibc/ldso/ldso/.cvsignore Thu Jul 29 21:32:40 2004
@@ -1,2 +1 @@
ld-uclibc.so*
-dl-progname.h
Index: uClibc/ldso/ldso/Makefile
diff -u uClibc/ldso/ldso/Makefile:1.57 uClibc/ldso/ldso/Makefile:1.58
--- uClibc/ldso/ldso/Makefile:1.57 Sat Feb 14 05:48:47 2004
+++ uClibc/ldso/ldso/Makefile Thu Jul 29 21:32:40 2004
@@ -70,18 +70,13 @@
all: lib
-lib:: dl-progname.h $(OBJS) $(DLINK_OBJS)
+lib:: $(OBJS) $(DLINK_OBJS)
$(LD) $(LDFLAGS) -e _dl_boot -soname=$(UCLIBC_LDSO) \
-o $(LDSO_FULLNAME) $(OBJS) $(LIBGCC);
$(INSTALL) -d $(TOPDIR)lib
$(INSTALL) -m 755 $(LDSO_FULLNAME) $(TOPDIR)lib
$(LN) -sf $(LDSO_FULLNAME) $(TOPDIR)lib/$(UCLIBC_LDSO)
-dl-progname.h: Makefile
- echo "const char *_dl_progname=\""$(UCLIBC_LDSO)"\";" > dl-progname.h
- echo "#include \"$(TARGET_ARCH)/elfinterp.c\"" >> dl-progname.h
-
-
$(COBJS): %.o : %.c
$(CC) $(XXFLAGS) -I../libdl -c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
@@ -93,4 +88,4 @@
ldso.o: $(CSRC)
clean:
- $(RM) $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i dl-progname.h ldso.h *~
+ $(RM) $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i ldso.h *~
Index: uClibc/ldso/ldso/dl-elf.c
diff -u uClibc/ldso/ldso/dl-elf.c:1.73 uClibc/ldso/ldso/dl-elf.c:1.74
--- uClibc/ldso/ldso/dl-elf.c:1.73 Fri Jul 16 07:23:21 2004
+++ uClibc/ldso/ldso/dl-elf.c Thu Jul 29 21:32:40 2004
@@ -888,40 +888,3 @@
return retval;
}
-void *(*_dl_malloc_function) (size_t size) = NULL;
-void *_dl_malloc(int size)
-{
- void *retval;
-
-#if 0
-#ifdef __SUPPORT_LD_DEBUG_EARLY__
- _dl_dprintf(2, "malloc: request for %d bytes\n", size);
-#endif
-#endif
-
- if (_dl_malloc_function)
- return (*_dl_malloc_function) (size);
-
- if (_dl_malloc_addr - _dl_mmap_zero + size > _dl_pagesize) {
-#ifdef __SUPPORT_LD_DEBUG_EARLY__
- _dl_dprintf(2, "malloc: mmapping more memory\n");
-#endif
- _dl_mmap_zero = _dl_malloc_addr = _dl_mmap((void *) 0, size,
- PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- if (_dl_mmap_check_error(_dl_mmap_zero)) {
- _dl_dprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
- _dl_exit(20);
- }
- }
- retval = _dl_malloc_addr;
- _dl_malloc_addr += size;
-
- /*
- * Align memory to 4 byte boundary. Some platforms require this, others
- * simply get better performance.
- */
- _dl_malloc_addr = (unsigned char *) (((unsigned long) _dl_malloc_addr + 3) & ~(3));
- return retval;
-}
-
-
Index: uClibc/ldso/ldso/ldso.c
diff -u uClibc/ldso/ldso/ldso.c:1.100 uClibc/ldso/ldso/ldso.c:1.101
--- uClibc/ldso/ldso/ldso.c:1.100 Wed Jul 14 17:07:45 2004
+++ uClibc/ldso/ldso/ldso.c Thu Jul 29 21:32:40 2004
@@ -41,13 +41,12 @@
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; /* Location of the shared lib loader */
-unsigned char *_dl_malloc_addr = 0; /* Lets _dl_malloc use the already allocated memory page */
-unsigned char *_dl_mmap_zero = 0; /* Also used by _dl_malloc */
unsigned long *_dl_brkp = 0; /* The end of the data segment for brk and sbrk */
unsigned long *_dl_envp = 0; /* The environment address */
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 */
@@ -74,8 +73,8 @@
{
}
-/* This global variable is also to communicate with debuggers such as gdb. */
-struct r_debug *_dl_debug_addr = NULL;
+static unsigned char *_dl_malloc_addr = 0; /* Lets _dl_malloc use the already allocated memory page */
+static unsigned char *_dl_mmap_zero = 0; /* Also used by _dl_malloc */
@@ -757,5 +756,42 @@
return 0;
}
+void *(*_dl_malloc_function) (size_t size) = NULL;
+void *_dl_malloc(int size)
+{
+ void *retval;
+
+#if 0
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+ _dl_dprintf(2, "malloc: request for %d bytes\n", size);
+#endif
+#endif
+
+ if (_dl_malloc_function)
+ return (*_dl_malloc_function) (size);
+
+ if (_dl_malloc_addr - _dl_mmap_zero + size > _dl_pagesize) {
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+ _dl_dprintf(2, "malloc: mmapping more memory\n");
+#endif
+ _dl_mmap_zero = _dl_malloc_addr = _dl_mmap((void *) 0, size,
+ PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (_dl_mmap_check_error(_dl_mmap_zero)) {
+ _dl_dprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
+ _dl_exit(20);
+ }
+ }
+ retval = _dl_malloc_addr;
+ _dl_malloc_addr += size;
+
+ /*
+ * Align memory to 4 byte boundary. Some platforms require this, others
+ * simply get better performance.
+ */
+ _dl_malloc_addr = (unsigned char *) (((unsigned long) _dl_malloc_addr + 3) & ~(3));
+ return retval;
+}
+
+
#include "dl-hash.c"
#include "dl-elf.c"
Index: uClibc/ldso/libdl/Makefile
diff -u uClibc/ldso/libdl/Makefile:1.36 uClibc/ldso/libdl/Makefile:1.37
--- uClibc/ldso/libdl/Makefile:1.36 Thu Feb 12 01:51:21 2004
+++ uClibc/ldso/libdl/Makefile Thu Jul 29 21:32:41 2004
@@ -23,12 +23,12 @@
XXFLAGS=$(XWARNINGS) $(OPTIMIZATION) $(XARCH_CFLAGS) $(CPU_CFLAGS) \
-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
- -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I. -I$(TOPDIR)include
+ -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso -I. -I$(TOPDIR)include
ifeq ($(DODEBUG),y)
XXFLAGS=$(XWARNINGS) -O0 -g3 $(XARCH_CFLAGS) $(CPU_CFLAGS) \
-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
- -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I. -I$(TOPDIR)include
+ -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso I. -I$(TOPDIR)include
endif
XXFLAGS+=$(shell $(CC) -print-search-dirs | sed -ne "s/install: *\(.*\)/-I\1include/gp")
Index: uClibc/ldso/libdl/libdl.c
diff -u uClibc/ldso/libdl/libdl.c:1.45 uClibc/ldso/libdl/libdl.c:1.46
--- uClibc/ldso/libdl/libdl.c:1.45 Thu Jul 29 18:21:01 2004
+++ uClibc/ldso/libdl/libdl.c Thu Jul 29 21:32:41 2004
@@ -31,6 +31,7 @@
#include <ldso.h>
+#include <stdio.h>
#if defined (__LIBDL_SHARED__)
@@ -38,7 +39,6 @@
/* When libdl is loaded as a shared library, we need to load in
* and use a pile of symbols from ldso... */
-extern void _dl_dprintf(int, const char *, ...) __attribute__ ((__weak__));
extern char *_dl_find_hash(const char *, struct dyn_elf *, int)
__attribute__ ((__weak__));
extern struct elf_resolve * _dl_load_shared_library(int, struct dyn_elf **,
@@ -64,13 +64,6 @@
#endif
#ifdef __SUPPORT_LD_DEBUG__
extern char *_dl_debug __attribute__ ((__weak__));
-extern char *_dl_debug_symbols __attribute__ ((__weak__));
-extern char *_dl_debug_move __attribute__ ((__weak__));
-extern char *_dl_debug_reloc __attribute__ ((__weak__));
-extern char *_dl_debug_detail __attribute__ ((__weak__));
-extern char *_dl_debug_nofixups __attribute__ ((__weak__));
-extern char *_dl_debug_bindings __attribute__ ((__weak__));
-extern int _dl_debug_file __attribute__ ((__weak__));
#endif
@@ -81,22 +74,15 @@
#ifdef __SUPPORT_LD_DEBUG__
char *_dl_debug = 0;
-char *_dl_debug_symbols = 0;
-char *_dl_debug_move = 0;
-char *_dl_debug_reloc = 0;
-char *_dl_debug_detail = 0;
-char *_dl_debug_nofixups = 0;
-char *_dl_debug_bindings = 0;
-int _dl_debug_file = 2;
#endif
-char *_dl_library_path = 0;
-char *_dl_ldsopath = 0;
+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;
-static unsigned char *_dl_malloc_addr, *_dl_mmap_zero;
-void *(*_dl_malloc_function) (size_t size);
-int _dl_errno = 0;
-int _dl_fixup(struct dyn_elf *rpnt, int lazy);
-#include "../ldso/dl-progname.h" /* Pull in the name of ld.so */
+#define _dl_malloc malloc
+#include "dl-progname.h"
#include "../ldso/dl-hash.c"
#define _dl_trace_loaded_objects 0
#include "../ldso/dl-elf.c"
@@ -142,7 +128,7 @@
}
}
-void *_dlopen(const char *libname, int flag)
+void *dlopen(const char *libname, int flag)
{
struct elf_resolve *tpnt, *tfrom, *tcurr;
struct dyn_elf *dyn_chain, *rpnt = NULL;
@@ -163,7 +149,9 @@
/* 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 */
@@ -191,7 +179,7 @@
/* Try to load the specified library */
#ifdef __SUPPORT_LD_DEBUG__
if(_dl_debug)
- _dl_dprintf(_dl_debug_file, "Trying to dlopen '%s'\n", (char*)libname);
+ fprintf(stderr, "Trying to dlopen '%s'\n", (char*)libname);
#endif
if (!(tpnt = _dl_check_if_named_library_is_loaded((char *)libname, 0)))
tpnt = _dl_load_shared_library(0, &rpnt, tfrom, (char*)libname, 0);
@@ -220,7 +208,7 @@
#ifdef __SUPPORT_LD_DEBUG__
if(_dl_debug)
- _dl_dprintf(_dl_debug_file, "Looking for needed libraries\n");
+ fprintf(stderr, "Looking for needed libraries\n");
#endif
for (tcurr = tpnt; tcurr; tcurr = tcurr->next)
@@ -240,7 +228,7 @@
#ifdef __SUPPORT_LD_DEBUG__
if(_dl_debug)
- _dl_dprintf(_dl_debug_file, "Trying to load '%s', needed by '%s'\n",
+ fprintf(stderr, "Trying to load '%s', needed by '%s'\n",
lpntstr, tcurr->libname);
#endif
@@ -273,7 +261,7 @@
#ifdef __SUPPORT_LD_DEBUG__
if(_dl_debug)
- _dl_dprintf(_dl_debug_file, "Beginning dlopen relocation fixups\n");
+ fprintf(stderr, "Beginning dlopen relocation fixups\n");
#endif
/*
* OK, now all of the kids are tucked into bed in their proper addresses.
@@ -298,11 +286,6 @@
}
}
-#if 0 //def __SUPPORT_LD_DEBUG__
- if(_dl_debug)
- _dlinfo();
-#endif
-
#if defined (__LIBDL_SHARED__)
/* Find the last library so we can run things in the right order */
for (tpnt = dyn_chain->dyn; tpnt->next!=NULL; tpnt = tpnt->next)
@@ -328,7 +311,7 @@
if (dl_elf_func && *dl_elf_func != NULL) {
#ifdef __SUPPORT_LD_DEBUG__
if(_dl_debug)
- _dl_dprintf(2, "running ctors for library %s at '%x'\n", tpnt->libname, dl_elf_func);
+ fprintf(stderr, "running ctors for library %s at '%x'\n", tpnt->libname, dl_elf_func);
#endif
(*dl_elf_func) ();
}
@@ -339,7 +322,7 @@
if (dl_elf_func && *dl_elf_func != NULL) {
#ifdef __SUPPORT_LD_DEBUG__
if(_dl_debug)
- _dl_dprintf(2, "setting up dtors for library %s at '%x'\n", tpnt->libname, dl_elf_func);
+ fprintf(stderr, "setting up dtors for library %s at '%x'\n", tpnt->libname, dl_elf_func);
#endif
atexit(dl_elf_func);
}
@@ -354,9 +337,8 @@
do_dlclose(dyn_chain, 0);
return NULL;
}
-weak_alias(_dlopen, dlopen);
-void *_dlsym(void *vhandle, const char *name)
+void *dlsym(void *vhandle, const char *name)
{
struct elf_resolve *tpnt, *tfrom;
struct dyn_elf *handle;
@@ -409,7 +391,6 @@
_dl_error_number = LD_NO_SYMBOL;
return ret;
}
-weak_alias(_dlsym, dlsym);
static int do_dlclose(void *vhandle, int need_fini)
{
@@ -535,13 +516,12 @@
return 0;
}
-int _dlclose(void *vhandle)
+int dlclose(void *vhandle)
{
return do_dlclose(vhandle, 1);
}
-weak_alias(_dlclose, dlclose);
-const char *_dlerror(void)
+const char *dlerror(void)
{
const char *retval;
@@ -551,22 +531,21 @@
_dl_error_number = 0;
return retval;
}
-weak_alias(_dlerror, dlerror);
/*
* Dump information to stderrr about the current loaded modules
*/
static char *type[] = { "Lib", "Exe", "Int", "Mod" };
-void _dlinfo(void)
+void dlinfo(void)
{
struct elf_resolve *tpnt;
struct dyn_elf *rpnt, *hpnt;
- _dl_dprintf(2, "List of loaded modules\n");
+ fprintf(stderr, "List of loaded modules\n");
/* First start with a complete list of all of the loaded files. */
for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
- _dl_dprintf(2, "\t%x %x %x %s %d %s\n",
+ fprintf(stderr, "\t%x %x %x %s %d %s\n",
(unsigned) tpnt->loadaddr, (unsigned) tpnt,
(unsigned) tpnt->symbol_scope,
type[tpnt->libtype],
@@ -574,21 +553,20 @@
}
/* Next dump the module list for the application itself */
- _dl_dprintf(2, "\nModules for application (%x):\n",
+ fprintf(stderr, "\nModules for application (%x):\n",
(unsigned) _dl_symbol_tables);
for (rpnt = _dl_symbol_tables; rpnt; rpnt = rpnt->next)
- _dl_dprintf(2, "\t%x %s\n", (unsigned) rpnt->dyn, rpnt->dyn->libname);
+ fprintf(stderr, "\t%x %s\n", (unsigned) rpnt->dyn, rpnt->dyn->libname);
for (hpnt = _dl_handles; hpnt; hpnt = hpnt->next_handle) {
- _dl_dprintf(2, "Modules for handle %x\n", (unsigned) hpnt);
+ fprintf(stderr, "Modules for handle %x\n", (unsigned) hpnt);
for (rpnt = hpnt; rpnt; rpnt = rpnt->next)
- _dl_dprintf(2, "\t%x %s\n", (unsigned) rpnt->dyn,
+ fprintf(stderr, "\t%x %s\n", (unsigned) rpnt->dyn,
rpnt->dyn->libname);
}
}
-weak_alias(_dlinfo, dlinfo);
-int _dladdr(void *__address, Dl_info * __dlip)
+int dladdr(void *__address, Dl_info * __dlip)
{
struct elf_resolve *pelf;
struct elf_resolve *rpnt;
@@ -601,7 +579,7 @@
pelf = NULL;
#if 0
- _dl_dprintf(2, "dladdr( %x, %x )\n", __address, __dlip);
+ fprintf(stderr, "dladdr( %x, %x )\n", __address, __dlip);
#endif
for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next) {
@@ -609,7 +587,7 @@
tpnt = rpnt;
#if 0
- _dl_dprintf(2, "Module \"%s\" at %x\n",
+ fprintf(stderr, "Module \"%s\" at %x\n",
tpnt->libname, tpnt->loadaddr);
#endif
if (tpnt->loadaddr < (ElfW(Addr)) __address
@@ -650,7 +628,7 @@
sf = 1;
}
#if 0
- _dl_dprintf(2, "Symbol \"%s\" at %x\n",
+ fprintf(stderr, "Symbol \"%s\" at %x\n",
strtab + symtab[si].st_name, symbol_addr);
#endif
}
@@ -665,4 +643,3 @@
return 1;
}
}
-weak_alias(_dladdr, dladdr);
More information about the uClibc-cvs
mailing list