OSDN Git Service

Add __libc_stack_end to libc.
authorJoakim Tjernlund <joakim.tjernlund@transmode.se>
Wed, 29 Jun 2005 23:21:45 +0000 (23:21 -0000)
committerJoakim Tjernlund <joakim.tjernlund@transmode.se>
Wed, 29 Jun 2005 23:21:45 +0000 (23:21 -0000)
libc/Makefile
libc/misc/internals/Makefile
libc/misc/internals/__uClibc_main.c
libc/misc/internals/static.c [new file with mode: 0644]

index fc31a2c..5a9a908 100644 (file)
@@ -52,7 +52,8 @@ all: halfclean $(LIBNAME_TARGET) $(DO_SHARED)
 # the wildcard will be evaluated when `make` is run instead of when the make 
 # target is evaluated.  That means if you run `rm obj.* ; make`, the wildcard 
 # will evaluate to no files :(.
-$(LIBNAME) ar-target: subdirs
+$(LIBNAME) shared_$(LIBNAME) ar-target: subdirs
+       $(RM) $(LIBNAME) shared_$(LIBNAME)
        objs=`cat obj.*` ; \
        $(AR) $(ARFLAGS) $(LIBNAME) $$objs && \
        $(AR) dN 2 $(LIBNAME) $$objs && \
@@ -66,6 +67,8 @@ $(LIBNAME) ar-target: subdirs
                fi ; \
                $(AR) $(ARFLAGS) $(LIBNAME) $$objs || exit 1 ; \
        done
+       cp $(LIBNAME) shared_$(LIBNAME)
+       $(AR) $(ARFLAGS) $(LIBNAME) misc/internals/static.o || exit 1
        $(RANLIB) $(LIBNAME)
 
 $(LIBNAME_TARGET): $(LIBNAME)
@@ -73,9 +76,9 @@ $(LIBNAME_TARGET): $(LIBNAME)
        $(RM) $(TOPDIR)lib/$(LIBNAME)
        $(INSTALL) -m 644 $(LIBNAME) $(TOPDIR)lib
 
-shared: $(LIBNAME)
+shared: shared_$(LIBNAME)
        $(LD) $(LDFLAGS) $(VERSION_SCRIPT) -soname=$(SHARED_MAJORNAME) -o $(SHARED_FULLNAME) \
-               --whole-archive $(LIBNAME) \
+               --whole-archive shared_$(LIBNAME) \
                $(TOPDIR)libc/misc/internals/interp.o --no-whole-archive \
                -init __uClibc_init $(LIBGCC) $(LDADD_LIBFLOAT)
        @true #$(RM) -r tmp
@@ -86,7 +89,7 @@ shared: $(LIBNAME)
        $(LN) -sf $(SHARED_FULLNAME) $(TOPDIR)lib/$(SHARED_MAJORNAME)
 
 halfclean:
-       @$(RM) $(LIBNAME) uClibc_config.h
+       @$(RM) $(LIBNAME) shared_$(LIBNAME) uClibc_config.h
        @$(RM) $(SHARED_FULLNAME) $(SHARED_MAJORNAME) uClibc-0.* libc.so*
 
 tags:
index 23816b3..933b169 100644 (file)
@@ -31,7 +31,7 @@ OBJS=$(COBJS)
 
 OBJ_LIST=../../obj.misc.internals
 
-all: $(OBJ_LIST) interp.o
+all: $(OBJ_LIST) interp.o static.o
 
 $(OBJ_LIST): $(OBJS)
        echo $(patsubst %, misc/internals/%, $(OBJS)) > $(OBJ_LIST)
@@ -44,11 +44,7 @@ interp.c: Makefile
                "(\".interp\"))) =\""$(DYNAMIC_LINKER)"\";" >> interp.c
        echo "#endif" >> interp.c
 
-interp.o: interp.c
-       $(CC) $(CFLAGS) -c $< -o $@
-       $(STRIPTOOL) -x -R .note -R .comment $*.o
-
-$(COBJS): %.o : %.c
+$(COBJS) interp.o static.o: %.o : %.c
        $(CC) $(CFLAGS) -c $< -o $@
        $(STRIPTOOL) -x -R .note -R .comment $*.o
 
index 071d6d6..21864ba 100644 (file)
@@ -32,6 +32,7 @@ extern void __guard_setup(void);
 /*
  * Prototypes.
  */
+extern void *__libc_stack_end;
 extern void weak_function _stdio_init(void);
 extern int *weak_const_function __errno_location(void);
 extern int *weak_const_function __h_errno_location(void);
@@ -172,7 +173,7 @@ __uClibc_main(int (*main)(int, char **, char **), int argc,
     unsigned long *aux_dat;
     Elf32_auxv_t auxvt[AT_EGID + 1];
 #endif
-
+    __libc_stack_end = stack_end;
     /* We need to initialize uClibc.  If we are dynamically linked this
      * may have already been completed by the shared lib loader.  We call
      * __uClibc_init() regardless, to be sure the right thing happens. */
diff --git a/libc/misc/internals/static.c b/libc/misc/internals/static.c
new file mode 100644 (file)
index 0000000..cd39ffd
--- /dev/null
@@ -0,0 +1,4 @@
+#include <stddef.h>
+
+/* Force static libraries to know about ... */
+void *__libc_stack_end=NULL;