@@ -99,6 +99,7 @@ static __inline__ int msync (void *__addr, size_t __len, int __flags) { return 0
#endif
+#ifdef __ARCH_USE_MMU__
#if defined __USE_BSD && (defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__)
/* Advise the system about particular usage patterns the program follows
for the region starting at ADDR and extending LEN bytes. */
@@ -108,6 +109,8 @@ extern int madvise (void *__addr, size_t __len, int __advice) __THROW;
/* This is the POSIX name for this function. */
extern int posix_madvise (void *__addr, size_t __len, int __advice) __THROW;
#endif
+#endif /* __ARCH_USE_MMU__ */
+
#if defined __UCLIBC_HAS_REALTIME__
# ifdef __ARCH_USE_MMU__
@@ -93,6 +93,6 @@ static __always_inline void
elf_machine_relative (DL_LOADADDR_TYPE load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
{
- return 0;
+ return;
}
#endif
@@ -30,6 +30,14 @@
*/
+/* When libdl is linked in statically into libc.a, we need to replace
+ * these symbols that otherwise would have been loaded in from ldso.
+ * This must be before including ldso.h */
+#ifndef SHARED
+#define _dl_malloc malloc
+#define _dl_free free
+#endif
+
#include <ldso.h>
#include <stdio.h>
#include <string.h>
@@ -86,9 +94,6 @@ extern char *_dl_debug;
#else /* !SHARED */
-#define _dl_malloc malloc
-#define _dl_free free
-
/* When libdl is linked as a static library, we need to replace all
* the symbols that otherwise would have been loaded in from ldso... */
@@ -25,7 +25,9 @@ libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS
else
libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.os
endif
-libc-static-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o
+# link order is important to not pull in pthread functions, when
+# a single threaded application is statically linked
+libc-static-y := $(MISC_INTERNALS_OUT)/__uClibc_main.o $(libc-static-y)
libc-static-$(UCLIBC_FORMAT_FLAT_SEP_DATA) += \
$(MISC_INTERNALS_OUT)/shared_flat_initfini.o \
$(MISC_INTERNALS_OUT)/shared_flat_add_library.o
@@ -68,6 +68,43 @@ uintptr_t __stack_chk_guard attribute_relro;
void internal_function _dl_aux_init (ElfW(auxv_t) *av);
+#ifdef __UCLIBC_HAS_THREADS__
+/*
+ * uClibc internal locking requires that we have weak aliases
+ * for dummy functions in case a single threaded application is linked.
+ * This needs to be in compilation unit that is pulled always
+ * in or linker will disregard these weaks.
+ */
+
+static int __pthread_return_0 (pthread_mutex_t *unused) { return 0; }
+weak_alias (__pthread_return_0, __pthread_mutex_lock)
+weak_alias (__pthread_return_0, __pthread_mutex_trylock)
+weak_alias (__pthread_return_0, __pthread_mutex_unlock)
+
+int weak_function
+__pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
+{
+ return 0;
+}
+
+void weak_function
+_pthread_cleanup_push_defer(struct _pthread_cleanup_buffer *__buffer,
+ void (*__routine) (void *), void *__arg)
+{
+ __buffer->__routine = __routine;
+ __buffer->__arg = __arg;
+}
+
+void weak_function
+_pthread_cleanup_pop_restore(struct _pthread_cleanup_buffer *__buffer,
+ int __execute)
+{
+ if (__execute)
+ __buffer->__routine(__buffer->__arg);
+}
+
+#endif /* __UCLIBC_HAS_THREADS__ */
+
#endif /* !SHARED */
/* Defeat compiler optimization which assumes function addresses are never NULL */
@@ -9,6 +9,8 @@
#include <sys/syscall.h>
#include <sys/mman.h>
+#ifdef __ARCH_USE_MMU__
#if defined __NR_madvise && defined __USE_BSD
_syscall3(int, madvise, void *, __addr, size_t, __len, int, __advice)
+#endif /* __ARCH_USE_MMU__ */
#endif
@@ -32,10 +32,11 @@ libpthread_arch_SOBJ = $(patsubst %.S,$(libpthread_arch_OUT)/%.o,$(libpthread_ar
libpthread_arch_OBJS = $(libpthread_subarch_OBJS) $(libpthread_arch_COBJ) $(libpthread_arch_SOBJ)
libc_arch_COBJ = $(patsubst %.c,$(libpthread_arch_OUT)/%.o,$(libc_arch_CSRC))
-libc_arch_SOBJ = $(patsubst %.c,$(libpthread_arch_OUT)/%.o,$(libc_arch_SSRC))
+libc_arch_SOBJ = $(patsubst %.S,$(libpthread_arch_OUT)/%.o,$(libc_arch_SSRC))
libc_arch_OBJS = $(libc_arch_COBJ) $(libc_arch_SOBJ)
libc_arch_a_COBJ = $(patsubst %.c,$(libpthread_arch_OUT)/%.o,$(libc_arch_a_CSRC))
-libc_arch_a_OBJS = $(libc_arch_a_COBJ)
+libc_arch_a_SOBJ = $(patsubst %.S,$(libpthread_arch_OUT)/%.o,$(libc_arch_a_SSRC))
+libc_arch_a_OBJS = $(libc_arch_a_COBJ) $(libc_arch_a_SOBJ)
librt_arch_COBJ = $(patsubst %.c,$(libpthread_arch_OUT)/%.o,$(librt_arch_CSRC))
librt_arch_SOBJ = $(patsubst %.S,$(libpthread_arch_OUT)/%.o,$(librt_arch_SSRC))
@@ -20,7 +20,7 @@ ASFLAGS-pthread_spin_lock.S = -DNOT_IN_libc -DIS_IN_libpthread
ASFLAGS-pthread_spin_trylock.S = -DNOT_IN_libc -DIS_IN_libpthread
libc_arch_a_CSRC = libc-tls.c
-librt_arch_a_SSRC = dl-tlsdesc.S
+libc_arch_a_SSRC = libc-dl-tlsdesc.S
CFLAGS-gen_tlsdesc.c = -S
$(libpthread_arch_OUT)/gen_tlsdesc.c: $(libpthread_arch_DIR)/tlsdesc.sym | $(libpthread_arch_OUT)
new file mode 100644
@@ -0,0 +1 @@
+#include <ldso/ldso/xtensa/dl-tlsdesc.S>
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "uClibc-ng - small C library for embedded systems". The branch, master has been updated via 5ca03df6978345c297225212cc0ca33d476b0272 (commit) via 6579597083e608f5a66fe8a898d113c2588e2c8f (commit) via 569914be2e968a1bda8b4982ca97c1524635174e (commit) via 1f79f41508d0f9c30be812bea9b84fd7900a273e (commit) via 25a60624713990c637f125e094e968ff4655307c (commit) via bf7a84dc1fd8c9c340222260cb3e53019715088c (commit) from b5bd012fab8560a78c70edef7e921e2b950dd02f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 5ca03df6978345c297225212cc0ca33d476b0272 Author: Waldemar Brodkorb <wbx@openadk.org> Date: Wed Dec 7 07:56:44 2016 +0100 threads: optimize single threaded applications Revert the removal of the weak pthread functions and guarantee a link order so that single threaded applications doesn't link in all the pthread functions they don't use. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Tested-by: Waldemar Brodkorb <wbx@uclibc-ng.org> commit 6579597083e608f5a66fe8a898d113c2588e2c8f Author: Waldemar Brodkorb <wbx@openadk.org> Date: Wed Dec 7 07:59:34 2016 +0100 xtensa: fix static linking uClibc-ng 1.0.20 fixed static linking with "libdl" by adding all libdl functions into the libc. On xtensa, though, libdl contains an unresolved reference that is satisfied by the ld.so - which is not a part of the linking in a static case. Signed-off-by: Alexey Neyman <stilor@att.net> Acked-by: Max Filippov <jcmvbkbc@gmail.com> commit 569914be2e968a1bda8b4982ca97c1524635174e Author: Waldemar Brodkorb <wbx@openadk.org> Date: Thu Dec 8 04:36:10 2016 +0100 fix static linking for FDPIC toolchains Fixes following problem, when trying to compile a simple C application statically with a FDPIC toolchain (for example with Blackfin architecture): lib/libc.a(libdl.os): In function `do_dlclose': (.text+0x6be): undefined reference to `_dl_free' .. commit 1f79f41508d0f9c30be812bea9b84fd7900a273e Author: Waldemar Brodkorb <wbx@openadk.org> Date: Thu Dec 8 04:07:47 2016 +0100 bfin: fix a gcc warning commit 25a60624713990c637f125e094e968ff4655307c Author: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Date: Wed Dec 7 23:20:18 2016 +0100 include/sys/mman.h: remove madvise/posix_madvise prototypes on noMMU Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> commit bf7a84dc1fd8c9c340222260cb3e53019715088c Author: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Date: Wed Dec 7 23:18:49 2016 +0100 libc/sysdeps/linux/common/madvise.c: disable on noMMU architectures Similar to what was done in commit 9945c6d21797553e78cbef8034f6dd16b3824df5 for posix_madvise(). Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> ----------------------------------------------------------------------- Summary of changes: include/sys/mman.h | 3 ++ ldso/ldso/bfin/dl-sysdep.h | 2 +- ldso/libdl/libdl.c | 11 +++++-- libc/misc/internals/Makefile.in | 4 ++- libc/misc/internals/__uClibc_main.c | 37 ++++++++++++++++++++++++ libc/sysdeps/linux/common/madvise.c | 2 ++ libpthread/nptl/sysdeps/Makefile.commonarch | 5 ++-- libpthread/nptl/sysdeps/xtensa/Makefile.arch | 2 +- libpthread/nptl/sysdeps/xtensa/libc-dl-tlsdesc.S | 1 + 9 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 libpthread/nptl/sysdeps/xtensa/libc-dl-tlsdesc.S hooks/post-receive