summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/Makefile90
-rw-r--r--libc/inet/Makefile4
-rw-r--r--libc/misc/internals/Makefile4
-rw-r--r--libc/misc/internals/__uClibc_main.c60
-rw-r--r--libc/misc/syslog/Makefile4
-rw-r--r--libc/stdio/Makefile4
-rw-r--r--libc/stdlib/malloc-standard/Makefile10
-rw-r--r--libc/sysdeps/linux/mips/Makefile12
8 files changed, 115 insertions, 73 deletions
diff --git a/libc/Makefile b/libc/Makefile
index 231c8112e..07ae4085c 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -37,9 +37,17 @@ DIRS = misc pwd_grp stdio string termios inet signal stdlib sysdeps unistd
VERSION_SCRIPT:=${shell if [ -f sysdeps/linux/$(TARGET_ARCH)/libc.map ] ; then \
echo "--version-script sysdeps/linux/$(TARGET_ARCH)/libc.map"; fi}
-LIBNAME_TARGET:=$(TOPDIR)lib/$(LIBNAME)
-
-all: halfclean $(LIBNAME_TARGET)
+# we have SHARED_MAJORNAME=libc.so.$(MAJOR_VERSION) defined in Rules.mak
+LIB_NAME=libc
+AR_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).a
+SO_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).so
+SO_FULL_NAME=libuClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
+
+ifeq ($(strip $(HAVE_SHARED)),y)
+all: $(SO_LIB_NAME)
+else
+all: $(AR_LIB_NAME)
+endif
# Some functions are duplicated across subdirs, and when you pass $(AR)
# the same object file more than once, it'll add it to the archive multiple
@@ -52,53 +60,63 @@ all: halfclean $(LIBNAME_TARGET)
# 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) shared_$(LIBNAME) ar-target: subdirs objs-pthread-libc
- $(RM) $(LIBNAME) shared_$(LIBNAME)
+shared_$(LIB_NAME).a: subdirs
+ $(RM) shared_$(LIB_NAME).a obj.pthread.*
objs=`cat obj.*` ; \
- $(AR) $(ARFLAGS) $(LIBNAME) $$objs && \
- $(AR) dN 2 $(LIBNAME) $$objs && \
- $(AR) dN 2 $(LIBNAME) $$objs
+ $(AR) $(ARFLAGS) shared_$(LIB_NAME).a $$objs && \
+ $(AR) dN 2 shared_$(LIB_NAME).a $$objs && \
+ $(AR) dN 2 shared_$(LIB_NAME).a $$objs
@for objfile in obj.signal \
obj.string.generic obj.string.$(TARGET_ARCH) obj.string \
obj.sysdeps.common obj.sysdeps.$(TARGET_ARCH) ; do \
if [ -e $$objfile ] ; then \
if [ "$(MAKE_IS_SILENT)" = "n" ] ; then \
- echo $(AR) $(ARFLAGS) $(LIBNAME) $$objfile ; \
+ echo $(AR) $(ARFLAGS) shared_$(LIB_NAME).a $$objfile ; \
fi ; \
objs=`cat $$objfile` ; \
fi ; \
- $(AR) $(ARFLAGS) $(LIBNAME) $$objs || exit 1 ; \
+ $(AR) $(ARFLAGS) shared_$(LIB_NAME).a $$objs || exit 1 ; \
done
- cp $(LIBNAME) shared_$(LIBNAME)
- $(AR) $(ARFLAGS) $(LIBNAME) misc/internals/static.o
- $(AR) $(ARFLAGS) $(LIBNAME) `cat "$(PTCOBJST)"`
- $(RANLIB) $(LIBNAME)
-
-$(LIBNAME_TARGET): $(LIBNAME)
- $(INSTALL) -d $(TOPDIR)lib
- $(RM) $(TOPDIR)lib/$(LIBNAME)
- $(INSTALL) -m 644 $(LIBNAME) $(TOPDIR)lib
-shared: shared_$(LIBNAME)
- $(AR) $(ARFLAGS) shared_$(LIBNAME) `cat "$(PTCOBJSH)"`
- $(LD) $(LDFLAGS) $(VERSION_SCRIPT) -soname=$(SHARED_MAJORNAME) -o $(SHARED_FULLNAME) \
- --whole-archive shared_$(LIBNAME) \
- $(TOPDIR)libc/misc/internals/interp.o --no-whole-archive \
- -init __uClibc_init $(TOPDIR)lib/$(UCLIBC_LDSO) $(LIBGCC) $(LDADD_LIBFLOAT)
+$(AR_LIB_NAME): shared_$(LIB_NAME).a
$(INSTALL) -d $(TOPDIR)lib
- $(RM) $(TOPDIR)lib/$(SHARED_FULLNAME)
- $(INSTALL) -m 644 $(SHARED_FULLNAME) $(TOPDIR)lib
- $(LN) -sf $(SHARED_FULLNAME) $(TOPDIR)lib/libc.so
- $(LN) -sf $(SHARED_FULLNAME) $(TOPDIR)lib/$(SHARED_MAJORNAME)
-
-halfclean:
- $(RM) $(LIBNAME) shared_$(LIBNAME) $(SHARED_FULLNAME)
+ $(RM) $(AR_LIB_NAME)
+ cp shared_$(LIB_NAME).a $(AR_LIB_NAME)
+ $(AR) $(ARFLAGS) $(AR_LIB_NAME) misc/internals/static.o `cat nonshared_obj.*`
+ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+ $(MAKE) -C $(TOPDIR)libpthread/nptl obj.pthread.ar
+ $(AR) $(ARFLAGS) $(AR_LIB_NAME) `cat obj.pthread.ar`
+endif
+
+$(SO_LIB_NAME): $(AR_LIB_NAME)
+ $(RM) $(TOPDIR)lib/$(SO_FULL_NAME) $(TOPDIR)lib/$(SHARED_MAJORNAME) $(SO_LIB_NAME)
+ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+ $(MAKE) -C $(TOPDIR)libpthread/nptl obj.pthread.so
+ $(AR) $(ARFLAGS) shared_$(LIB_NAME).a `cat obj.pthread.so`
+endif
+ $(LD) $(LDFLAGS) $(VERSION_SCRIPT) -soname=$(SHARED_MAJORNAME) \
+ -o $(TOPDIR)lib/$(SO_FULL_NAME) --whole-archive shared_$(LIB_NAME).a \
+ --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \
+ -init __uClibc_init $(TOPDIR)lib/$(UCLIBC_LDSO) $(LDADD_LIBFLOAT) $(LIBGCC)
+ $(LN) -sf $(SO_FULL_NAME) $(TOPDIR)lib/$(SHARED_MAJORNAME)
+ $(RM) $(TOPDIR)lib/$(NONSHARED_LIBNAME)
+ $(AR) $(ARFLAGS) $(TOPDIR)lib/$(NONSHARED_LIBNAME) `cat nonshared_obj.*`
+ echo "/* GNU ld script" > $(SO_LIB_NAME)
+ echo " * Use the shared library, but some functions are only in" >> $(SO_LIB_NAME)
+ echo " * the static library, so try that secondarily. */" >> $(SO_LIB_NAME)
+ #OUT_FORMAT:=$(shell $(LD) --verbose | grep OUTPUT_FORMAT | awk -F '"' '{print $2}')
+ #echo "OUTPUT_FORMAT($(OUT_FORMAT))" >> $(SO_LIB_NAME)
+ifeq ($(strip $(COMPAT_ATEXIT)),y)
+ echo "GROUP ( $(TOPDIR)lib/$(NONSHARED_LIBNAME) $(TOPDIR)lib/$(SHARED_MAJORNAME) )" >> $(SO_LIB_NAME)
+else
+ echo "GROUP ( $(TOPDIR)lib/$(SHARED_MAJORNAME) $(TOPDIR)lib/$(NONSHARED_LIBNAME) )" >> $(SO_LIB_NAME)
+endif
tags:
ctags -R
-clean: subdirs_clean halfclean
- $(RM) obj.* obj-*
+clean: subdirs_clean
+ $(RM) *.a obj.* nonshared_obj.*
subdirs: $(patsubst %, _dir_%, $(DIRS))
subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS))
@@ -109,8 +127,4 @@ $(patsubst %, _dir_%, $(DIRS)) : dummy
$(patsubst %, _dirclean_%, $(DIRS)) : dummy
$(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
-objs-pthread-libc:
- $(RM) $(PTCOBJST) $(PTCOBJSH)
- $(MAKE) -C ../libpthread $@
-
.PHONY: dummy subdirs
diff --git a/libc/inet/Makefile b/libc/inet/Makefile
index e7018db7c..6d59e1856 100644
--- a/libc/inet/Makefile
+++ b/libc/inet/Makefile
@@ -56,6 +56,10 @@ CSRC =getservice.c getproto.c hostid.c getnetent.c getnetbynm.c getnetbyad.c \
COBJS=$(patsubst %.c,%.o, $(CSRC))
+ifeq ($(UCLIBC_HAS_THREADS),y)
+CFLAGS += $(PTINC)
+endif
+
OBJS=$(MOBJ) $(MOBJ2) $(MOBJ3) $(COBJS)
OBJ_LIST=../obj.inet
diff --git a/libc/misc/internals/Makefile b/libc/misc/internals/Makefile
index fee3eca70..1df05a934 100644
--- a/libc/misc/internals/Makefile
+++ b/libc/misc/internals/Makefile
@@ -31,6 +31,10 @@ __uClibc_main.o: CFLAGS += $(SSP_DISABLE_FLAGS)
OBJS=$(COBJS)
+ifeq ($(UCLIBC_HAS_THREADS),y)
+CFLAGS += $(PTINC)
+endif
+
OBJ_LIST=../../obj.misc.internals
all: $(OBJ_LIST) interp.o static.o
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 1ed05c6b2..8ed1f8d71 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -27,8 +27,12 @@
#include <sys/sysmacros.h>
#ifdef __UCLIBC_HAS_SSP__
#include <ssp-internal.h>
+#include <stdint.h>
-unsigned long __guard = 0UL;
+/* for gcc-3.x + Etoh ssp */
+uintptr_t __guard /* segfaults with attribute_relro */;
+/* for gcc-4.1 non-TLS */
+uintptr_t __stack_chk_guard /* attribute_relro */;
#endif
/*
@@ -43,13 +47,13 @@ extern void weak_function _locale_init(void);
#endif
#ifdef __UCLIBC_HAS_THREADS__
extern void weak_function __pthread_initialize_minimal(void);
-extern void weak_function _dl_aux_init(ElfW(auxv_t) *);
#endif
+
/*
* Declare the __environ global variable and create a weak alias environ.
* Note: Apparently we must initialize __environ to ensure that the weak
@@ -108,11 +112,9 @@ static int __check_suid(void)
}
#ifdef __UCLIBC_HAS_SSP__
-static __always_inline void __guard_setup(void)
+static __always_inline uintptr_t _dl_guard_setup(void)
{
- if (__guard != 0UL)
- return;
-
+ uintptr_t ret;
#ifndef __SSP_QUICK_CANARY__
size_t size;
@@ -125,10 +127,9 @@ static __always_inline void __guard_setup(void)
mib[1] = KERN_RANDOM;
mib[2] = RANDOM_ERANDOM;
- size = sizeof(unsigned long);
- if (SYSCTL(mib, 3, &__guard, &size, NULL, 0) != (-1))
- if (__guard != 0UL)
- return;
+ if (SYSCTL(mib, 3, &ret, &size, NULL, 0) != (-1))
+ if (size == (size_t) sizeof(ret))
+ return ret;
}
# endif /* ifdef __SSP_USE_ERANDOM__ */
{
@@ -142,25 +143,26 @@ static __always_inline void __guard_setup(void)
if ((fd = OPEN("/dev/erandom", O_RDONLY)) == (-1))
# endif
fd = OPEN("/dev/urandom", O_RDONLY);
- if (fd != (-1)) {
- size = READ(fd, (char *) &__guard, sizeof(__guard));
+ if (fd >= 0) {
+ size = READ(fd, &ret, sizeof(ret));
CLOSE(fd);
- if (size == sizeof(__guard))
- return;
+ if (size == (size_t) sizeof(ret))
+ return ret;
}
}
#endif /* ifndef __SSP_QUICK_CANARY__ */
/* Start with the "terminator canary". */
- __guard = 0xFF0A0D00UL;
+ ret = 0xFF0A0D00UL;
/* Everything failed? Or we are using a weakened model of the
* terminator canary */
{
struct timeval tv;
- GETTIMEOFDAY(&tv, NULL);
- __guard ^= tv.tv_usec ^ tv.tv_sec;
+ if (GETTIMEOFDAY(&tv, NULL) != (-1))
+ ret ^= tv.tv_usec ^ tv.tv_sec;
}
+ return ret;
}
#endif /* __UCLIBC_HAS_SSP__ */
@@ -199,7 +201,11 @@ void __uClibc_init(void)
#endif
#ifdef __UCLIBC_HAS_SSP__
- __guard_setup ();
+ uintptr_t stack_chk_guard = _dl_guard_setup();
+ /* for gcc-3.x + Etoh ssp */
+ __guard = stack_chk_guard;
+ /* for gcc-4.1 non-TLS */
+ __stack_chk_guard = stack_chk_guard;
#endif
#ifdef __UCLIBC_HAS_LOCALE__
@@ -265,13 +271,17 @@ __uClibc_main(int (*main)(int, char **, char **), int argc,
aux_dat += 2;
}
-#ifdef __UCLIBC_HAS_THREADS__
- /*
- * Before we can make any pthread calls, we have to do some
- * some TLS setup. This call may do more in the future.
- */
- if (likely(_dl_aux_init != NULL))
- _dl_aux_init(auxvt);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ {
+ extern void _dl_aux_init (ElfW(auxv_t) *av);
+
+ /*
+ * Before we can make any pthread calls, we have to do some
+ * some TLS setup. This call may do more in the future.
+ */
+ if (likely(_dl_aux_init != NULL))
+ _dl_aux_init(auxvt);
+ }
#endif
/* We need to initialize uClibc. If we are dynamically linked this
diff --git a/libc/misc/syslog/Makefile b/libc/misc/syslog/Makefile
index 35e755e40..26239ab7b 100644
--- a/libc/misc/syslog/Makefile
+++ b/libc/misc/syslog/Makefile
@@ -28,6 +28,10 @@ CSRC=syslog.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
OBJS=$(COBJS)
+ifeq ($(UCLIBC_HAS_THREADS),y)
+CFLAGS += $(PTINC)
+endif
+
OBJ_LIST=../../obj.misc.syslog
all: $(OBJ_LIST)
diff --git a/libc/stdio/Makefile b/libc/stdio/Makefile
index dc2a29173..729e4dd81 100644
--- a/libc/stdio/Makefile
+++ b/libc/stdio/Makefile
@@ -119,6 +119,10 @@ ifeq ($(strip $(UCLIBC_HAS_LFS)),y)
OBJS += $(CLOBJS)
endif
+ifeq ($(UCLIBC_HAS_THREADS),y)
+CFLAGS += $(PTINC)
+endif
+
ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y)
CFLAGS += -D__USE_STDIO_FUTEXES__
endif
diff --git a/libc/stdlib/malloc-standard/Makefile b/libc/stdlib/malloc-standard/Makefile
index acd7526e9..54022ec13 100644
--- a/libc/stdlib/malloc-standard/Makefile
+++ b/libc/stdlib/malloc-standard/Makefile
@@ -32,11 +32,17 @@ endif
# calloc.c can be found at uClibc/libc/stdlib/calloc.c
# valloc.c can be found at uClibc/libc/stdlib/valloc.c
CSRC=malloc.c calloc.c realloc.c free.c memalign.c mallopt.c mallinfo.c
+
+COBJS=$(patsubst %.c,%.o, $(CSRC))
+
+OBJS=$(COBJS)
+
+ifeq ($(UCLIBC_HAS_THREADS),y)
+CFLAGS += $(PTINC)
ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
CSRC += thread-freeres.c
endif
-COBJS=$(patsubst %.c,%.o, $(CSRC))
-OBJS=$(COBJS)
+endif
OBJ_LIST=../../obj.stdlib.malloc-standard
diff --git a/libc/sysdeps/linux/mips/Makefile b/libc/sysdeps/linux/mips/Makefile
index 91da020dd..6d51205e9 100644
--- a/libc/sysdeps/linux/mips/Makefile
+++ b/libc/sysdeps/linux/mips/Makefile
@@ -60,14 +60,14 @@ $(COBJS): %.o : %.c
ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
crti.o: crti.S
- $(CC) $(ASFLAGS) -c crti.S -o crti.o
+ $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crti.S -o crti.o
$(TOPDIR)lib/crti.o: crti.o
$(INSTALL) -d $(TOPDIR)lib/
cp crti.o $(TOPDIR)lib/
crtn.o: crtn.S
- $(CC) $(ASFLAGS) -c crtn.S -o crtn.o
+ $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c crtn.S -o crtn.o
$(TOPDIR)lib/crtn.o: crtn.o
$(INSTALL) -d $(TOPDIR)lib/
@@ -87,9 +87,5 @@ headers:
cp sysdep.h $(TOPDIR)/include/
clean:
- $(RM) *.[oa] *~ core
- $(RM) bits/sysnum.h
- $(RM) $(TOPDIR)/include/fpu_control.h
- $(RM) $(TOPDIR)/include/sgidefs.h
- $(RM) $(TOPDIR)/include/sysdep.h
- $(RM) $(TOPDIR)/include/sysdep-nptl.h
+ $(RM) *.o *~ core
+ $(RM) $(TOPDIR)/include/sgidefs.h $(TOPDIR)/include/sysdep.h