[uClibc-cvs] uClibc/ldso/libdl Makefile,1.25,1.26 dlib.c,1.21,1.22
Erik Andersen
andersen at codepoet.org
Thu Dec 12 22:22:08 UTC 2002
Update of /var/cvs/uClibc/ldso/libdl
In directory winder:/tmp/cvs-serv15280/libdl
Modified Files:
Makefile dlib.c
Log Message:
Rework things such that staticly linked applications can use
dlopen and have it be successful. This required moving some
things out of ldso.c into readelflib1.c, and directly including
hash.c and readelflib1.c into dlib.c when building the static
version of the library.
-Erik
Index: Makefile
===================================================================
RCS file: /var/cvs/uClibc/ldso/libdl/Makefile,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- Makefile 25 Oct 2002 12:12:37 -0000 1.25
+++ Makefile 12 Dec 2002 22:22:03 -0000 1.26
@@ -16,42 +16,52 @@
# You should have received a copy of the GNU Library General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# Derived in part from the Linux-8086 C library, the GNU C Library, and several
-# other sundry sources. Files within this library are copyright by their
-# respective copyright holders.
TOPDIR=../../
include $(TOPDIR)Rules.mak
+XXFLAGS+=-DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
+ -DUCLIBC_DEVEL_PREFIX=\"$(DEVEL_PREFIX)\" \
+ -DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR) && pwd)\"
+ifeq ($(strip $(SUPPORT_LD_DEBUG)),y)
+XXFLAGS+=-D__SUPPORT_LD_DEBUG__
+endif
+
LIBDL=libdl.a
+LIBDL_PIC=libdl_pic.a
LIBDL_SHARED=libdl.so
LIBDL_SHARED_FULLNAME=libdl-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
-CSRC= dlib.c
-OBJS=$(patsubst %.c,%.o, $(CSRC))
+CSRC=dlib.c
+OBJS=dlib.o
+PIC_OBJS=dlib_pic.o
all: $(OBJS) $(LIBDL) shared
$(LIBDL): ar-target
-ar-target: $(OBJS)
- $(AR) $(ARFLAGS) $(LIBDL) $(OBJS)
+ar-target: $(OBJS) $(PIC_OBJS)
+ $(AR) $(ARFLAGS) $(LIBDL) ../ldso/$(TARGET_ARCH)/resolve.o $(OBJS)
+ $(AR) $(ARFLAGS) $(LIBDL_PIC) $(PIC_OBJS)
install -d $(TOPDIR)lib
rm -f $(TOPDIR)lib/$(LIBDL)
install -m 644 $(LIBDL) $(TOPDIR)lib
-$(OBJS): %.o : %.c
- $(CC) -I../ldso -I../ldso/$(TARGET_ARCH) $(CFLAGS) -c $< -o $@
+dlib.o: dlib.c
+ $(CC) -I../ldso -I../ldso/$(TARGET_ARCH) $(CFLAGS_NOPIC) $(XXFLAGS) -c dlib.c -o dlib.o
+ $(STRIPTOOL) -x -R .note -R .comment $*.o
+
+dlib_pic.o: dlib.c
+ $(CC) -I../ldso -I../ldso/$(TARGET_ARCH) $(CFLAGS) -c dlib.c -o dlib_pic.o
$(STRIPTOOL) -x -R .note -R .comment $*.o
$(OBJ): Makefile
shared:
$(LD) $(LDFLAGS) -soname=$(LIBDL_SHARED).$(MAJOR_VERSION) \
- -o $(LIBDL_SHARED_FULLNAME) --whole-archive $(LIBDL) \
+ -o $(LIBDL_SHARED_FULLNAME) --whole-archive $(LIBDL_PIC) \
--no-whole-archive $(TOPDIR)/libc/misc/internals/interp.o \
-L$(TOPDIR)/lib -lc;
install -d $(TOPDIR)lib
Index: dlib.c
===================================================================
RCS file: /var/cvs/uClibc/ldso/libdl/dlib.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- dlib.c 15 Nov 2002 14:37:59 -0000 1.21
+++ dlib.c 12 Dec 2002 22:22:03 -0000 1.22
@@ -12,7 +12,6 @@
#include "ld_hash.h"
#include "ld_string.h"
-extern int _dl_error_number;
extern struct r_debug *_dl_debug_addr;
extern void *(*_dl_malloc_function) (size_t size);
@@ -26,6 +25,7 @@
int dlclose(void *) __attribute__ ((__weak__, __alias__ ("_dlclose")));
int dladdr(void *, Dl_info *) __attribute__ ((__weak__, __alias__ ("_dladdr")));
+#ifdef __PIC__
/* This is a real hack. We need access to the dynamic linker, but we
also need to make it possible to link against this library without any
unresolved externals. We provide these weak symbols to make the link
@@ -60,8 +60,27 @@
extern struct dyn_elf *_dl_handles __attribute__ ((__weak__, __alias__ ("foobar1")));
extern struct elf_resolve *_dl_loaded_modules __attribute__ ((__weak__, __alias__ ("foobar1")));
extern struct r_debug *_dl_debug_addr __attribute__ ((__weak__, __alias__ ("foobar1")));
-extern int _dl_error_number __attribute__ ((__weak__, __alias__ ("foobar1")));
+extern unsigned long _dl_error_number __attribute__ ((__weak__, __alias__ ("foobar1")));
extern void *(*_dl_malloc_function)(size_t) __attribute__ ((__weak__, __alias__ ("foobar1")));
+#else
+#ifdef __SUPPORT_LD_DEBUG__
+static char *_dl_debug = 0;
+static char *_dl_debug_symbols = 0;
+static char *_dl_debug_move = 0;
+static char *_dl_debug_reloc = 0;
+static char *_dl_debug_detail = 0;
+static char *_dl_debug_nofixups = 0;
+static char *_dl_debug_bindings = 0;
+static int _dl_debug_file = 2;
+#endif
+char *_dl_library_path = 0;
+char *_dl_ldsopath = 0;
+struct r_debug *_dl_debug_addr = NULL;
+static char *_dl_malloc_addr, *_dl_mmap_zero;
+#include "../ldso/ldso.h" /* Pull in the name of ld.so */
+#include "../ldso/hash.c"
+#include "../ldso/readelflib1.c"
+#endif
static const char *dl_error_names[] = {
"",
@@ -109,7 +128,9 @@
static int dl_init = 0;
char *from;
void (*dl_brk) (void);
+#ifdef __PIC__
int (*dl_elf_init) (void);
+#endif
from = __builtin_return_address(0);
@@ -213,15 +234,18 @@
goto oops;
}
- dl_brk = (void (*)(void)) _dl_debug_addr->r_brk;
- if (dl_brk != NULL) {
+ if (_dl_debug_addr) {
+ dl_brk = (void (*)(void)) _dl_debug_addr->r_brk;
+ if (dl_brk != NULL) {
_dl_debug_addr->r_state = RT_ADD;
(*dl_brk) ();
_dl_debug_addr->r_state = RT_CONSISTENT;
(*dl_brk) ();
+ }
}
+#ifdef __PIC__
for (rpnt = dyn_chain; rpnt; rpnt = rpnt->next) {
tpnt = rpnt->dyn;
/* Apparently crt1 for the application is responsible for handling this.
@@ -244,6 +268,7 @@
}
}
+#endif
#ifdef USE_CACHE
_dl_unmap_cache();
@@ -476,13 +501,15 @@
}
- dl_brk = (void (*)(void)) _dl_debug_addr->r_brk;
- if (dl_brk != NULL) {
+ if (_dl_debug_addr) {
+ dl_brk = (void (*)(void)) _dl_debug_addr->r_brk;
+ if (dl_brk != NULL) {
_dl_debug_addr->r_state = RT_DELETE;
(*dl_brk) ();
_dl_debug_addr->r_state = RT_CONSISTENT;
(*dl_brk) ();
+ }
}
return 0;
More information about the uClibc-cvs
mailing list