Browse Source

Add __libc_stack_end to libc.

Joakim Tjernlund 19 years ago
parent
commit
8a8af03dce
4 changed files with 15 additions and 11 deletions
  1. 7 4
      libc/Makefile
  2. 2 6
      libc/misc/internals/Makefile
  3. 2 1
      libc/misc/internals/__uClibc_main.c
  4. 4 0
      libc/misc/internals/static.c

+ 7 - 4
libc/Makefile

@@ -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:

+ 2 - 6
libc/misc/internals/Makefile

@@ -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
 

+ 2 - 1
libc/misc/internals/__uClibc_main.c

@@ -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. */

+ 4 - 0
libc/misc/internals/static.c

@@ -0,0 +1,4 @@
+#include <stddef.h>
+
+/* Force static libraries to know about ... */
+void *__libc_stack_end=NULL;