uclibc: add upstream 0.9.33 fixes

Upstream has a large number of patches lined up for the next 0.9.33.x bugfix
release;

http://git.uclibc.org/uClibc/log/?h=0.9.33

Add them here, as atleast some of them are quite critical (E.G. the eventfd
issue gets triggered by recent glib versions).

I've skipped the microblaze and xtensa fixes as we don't currently support
those with 0.9.33.2.

Drop uclibc-0002-Add-definition-of-MSG_WAITFORONE-and-MSG_CMSG_CMSG_CLOEXE.patch
as that is a subset of uclibc-0035-socket.h-pull-socket_type.h-from-eglibc.patch

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
This commit is contained in:
Peter Korsgaard 2013-09-06 15:28:51 +02:00
parent 66c0d5d05c
commit 055f1c02d3
42 changed files with 4647 additions and 39 deletions

View File

@ -1,39 +0,0 @@
From e95694dfd24779acaab0bb1500f182e46f8a518d Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Sat, 13 Jul 2013 17:13:55 +0200
Subject: [PATCH 2/8] Add definition of MSG_WAITFORONE and MSG_CMSG_CLOEXEC
From yocto:
http://git.yoctoproject.org/cgit.cgi/poky/plain/meta/recipes-core/uclibc/uclibc-0.9.33/define-MSG_CMSG_CLOEXEC.patch
Upstream-Status: Pending
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
libc/sysdeps/linux/common/bits/socket.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/libc/sysdeps/linux/common/bits/socket.h b/libc/sysdeps/linux/common/bits/socket.h
index 7e12733..338fd92 100644
--- a/libc/sysdeps/linux/common/bits/socket.h
+++ b/libc/sysdeps/linux/common/bits/socket.h
@@ -235,8 +235,15 @@ enum
#define MSG_ERRQUEUE MSG_ERRQUEUE
MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */
#define MSG_NOSIGNAL MSG_NOSIGNAL
- MSG_MORE = 0x8000 /* Sender will send more. */
+ MSG_MORE = 0x8000, /* Sender will send more. */
#define MSG_MORE MSG_MORE
+ MSG_WAITFORONE = 0x10000, /* Wait for at least one packet to return.*/
+#define MSG_WAITFORONE MSG_WAITFORONE
+
+ MSG_CMSG_CLOEXEC = 0x40000000 /* Set close_on_exit for file
+ descriptor received through
+ SCM_RIGHTS. */
+#define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC
};
--
1.8.1.2

View File

@ -0,0 +1,64 @@
From 7810e4f8027b5c4c8ceec6fefec4eb779362ebb5 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 10 Jun 2012 09:36:23 -0700
Subject: [PATCH] eventfd: Implement eventfd2 and fix eventfd
eventfd: evntfd assumes to take two arguments instead it
should be one evntfd expects two therefore implement both syscalls with
correct parameters
Thanks Eugene Rudoy for reporting it and also providing the patch
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
libc/sysdeps/linux/common/eventfd.c | 16 ++++++++++++++--
libc/sysdeps/linux/common/stubs.c | 2 +-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/libc/sysdeps/linux/common/eventfd.c b/libc/sysdeps/linux/common/eventfd.c
index cc3f3f0..96597ab 100644
--- a/libc/sysdeps/linux/common/eventfd.c
+++ b/libc/sysdeps/linux/common/eventfd.c
@@ -7,12 +7,24 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+#include <errno.h>
#include <sys/syscall.h>
#include <sys/eventfd.h>
/*
* eventfd()
*/
-#ifdef __NR_eventfd
-_syscall2(int, eventfd, int, count, int, flags)
+#if defined __NR_eventfd || defined __NR_eventfd2
+int eventfd (int count, int flags)
+{
+#if defined __NR_eventfd2
+ return INLINE_SYSCALL (eventfd2, 2, count, flags);
+#elif defined __NR_eventfd
+ if (flags != 0) {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ return INLINE_SYSCALL (eventfd, 1, count);
+#endif
+}
#endif
diff --git a/libc/sysdeps/linux/common/stubs.c b/libc/sysdeps/linux/common/stubs.c
index 4d1e26c..7af14c1 100644
--- a/libc/sysdeps/linux/common/stubs.c
+++ b/libc/sysdeps/linux/common/stubs.c
@@ -93,7 +93,7 @@ make_stub(epoll_ctl)
make_stub(epoll_wait)
#endif
-#if !defined __NR_eventfd && defined __UCLIBC_LINUX_SPECIFIC__
+#if !defined __NR_eventfd && !defined __NR_eventfd2 && defined __UCLIBC_LINUX_SPECIFIC__
make_stub(eventfd)
#endif
--
1.7.10.4

View File

@ -0,0 +1,219 @@
From 342a3d861fde5651ee53486addbacddcec6a0a58 Mon Sep 17 00:00:00 2001
From: Natanael Copa <natanael.copa@gmail.com>
Date: Sat, 4 Aug 2012 19:32:45 +0200
Subject: [PATCH] pread/pwrite: backport fix
pread/pwrite syscalls has been renamed to pread64/pwrite in 2.6 kernel.
There was a fallback function using lseek for kernels who did not have
this syscall (pre 2.1.60). This is broken in many ways.
uclibc have been using the broken fallback due to they forgot to rename
pread syscall.
This got detected with git-1.7.11 which introduced threaded index-pack
which broke in similar ways a windows (msys).
This issue in uclibc have been reported upstream and fixed in git master
so this patch does not need to be upstreamed. It might be an idea to
backport it properly for 0.9.33 branch though.
Signed-off-by: Natanael Copa <natanael.copa@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/sysdeps/linux/common/pread_write.c | 143 ++++---------------------------
1 file changed, 19 insertions(+), 124 deletions(-)
diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c
index 88e6957..baf8691 100644
--- a/libc/sysdeps/linux/common/pread_write.c
+++ b/libc/sysdeps/linux/common/pread_write.c
@@ -17,6 +17,7 @@
#include <unistd.h>
#include <stdint.h>
#include <endian.h>
+#include <sysdep-cancel.h>
extern __typeof(pread) __libc_pread;
extern __typeof(pwrite) __libc_pwrite;
@@ -27,15 +28,17 @@ extern __typeof(pwrite64) __libc_pwrite64;
#include <bits/kernel_types.h>
-#ifdef __NR_pread
-
-# define __NR___syscall_pread __NR_pread
+# define __NR___syscall_pread __NR_pread64
static __inline__ _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
size_t, count, off_t, offset_hi, off_t, offset_lo)
ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
{
- return __syscall_pread(fd, buf, count, __LONG_LONG_PAIR(offset >> 31, offset));
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __syscall_pread(fd, buf, count, __LONG_LONG_PAIR(offset >> 31, offset));
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
+
}
weak_alias(__libc_pread,pread)
@@ -44,22 +47,24 @@ ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
{
uint32_t low = offset & 0xffffffff;
uint32_t high = offset >> 32;
- return __syscall_pread(fd, buf, count, __LONG_LONG_PAIR(high, low));
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __syscall_pread(fd, buf, count, __LONG_LONG_PAIR(high, low));
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
}
weak_alias(__libc_pread64,pread64)
# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pread */
-
-#ifdef __NR_pwrite
-
-# define __NR___syscall_pwrite __NR_pwrite
+# define __NR___syscall_pwrite __NR_pwrite64
static __inline__ _syscall5(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
size_t, count, off_t, offset_hi, off_t, offset_lo)
ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
{
- return __syscall_pwrite(fd, buf, count, __LONG_LONG_PAIR(offset >> 31, offset));
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __syscall_pwrite(fd, buf, count, __LONG_LONG_PAIR(offset >> 31, offset));
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
}
weak_alias(__libc_pwrite,pwrite)
@@ -68,120 +73,10 @@ ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
{
uint32_t low = offset & 0xffffffff;
uint32_t high = offset >> 32;
- return __syscall_pwrite(fd, buf, count, __LONG_LONG_PAIR(high, low));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pwrite */
-
-#if ! defined __NR_pread || ! defined __NR_pwrite
-
-static ssize_t __fake_pread_write(int fd, void *buf,
- size_t count, off_t offset, int do_pwrite)
-{
- int save_errno;
- ssize_t result;
- off_t old_offset;
-
- /* Since we must not change the file pointer preserve the
- * value so that we can restore it later. */
- if ((old_offset=lseek(fd, 0, SEEK_CUR)) == (off_t) -1)
- return -1;
-
- /* Set to wanted position. */
- if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
- return -1;
-
- if (do_pwrite == 1) {
- /* Write the data. */
- result = write(fd, buf, count);
- } else {
- /* Read the data. */
- result = read(fd, buf, count);
- }
-
- /* Now we have to restore the position. If this fails we
- * have to return this as an error. */
- save_errno = errno;
- if (lseek(fd, old_offset, SEEK_SET) == (off_t) -1)
- {
- if (result == -1)
- __set_errno(save_errno);
- return -1;
- }
- __set_errno(save_errno);
- return(result);
-}
-
-# ifdef __UCLIBC_HAS_LFS__
-
-static ssize_t __fake_pread_write64(int fd, void *buf,
- size_t count, off64_t offset, int do_pwrite)
-{
- int save_errno;
- ssize_t result;
- off64_t old_offset;
-
- /* Since we must not change the file pointer preserve the
- * value so that we can restore it later. */
- if ((old_offset=lseek64(fd, 0, SEEK_CUR)) == (off64_t) -1)
- return -1;
-
- /* Set to wanted position. */
- if (lseek64(fd, offset, SEEK_SET) == (off64_t) -1)
- return -1;
-
- if (do_pwrite == 1) {
- /* Write the data. */
- result = write(fd, buf, count);
- } else {
- /* Read the data. */
- result = read(fd, buf, count);
- }
-
- /* Now we have to restore the position. */
- save_errno = errno;
- if (lseek64(fd, old_offset, SEEK_SET) == (off64_t) -1) {
- if (result == -1)
- __set_errno (save_errno);
- return -1;
- }
- __set_errno (save_errno);
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __syscall_pwrite(fd, buf, count, __LONG_LONG_PAIR(high, low));
+ LIBC_CANCEL_RESET (oldtype);
return result;
}
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! defined __NR_pread || ! defined __NR_pwrite */
-
-#ifndef __NR_pread
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return __fake_pread_write(fd, buf, count, offset, 0);
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- return __fake_pread_write64(fd, buf, count, offset, 0);
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! __NR_pread */
-
-#ifndef __NR_pwrite
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
-{
- /* we won't actually be modifying the buffer,
- *just cast it to get rid of warnings */
- return __fake_pread_write(fd, (void*)buf, count, offset, 1);
-}
-weak_alias(__libc_pwrite,pwrite)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
-{
- return __fake_pread_write64(fd, (void*)buf, count, offset, 1);
-}
weak_alias(__libc_pwrite64,pwrite64)
# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! __NR_pwrite */
--
1.7.10.4

View File

@ -0,0 +1,61 @@
From 93b8ce8886e30986be31c1403b606b6367dc258a Mon Sep 17 00:00:00 2001
From: "Peter S. Mazinger" <ps.m@gmx.net>
Date: Tue, 26 Apr 2011 23:03:44 +0200
Subject: [PATCH] add posix_madvise.c
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
libc/sysdeps/linux/common/Makefile.in | 2 +-
libc/sysdeps/linux/common/posix_madvise.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
create mode 100644 libc/sysdeps/linux/common/posix_madvise.c
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index 3b5763c..b39082b 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -81,7 +81,7 @@ CSRC-$(UCLIBC_HAS_REALTIME) += clock_getres.c clock_gettime.c clock_settime.c \
sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c \
sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c sigqueue.c
# clock_getcpuclockid|clock_nanosleep|mq_timedreceive|mq_timedsend|posix_fadvise|posix_fallocate|posix_madvise|posix_memalign|posix_mem_offset|posix_spawnattr_destroy|posix_spawnattr_init|posix_spawnattr_getflags|posix_spawnattr_setflags|posix_spawnattr_getpgroup|posix_spawnattr_setpgroup|posix_spawnattr_getschedparam|posix_spawnattr_setschedparam|posix_spawnattr_getschedpolicy|posix_spawnattr_setschedpolicy|posix_spawnattr_getsigdefault|posix_spawnattr_setsigdefault|posix_spawnattr_getsigmask|posix_spawnattr_setsigmask|posix_spawnattr_init|posix_spawnattr_setflags|posix_spawnattr_setpgroup|posix_spawnattr_setschedparam|posix_spawnattr_setschedpolicy|posix_spawnattr_setsigdefault|posix_spawnattr_setsigmask|posix_spawn_file_actions_addclose|posix_spawn_file_actions_addopen|posix_spawn_file_actions_adddup2|posix_spawn_file_actions_addopen|posix_spawn_file_actions_destroy|posix_spawn_file_actions_init|posix_spawn_file_actions_init|posix_spawn|posix_spawnp|posix_spawnp|posix_typed_mem_get_info|pthread_mutex_timedlock|sem_timedwait
-CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c
+CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c
CSRC-$(UCLIBC_SUSV4_LEGACY) += utime.c
CSRC-$(UCLIBC_HAS_EPOLL) += epoll.c
CSRC-$(UCLIBC_HAS_XATTR) += xattr.c
diff --git a/libc/sysdeps/linux/common/posix_madvise.c b/libc/sysdeps/linux/common/posix_madvise.c
new file mode 100644
index 0000000..2f95bcb
--- /dev/null
+++ b/libc/sysdeps/linux/common/posix_madvise.c
@@ -0,0 +1,25 @@
+/* vi: set sw=4 ts=4: */
+/* Licensed under the LGPL v2.1, see the file LICENSE in this tarball. */
+
+#include <sys/mman.h>
+#include <sys/syscall.h>
+
+#if defined __NR_madvise && defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
+int posix_madvise(void *addr, size_t len, int advice)
+{
+ int result;
+ /* We have one problem: the kernel's MADV_DONTNEED does not
+ * correspond to POSIX's POSIX_MADV_DONTNEED. The former simply
+ * discards changes made to the memory without writing it back to
+ * disk, if this would be necessary. The POSIX behaviour does not
+ * allow this. There is no functionality mapping for the POSIX
+ * behaviour so far so we ignore that advice for now. */
+ if (advice == POSIX_MADV_DONTNEED)
+ return 0;
+
+ /* this part might use madvise function */
+ INTERNAL_SYSCALL_DECL (err);
+ result = INTERNAL_SYSCALL (madvise, err, 3, addr, len, advice);
+ return INTERNAL_SYSCALL_ERRNO (result, err);
+}
+#endif
--
1.7.10.4

View File

@ -0,0 +1,38 @@
From ffd9e147b120e9c2bf30ba4861860f1bc59362c5 Mon Sep 17 00:00:00 2001
From: Stas Sergeev <stsp@users.sourceforge.net>
Date: Thu, 14 Jun 2012 01:00:02 +0200
Subject: [PATCH] nptl: sh: fix race condition in lll_wait_tid
Make a local copy of the tid value to avoid a race condition,
as the value could have been changed to 0, thus using a pointer
it would have been passed to the lll_futex_wait modified.
Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
(cherry picked from commit 0dcc13bf7a61b1d0708e5dd103d5515e0ffec79a)
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
---
libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
index d10cd61..b83d863 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
@@ -396,9 +396,9 @@ extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden;
#define lll_wait_tid(tid) \
do { \
- __typeof (tid) *__tid = &(tid); \
- while (*__tid != 0) \
- lll_futex_wait (__tid, *__tid, LLL_SHARED); \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid, LLL_SHARED); \
} while (0)
extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)
--
1.7.10.4

View File

@ -0,0 +1,37 @@
From fec308fdfaf9f557ef5fb17c308c48259012b825 Mon Sep 17 00:00:00 2001
From: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Date: Thu, 12 Jul 2012 09:24:39 +0200
Subject: [PATCH] librt: re-add SIGCANCEL to the list of blocked signal in
helper thread
Indeed if the libpthread is before the libc in the library look up
the SIGCANCEL is removed from the list of the blocked signal by
sigfillset func, this can produce the handler not properly called.
This commit revert what Denys modified in commit
162cfaea20d807f0ae329efe39292a9b22593b41.
Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
(cherry picked from commit cb43f2afba0633400387fa7c55dda3396517f58a)
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
---
libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c
index 4319d8d..2681961 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c
@@ -175,7 +175,7 @@ __start_helper_thread (void)
sigset_t ss;
sigset_t oss;
sigfillset (&ss);
- /*__sigaddset (&ss, SIGCANCEL); - already done by sigfillset */
+ __sigaddset (&ss, SIGCANCEL);
INTERNAL_SYSCALL_DECL (err);
INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, &oss, _NSIG / 8);
--
1.7.10.4

View File

@ -0,0 +1,52 @@
From 2f09c67232cebca62f3afa4fc296c83aa813427c Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Sun, 18 Nov 2012 04:41:06 -0500
Subject: [PATCH] ldso: include dlfcn.h for RTLD_NODELETE
Building with NPTL enabled and shared library support disabled we hit:
In file included from libpthread/nptl/sysdeps/generic/dl-tls.c:30:0:
./ldso/include/dl-elf.h: In function '__dl_parse_dynamic_info':
./ldso/include/dl-elf.h:173:20: error: 'RTLD_NODELETE' undeclared (first use in this function)
./ldso/include/dl-elf.h:173:20: note: each undeclared identifier is reported only once for each function it appears in
make: *** [libpthread/nptl/sysdeps/generic/dl-tls.os] Error 1
A previous commit (f26c5f6952ce9bf8edec9c1571c47addb1bcc442) touched
on a similar issue, but added the include to the incorrect location.
Reported-by: Christophe Lyon <christophe.lyon@st.com> [arm nommu]
Reported-by: Daniel Beecham <daniel@lunix.se> [static x86_64]
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
---
ldso/include/dl-elf.h | 2 ++
ldso/include/ldso.h | 1 -
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/ldso/include/dl-elf.h b/ldso/include/dl-elf.h
index 29d1a00..e1185f7 100644
--- a/ldso/include/dl-elf.h
+++ b/ldso/include/dl-elf.h
@@ -18,6 +18,8 @@ struct elf_resolve;
struct r_scope_elem;
#include <dl-defs.h>
+#include <dlfcn.h>
+
#ifdef __LDSO_CACHE_SUPPORT__
extern int _dl_map_cache(void);
extern int _dl_unmap_cache(void);
diff --git a/ldso/include/ldso.h b/ldso/include/ldso.h
index 6f3b728..e250e30 100644
--- a/ldso/include/ldso.h
+++ b/ldso/include/ldso.h
@@ -42,7 +42,6 @@
#ifndef __ARCH_HAS_NO_SHARED__
#include <dl-syscall.h>
#include <dl-string.h>
-#include <dlfcn.h>
/* Now the ldso specific headers */
#include <dl-elf.h>
#ifdef __UCLIBC_HAS_TLS__
--
1.7.10.4

View File

@ -0,0 +1,34 @@
From 788d9ca73b7ed1262c83580ccc62fb3625e603c3 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Wed, 31 Oct 2012 20:41:50 +0100
Subject: [PATCH] include/elf.h: update for ELFOSABI_* changes.
ELFOSABI_GNU replaces ELFOSABI_LINUX, the latter is kept as a compatibility
alias, and ELFOSABI_HURD is removed. See the table on
<http://www.sco.com/developers/gabi/latest/ch4.eheader.html#osabi> for
reference.
Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
include/elf.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/elf.h b/include/elf.h
index ba3e804..470046e 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -148,8 +148,8 @@ typedef struct
#define ELFOSABI_SYSV 0 /* Alias. */
#define ELFOSABI_HPUX 1 /* HP-UX */
#define ELFOSABI_NETBSD 2 /* NetBSD. */
-#define ELFOSABI_LINUX 3 /* Linux. */
-#define ELFOSABI_HURD 4 /* GNU/Hurd */
+#define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */
+#define ELFOSABI_LINUX ELFOSABI_GNU /* Compatibility alias. */
#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
#define ELFOSABI_AIX 7 /* IBM AIX. */
#define ELFOSABI_IRIX 8 /* SGI Irix. */
--
1.7.10.4

View File

@ -0,0 +1,113 @@
From 2d0c3a704afe6bdc7be129e9f9217ec1369c1bc8 Mon Sep 17 00:00:00 2001
From: James Hogan <james.hogan@imgtec.com>
Date: Fri, 30 Nov 2012 10:08:13 +0000
Subject: [PATCH] update ptrace.h to latest from glibc
Update libc/sysdeps/linux/common/sys/ptrace.h to latest from glibc's
sysdeps/unix/sysv/linux/sys/ptrace.h.
This adds definitions for operations:
- PTRACE_GETREGSET
- PTRACE_SETREGSET
- PTRACE_SEIZE
- PTRACE_INTERRUPT
- PTRACE_LISTEN
And adds flags:
- PTRACE_SEIZE_DEVEL
And adds event codes:
- PTRACE_EVENT_SECCOMP
This is to allow access to the generic interface for accessing
architecture specific regsets using the corresponding NT_* types,
required for new Linux kernel architecture ports.
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/sysdeps/linux/common/sys/ptrace.h | 42 +++++++++++++++++++++++++++-----
1 file changed, 36 insertions(+), 6 deletions(-)
diff --git a/libc/sysdeps/linux/common/sys/ptrace.h b/libc/sysdeps/linux/common/sys/ptrace.h
index 08658f9..95b3fdf 100644
--- a/libc/sysdeps/linux/common/sys/ptrace.h
+++ b/libc/sysdeps/linux/common/sys/ptrace.h
@@ -1,5 +1,5 @@
/* `ptrace' debugger support interface. Linux version.
- Copyright (C) 1996-1999,2000,2006,2007 Free Software Foundation, Inc.
+ Copyright (C) 1996-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -125,13 +125,40 @@ enum __ptrace_request
#define PT_GETSIGINFO PTRACE_GETSIGINFO
/* Set new siginfo for process. */
- PTRACE_SETSIGINFO = 0x4203
+ PTRACE_SETSIGINFO = 0x4203,
#define PT_SETSIGINFO PTRACE_SETSIGINFO
+
+ /* Get register content. */
+ PTRACE_GETREGSET = 0x4204,
+#define PTRACE_GETREGSET PTRACE_GETREGSET
+
+ /* Set register content. */
+ PTRACE_SETREGSET = 0x4205,
+#define PTRACE_SETREGSET PTRACE_SETREGSET
+
+ /* Like PTRACE_ATTACH, but do not force tracee to trap and do not affect
+ signal or group stop state. */
+ PTRACE_SEIZE = 0x4206,
+#define PTRACE_SEIZE PTRACE_SEIZE
+
+ /* Trap seized tracee. */
+ PTRACE_INTERRUPT = 0x4207,
+#define PTRACE_INTERRUPT PTRACE_INTERRUPT
+
+ /* Wait for next group event. */
+ PTRACE_LISTEN = 0x4208
};
+/* Flag for PTRACE_LISTEN. */
+enum __ptrace_flags
+{
+ PTRACE_SEIZE_DEVEL = 0x80000000
+};
+
/* Options set using PTRACE_SETOPTIONS. */
-enum __ptrace_setoptions {
+enum __ptrace_setoptions
+{
PTRACE_O_TRACESYSGOOD = 0x00000001,
PTRACE_O_TRACEFORK = 0x00000002,
PTRACE_O_TRACEVFORK = 0x00000004,
@@ -139,17 +166,20 @@ enum __ptrace_setoptions {
PTRACE_O_TRACEEXEC = 0x00000010,
PTRACE_O_TRACEVFORKDONE = 0x00000020,
PTRACE_O_TRACEEXIT = 0x00000040,
- PTRACE_O_MASK = 0x0000007f
+ PTRACE_O_TRACESECCOMP = 0x00000080,
+ PTRACE_O_MASK = 0x000000ff
};
/* Wait extended result codes for the above trace options. */
-enum __ptrace_eventcodes {
+enum __ptrace_eventcodes
+{
PTRACE_EVENT_FORK = 1,
PTRACE_EVENT_VFORK = 2,
PTRACE_EVENT_CLONE = 3,
PTRACE_EVENT_EXEC = 4,
PTRACE_EVENT_VFORK_DONE = 5,
- PTRACE_EVENT_EXIT = 6
+ PTRACE_EVENT_EXIT = 6,
+ PTRAVE_EVENT_SECCOMP = 7
};
/* Perform process tracing functions. REQUEST is one of the values
--
1.7.10.4

View File

@ -0,0 +1,37 @@
From b7cc54be07412f02ff464aa47a8871ba7a910e3e Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Tue, 8 Jan 2013 10:14:22 +0100
Subject: [PATCH] pread/pwrite: fix for !threads
This is done properly via cancel.h on master.
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/sysdeps/linux/common/pread_write.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c
index baf8691..c142038 100644
--- a/libc/sysdeps/linux/common/pread_write.c
+++ b/libc/sysdeps/linux/common/pread_write.c
@@ -17,7 +17,16 @@
#include <unistd.h>
#include <stdint.h>
#include <endian.h>
-#include <sysdep-cancel.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include "sysdep-cancel.h"
+#else
+/* No multi-thread handling enabled. */
+#define SINGLE_THREAD_P (1)
+#define RTLD_SINGLE_THREAD_P (1)
+#define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */
+#define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */
+#define LIBC_CANCEL_HANDLED() /* Nothing. */
+#endif
extern __typeof(pread) __libc_pread;
extern __typeof(pwrite) __libc_pwrite;
--
1.7.10.4

View File

@ -0,0 +1,128 @@
From 5c797a24a7d6337b5e654079a8d815199b1e8364 Mon Sep 17 00:00:00 2001
From: Carmelo Amoroso <carmelo.amoroso@st.com>
Date: Thu, 2 Feb 2012 18:22:36 +0100
Subject: [PATCH] inet:rpc: fix authnone_marshal in multithreading context
This is a port of glibc's fix by Zack Weinberg as reported
in http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=142312,
and discussed in http://sourceware.org/ml/libc-alpha/2002-04/msg00069.html
and following.
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
---
libc/inet/rpc/auth_none.c | 59 +++++++++++++++++++++----------------------
libc/inet/rpc/rpc_private.h | 2 --
libc/inet/rpc/rpc_thread.c | 1 -
3 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/libc/inet/rpc/auth_none.c b/libc/inet/rpc/auth_none.c
index c48bbfe..d066f6b 100644
--- a/libc/inet/rpc/auth_none.c
+++ b/libc/inet/rpc/auth_none.c
@@ -66,49 +66,48 @@ struct authnone_private_s {
char marshalled_client[MAX_MARSHAL_SIZE];
u_int mcnt;
};
-#ifdef __UCLIBC_HAS_THREADS__
-#define authnone_private (*(struct authnone_private_s **)&RPC_THREAD_VARIABLE(authnone_private_s))
-#else
-static struct authnone_private_s *authnone_private;
-#endif
-AUTH *
-authnone_create (void)
+static struct authnone_private_s authnone_private;
+__libc_once_define(static, authnone_private_guard);
+
+static void authnone_create_once (void);
+
+static void
+authnone_create_once (void)
{
struct authnone_private_s *ap;
XDR xdr_stream;
XDR *xdrs;
- ap = (struct authnone_private_s *) authnone_private;
- if (ap == NULL)
- {
- ap = (struct authnone_private_s *) calloc (1, sizeof (*ap));
- if (ap == NULL)
- return NULL;
- authnone_private = ap;
- }
- if (!ap->mcnt)
- {
- ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
- ap->no_client.ah_ops = (struct auth_ops *)&ops;
- xdrs = &xdr_stream;
- xdrmem_create (xdrs, ap->marshalled_client, (u_int) MAX_MARSHAL_SIZE,
- XDR_ENCODE);
- (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_cred);
- (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_verf);
- ap->mcnt = XDR_GETPOS (xdrs);
- XDR_DESTROY (xdrs);
- }
- return (&ap->no_client);
+ ap = &authnone_private;
+
+ ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
+ ap->no_client.ah_ops = (struct auth_ops *) &ops;
+ xdrs = &xdr_stream;
+ xdrmem_create(xdrs, ap->marshalled_client,
+ (u_int) MAX_MARSHAL_SIZE, XDR_ENCODE);
+ (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
+ (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
+ ap->mcnt = XDR_GETPOS (xdrs);
+ XDR_DESTROY (xdrs);
+}
+
+AUTH *
+authnone_create (void)
+{
+ __libc_once (authnone_private_guard, authnone_create_once);
+ return &authnone_private.no_client;
}
libc_hidden_def(authnone_create)
static bool_t
-authnone_marshal (AUTH *client attribute_unused, XDR *xdrs)
+authnone_marshal (AUTH *client, XDR *xdrs)
{
struct authnone_private_s *ap;
- ap = authnone_private;
+ /* authnone_create returned authnone_private->no_client, which is
+ the first field of struct authnone_private_s. */
+ ap = (struct authnone_private_s *) client;
if (ap == NULL)
return FALSE;
return (*xdrs->x_ops->x_putbytes) (xdrs, ap->marshalled_client, ap->mcnt);
diff --git a/libc/inet/rpc/rpc_private.h b/libc/inet/rpc/rpc_private.h
index ede3ddf..e1214d2 100644
--- a/libc/inet/rpc/rpc_private.h
+++ b/libc/inet/rpc/rpc_private.h
@@ -18,8 +18,6 @@ struct rpc_thread_variables {
struct pollfd *svc_pollfd_s; /* Global, rpc_common.c */
int svc_max_pollfd_s; /* Global, rpc_common.c */
- void *authnone_private_s; /* auth_none.c */
-
void *clnt_perr_buf_s; /* clnt_perr.c */
void *clntraw_private_s; /* clnt_raw.c */
diff --git a/libc/inet/rpc/rpc_thread.c b/libc/inet/rpc/rpc_thread.c
index 71303b2..3367659 100644
--- a/libc/inet/rpc/rpc_thread.c
+++ b/libc/inet/rpc/rpc_thread.c
@@ -32,7 +32,6 @@ __rpc_thread_destroy (void)
__rpc_thread_svc_cleanup ();
__rpc_thread_clnt_cleanup ();
/*__rpc_thread_key_cleanup (); */
- free (tvp->authnone_private_s);
free (tvp->clnt_perr_buf_s);
free (tvp->clntraw_private_s);
free (tvp->svcraw_private_s);
--
1.7.10.4

View File

@ -0,0 +1,57 @@
From 6e2dbd7387bc2381e08aa85d6d33bb2d2d140843 Mon Sep 17 00:00:00 2001
From: Kevin Cernekee <cernekee@gmail.com>
Date: Tue, 5 Jun 2012 15:05:19 -0700
Subject: [PATCH] MIPS: Convert __syscall_error() callers to use $a0 for
argument
Some callers passed the first argument in $v0, while others used $a0.
Change the callers to use $a0 consistently.
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/sysdeps/linux/mips/vfork.S | 1 +
.../linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h | 2 +-
libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S | 1 +
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/libc/sysdeps/linux/mips/vfork.S b/libc/sysdeps/linux/mips/vfork.S
index b307447..00cc675 100644
--- a/libc/sysdeps/linux/mips/vfork.S
+++ b/libc/sysdeps/linux/mips/vfork.S
@@ -84,6 +84,7 @@ NESTED(__vfork,FRAMESZ,sp)
/* Something bad happened -- no child created. */
L(error):
+ move a0, v0
#ifdef __PIC__
PTR_LA t9, __syscall_error
RESTORE_GP64
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
index fc51774..4d2c405 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
@@ -31,7 +31,7 @@
# undef PSEUDO
# define PSEUDO(name, syscall_name, args) \
.align 2; \
- 99: \
+ 99: move a0, v0; \
PTR_LA t9,__syscall_error; \
/* manual cpreturn. */ \
REG_L gp, STKOFF_GP(sp); \
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S
index 7bbab5c..238d798 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S
@@ -80,6 +80,7 @@ NESTED(__vfork,FRAMESZ,sp)
/* Something bad happened -- no child created. */
L(error):
+ move a0, v0
#ifdef __PIC__
PTR_LA t9, __syscall_error
RESTORE_GP64
--
1.7.10.4

View File

@ -0,0 +1,63 @@
From c8f9e946bc2a0a42e84b5f97f272932de6485b54 Mon Sep 17 00:00:00 2001
From: Kevin Cernekee <cernekee@gmail.com>
Date: Tue, 5 Jun 2012 15:05:20 -0700
Subject: [PATCH] MIPS: Use $a0 instead of $v0 for __syscall_error() argument
$a0 is saved across _dl_runtime_resolve(); $v0 is not. Unfortunately,
__syscall_error() uses $v0 for its argument, not $a0 as is the MIPS ABI
standard. This means that if lazy binding was used for __syscall_error(),
the errno value in $v0 could get corrupted.
The problem can be easily seen in testcases where syscalls in librt fail;
when librt tries to call __syscall_error() in libc, the argument gets
lost and errno gets set to a bogus value:
# ./tst-mqueue1 ; echo $?
mq_receive on O_WRONLY mqd_t did not fail with EBADF: Unknown error 2004684208
1
# ./tst-mqueue2 ; echo $?
mq_timedreceive with too small msg_len did not fail with EMSGSIZE: Unknown error 1997360560
1
# ./tst-mqueue4 ; echo $?
mq_timedsend did not fail with ETIMEDOUT: Unknown error 2008747440
1
When _dl_runtime_resolve() was taken out of the equation, the same test
cases passed:
# LD_BIND_NOW=y ./tst-mqueue1 ; echo $?
0
# LD_BIND_NOW=y ./tst-mqueue2 ; echo $?
0
# LD_BIND_NOW=y ./tst-mqueue4 ; echo $?
0
Changing __syscall_error() to look at $a0 instead of $v0 fixed the
problem.
(Note that there is also a "__syscall_error.c" file which presumably
uses the standard C calling conventions, but I do not think it is used
on MIPS.)
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/sysdeps/linux/mips/syscall_error.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/sysdeps/linux/mips/syscall_error.S b/libc/sysdeps/linux/mips/syscall_error.S
index 51a8efa..0cc20da 100644
--- a/libc/sysdeps/linux/mips/syscall_error.S
+++ b/libc/sysdeps/linux/mips/syscall_error.S
@@ -43,7 +43,7 @@ ENTRY(__syscall_error)
#ifdef __PIC__
SAVE_GP(GPOFF)
#endif
- REG_S v0, V0OFF(sp)
+ REG_S a0, V0OFF(sp)
REG_S ra, RAOFF(sp)
/* Find our per-thread errno address */
--
1.7.10.4

View File

@ -0,0 +1,29 @@
From 753e4e4cd9177f25981e81f82cd9fe8612a95ba6 Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Fri, 15 Jun 2012 13:44:35 +0200
Subject: [PATCH] ldso: use .arm mode for resolver unconditionally
as per comment in the file.
Fixes runtime with __THUMB_INTERWORK__ enabled.
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
ldso/ldso/arm/resolve.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ldso/ldso/arm/resolve.S b/ldso/ldso/arm/resolve.S
index 08889d0..b0907f7 100644
--- a/ldso/ldso/arm/resolve.S
+++ b/ldso/ldso/arm/resolve.S
@@ -101,7 +101,7 @@
.text
.align 4 @ 16 byte boundary and there are 32 bytes below (arm case)
- #if !defined(__thumb__) || defined(__thumb2__)
+#if 1 /*(!defined(__thumb__) || defined __THUMB_INTERWORK__) || defined(__thumb2__)*/
.arm
.globl _dl_linux_resolve
.type _dl_linux_resolve,%function
--
1.7.10.4

View File

@ -0,0 +1,53 @@
From 8a2b550a510cf2a1a0989fc0a665a6a42c83efd4 Mon Sep 17 00:00:00 2001
From: "Peter S. Mazinger" <ps.m@gmx.net>
Date: Fri, 22 Apr 2011 00:52:22 +0200
Subject: [PATCH] make NPTL's getpid behave similar to the common one
make __getpid static
provide getppid alias if needed
remove unneeded libc_hidden_proto
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c b/libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c
index d4de3cd..d2b3384 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c
@@ -21,6 +21,10 @@
#include <tls.h>
#include <sysdep.h>
+#ifdef __NR_getxpid
+# undef __NR_getpid
+# define __NR_getpid __NR_getxpid
+#endif
#ifndef NOT_IN_libc
static inline __attribute__((always_inline)) pid_t really_getpid (pid_t oldval);
@@ -46,8 +50,7 @@ really_getpid (pid_t oldval)
}
#endif
-extern __typeof(getpid) __getpid;
-pid_t
+static pid_t
__getpid (void)
{
#ifdef NOT_IN_libc
@@ -60,6 +63,8 @@ __getpid (void)
#endif
return result;
}
-libc_hidden_proto(getpid)
weak_alias(__getpid, getpid)
libc_hidden_weak(getpid)
+#if !defined NOT_IN_libc && !defined __NR_getppid
+strong_alias(getpid,getppid)
+#endif
--
1.7.10.4

View File

@ -0,0 +1,33 @@
From 576983880a0ab5d27a4f530d2cef36239b617e78 Mon Sep 17 00:00:00 2001
From: Natanael Copa <natanael.copa@gmail.com>
Date: Thu, 5 Jul 2012 11:55:19 +0000
Subject: [PATCH] i386/bits/syscalls.h: allow immediate values as 6th syscall
arg
Allow use of immedate values as the 6th syscall argument. Otherwise we must
store the arg on memory. This gives gcc more options to optimize better.
This also works around an issue with posix_fallocate.
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/sysdeps/linux/i386/bits/syscalls.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/sysdeps/linux/i386/bits/syscalls.h b/libc/sysdeps/linux/i386/bits/syscalls.h
index 9fb4f35..566b5ac 100644
--- a/libc/sysdeps/linux/i386/bits/syscalls.h
+++ b/libc/sysdeps/linux/i386/bits/syscalls.h
@@ -136,7 +136,7 @@ __asm__ (
#define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
, "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)
#define ASMFMT_6(arg1, arg2, arg3, arg4, arg5, arg6) \
- , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5), "m" (arg6)
+ , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5), "g" (arg6)
#else /* !PIC */
--
1.7.10.4

View File

@ -0,0 +1,57 @@
From f5108ce0c0f72a285e4cb198426e477295c84517 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Tue, 8 Jan 2013 11:55:26 +0200
Subject: [PATCH] dl: fix dlsym lookups with RTLD_NEXT
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The current code for dlsym() when invoked with RTLD_NEXT lookup
searches for the module where it's being called from, and executes the
_dl_find_hash only for the next module in the chain. However, if the
looked symbol is not there, the rest of the modules are not checked.
Generally this is not a problem as symbols are merged for the parent
modules; so this affects only RTLD_NEXT.
This patch adds a loop iterating through all the following modules.
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Reviewed-by: Filippo ARCIDIACONO <filippo.arcidiacono@st.com>
Tested-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
ldso/libdl/libdl.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 51bcf7d..71ade1f 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -671,7 +671,7 @@ static void *do_dlsym(void *vhandle, const char *name, void *caller_address)
{
struct elf_resolve *tpnt, *tfrom;
struct dyn_elf *handle;
- ElfW(Addr) from;
+ ElfW(Addr) from = 0;
struct dyn_elf *rpnt;
void *ret;
struct symbol_ref sym_ref = { NULL, NULL };
@@ -729,7 +729,13 @@ static void *do_dlsym(void *vhandle, const char *name, void *caller_address)
tpnt = NULL;
if (handle == _dl_symbol_tables)
tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */
- ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref);
+
+ do {
+ ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref);
+ if (ret != NULL)
+ break;
+ handle = handle->next;
+ } while (from && handle);
#if defined(USE_TLS) && USE_TLS && defined SHARED
if (sym_ref.sym && (ELF_ST_TYPE(sym_ref.sym->st_info) == STT_TLS) && (sym_ref.tpnt)) {
--
1.7.10.4

View File

@ -0,0 +1,58 @@
From 3a732cacd650bd39d86ac13ba0f57eee0df82d5a Mon Sep 17 00:00:00 2001
From: Carmelo Amoroso <carmelo.amoroso@st.com>
Date: Wed, 14 Mar 2012 15:21:36 +0100
Subject: [PATCH] inet:rpc: fix build in !NPTL case
__libc_once is not available / needed when multithreading support
is not enabled, so authnone_create() calls authnone_create_once()
directly.
When LT.{old,new} is used instead of NPTL, it needs to explicitly
include <bits/libc-lock.h> to get __libc_once to be visible.
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
---
libc/inet/rpc/auth_none.c | 6 ++++++
libc/inet/rpc/rpc_private.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/libc/inet/rpc/auth_none.c b/libc/inet/rpc/auth_none.c
index d066f6b..70bee5b 100644
--- a/libc/inet/rpc/auth_none.c
+++ b/libc/inet/rpc/auth_none.c
@@ -68,7 +68,9 @@ struct authnone_private_s {
};
static struct authnone_private_s authnone_private;
+#ifdef __UCLIBC_HAS_THREADS__
__libc_once_define(static, authnone_private_guard);
+#endif
static void authnone_create_once (void);
@@ -95,7 +97,11 @@ authnone_create_once (void)
AUTH *
authnone_create (void)
{
+#ifdef __UCLIBC_HAS_THREADS__
__libc_once (authnone_private_guard, authnone_create_once);
+#else
+ authnone_create_once();
+#endif
return &authnone_private.no_client;
}
libc_hidden_def(authnone_create)
diff --git a/libc/inet/rpc/rpc_private.h b/libc/inet/rpc/rpc_private.h
index e1214d2..38ade1c 100644
--- a/libc/inet/rpc/rpc_private.h
+++ b/libc/inet/rpc/rpc_private.h
@@ -12,6 +12,7 @@ extern u_long _create_xid (void) attribute_hidden;
*/
#ifdef __UCLIBC_HAS_THREADS__
#include <pthread.h>
+#include <bits/libc-lock.h>
struct rpc_thread_variables {
fd_set svc_fdset_s; /* Global, rpc_common.c */
struct rpc_createerr rpc_createerr_s; /* Global, rpc_common.c */
--
1.7.10.4

View File

@ -0,0 +1,190 @@
From 050cd6971f92c2337bc506043dfcf1395dd5d622 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Sun, 6 May 2012 03:50:44 -0400
Subject: [PATCH] stdio: implement assignment-allocation "m" character
The latest POSIX spec introduces a "m" character to allocate buffers for
the user when using scanf type functions. This is like the old glibc "a"
flag, but now standardized. With packages starting to use these, we need
to implement it.
for example:
char *s;
sscanf("foo", "%ms", &s);
printf("%s\n", s);
free(s);
This will automatically allocate storage for "s", read in "foo" to it,
and then display it.
I'm not terribly familiar with the stdio layer, so this could be wrong.
But it seems to work for me.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
extra/Configs/Config.in | 13 ---------
libc/stdio/_scanf.c | 68 +++++++++++++++++++++++++++--------------------
2 files changed, 39 insertions(+), 42 deletions(-)
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index 1060729..c2f2fc7 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -1590,19 +1590,6 @@ config UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS
Most people will answer 9.
-
-config UCLIBC_HAS_SCANF_GLIBC_A_FLAG
- bool "Support glibc's 'a' flag for scanf string conversions (not implemented)"
- help
- NOTE!!! Currently Not Implemented!!! Just A Place Holder!! NOTE!!!
- NOTE!!! Conflicts with an ANSI/ISO C99 scanf flag!! NOTE!!!
-
- Answer Y to enable support for glibc's 'a' flag for the scanf string
- conversions '%s', '%[', '%ls', '%l[', and '%S'. This is used to
- auto-allocate sufficient memory to hold the data retrieved.
-
- Most people will answer N.
-
choice
prompt "Stdio buffer size"
default UCLIBC_HAS_STDIO_BUFSIZ_4096
diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c
index f38e72b..952853c 100644
--- a/libc/stdio/_scanf.c
+++ b/libc/stdio/_scanf.c
@@ -77,14 +77,6 @@
#include <bits/uClibc_fpmax.h>
#endif /* __UCLIBC_HAS_FLOATS__ */
-#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
-#ifdef L_vfscanf
-/* only emit this once */
-#warning Forcing undef of __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ until implemented!
-#endif
-#undef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
-#endif
-
#undef __STDIO_HAS_VSSCANF
#if defined(__STDIO_BUFFERS) || !defined(__UCLIBC_HAS_WCHAR__) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
#define __STDIO_HAS_VSSCANF 1
@@ -433,8 +425,9 @@ libc_hidden_def(vswscanf)
/* float layout 0123456789012345678901 repeat n for "l[" */
-#define SPEC_CHARS "npxXoudifFeEgGaACSncs["
-/* npxXoudif eEgG CS cs[ */
+#define SPEC_CHARS "npxXoudifFeEgGaACSnmcs["
+/* npxXoudif eEgG CS cs[ */
+/* NOTE: the 'm' flag must come before any convs that support it */
/* NOTE: Ordering is important! In particular, CONV_LEFTBRACKET
* must immediately precede CONV_c. */
@@ -444,7 +437,7 @@ enum {
CONV_p,
CONV_x, CONV_X, CONV_o, CONV_u, CONV_d, CONV_i,
CONV_f, CONV_F, CONV_e, CONV_E, CONV_g, CONV_G, CONV_a, CONV_A,
- CONV_C, CONV_S, CONV_LEFTBRACKET, CONV_c, CONV_s, CONV_leftbracket,
+ CONV_C, CONV_S, CONV_LEFTBRACKET, CONV_m, CONV_c, CONV_s, CONV_leftbracket,
CONV_percent, CONV_whitespace /* not in SPEC_* and no flags */
};
@@ -474,7 +467,7 @@ enum {
FLAG_SURPRESS = 0x10, /* MUST BE 1ST!! See DO_FLAGS. */
FLAG_THOUSANDS = 0x20,
FLAG_I18N = 0x40, /* only works for d, i, u */
- FLAG_MALLOC = 0x80, /* only works for s, S, and [ (and l[)*/
+ FLAG_MALLOC = 0x80, /* only works for c, s, S, and [ (and l[)*/
};
@@ -491,7 +484,7 @@ enum {
/* fFeEgGaA */ (0x0c|FLAG_SURPRESS|FLAG_THOUSANDS|FLAG_I18N), \
/* C */ ( 0|FLAG_SURPRESS), \
/* S and l[ */ ( 0|FLAG_SURPRESS|FLAG_MALLOC), \
- /* c */ (0x04|FLAG_SURPRESS), \
+ /* c */ (0x04|FLAG_SURPRESS|FLAG_MALLOC), \
/* s and [ */ (0x04|FLAG_SURPRESS|FLAG_MALLOC), \
}
@@ -904,17 +897,17 @@ int attribute_hidden __psfs_parse_spec(register psfs_t *psfs)
if (*psfs->fmt == *p) {
int p_m_spec_chars = p - spec_chars;
-#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
-#error implement gnu a flag
- if ((*p == 'a')
- && ((psfs->fmt[1] == '[') || ((psfs->fmt[1]|0x20) == 's'))
- ) { /* Assumes ascii for 's' and 'S' test. */
- psfs->flags |= FLAG_MALLOC;
+ if (*p == 'm' &&
+ (psfs->fmt[1] == '[' || psfs->fmt[1] == 'c' ||
+ /* Assumes ascii for 's' and 'S' test. */
+ (psfs->fmt[1] | 0x20) == 's'))
+ {
+ if (psfs->store)
+ psfs->flags |= FLAG_MALLOC;
++psfs->fmt;
++p;
- continue; /* The related conversions follow 'a'. */
+ continue; /* The related conversions follow 'm'. */
}
-#endif /* __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ */
for (p = spec_ranges; p_m_spec_chars > *p ; ++p) {}
if (((psfs->dataargtype >> 8) | psfs->flags)
@@ -1265,12 +1258,6 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
while (*wf && __isascii(*wf) && (b < buf + sizeof(buf) - 1)) {
*b++ = *wf++;
}
-#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
-#error this is wrong... we need to ched in __psfs_parse_spec instead since this checks last char in buffer and conversion my have stopped before it.
- if ((*b == 'a') && ((*wf == '[') || ((*wf|0x20) == 's'))) {
- goto DONE; /* Spec was excessively long. */
- }
-#endif /* __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ */
*b = 0;
if (b == buf) { /* Bad conversion specifier! */
goto DONE;
@@ -1390,13 +1377,36 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
}
if (psfs.conv_num == CONV_s) {
+ /* We might have to handle the allocation ourselves */
+ int len;
+ /* With 'm', we actually got a pointer to a pointer */
+ unsigned char **ptr = (void *)b;
+
+ i = 0;
+ if (psfs.flags & FLAG_MALLOC) {
+ len = 0;
+ b = NULL;
+ } else
+ len = -1;
+
/* Yes, believe it or not, a %s conversion can store nuls. */
while ((__scan_getc(&sc) >= 0) && !isspace(sc.cc)) {
zero_conversions = 0;
- *b = sc.cc;
- b += psfs.store;
+ if (i == len) {
+ /* Pick a size that won't trigger a lot of
+ * mallocs early on ... */
+ len += 256;
+ b = realloc(b, len + 1);
+ }
+ b[i] = sc.cc;
+ i += psfs.store;
fail = 0;
}
+
+ if (psfs.flags & FLAG_MALLOC)
+ *ptr = b;
+ /* The code below takes care of terminating NUL */
+ b += i;
} else {
#ifdef __UCLIBC_HAS_WCHAR__
assert((psfs.conv_num == CONV_LEFTBRACKET) || \
--
1.7.10.4

View File

@ -0,0 +1,35 @@
From 569d1423ac2b585b5cb38bee545b5e0ae2bd7f67 Mon Sep 17 00:00:00 2001
From: James Hogan <james.hogan@imgtec.com>
Date: Thu, 17 May 2012 12:42:54 +0100
Subject: [PATCH] mmap()->sys_mmap2: do unsigned shift of offset
Fix the implementation of mmap based on the mmap2 system call, to
construct pgoffset from offset with an unsigned shift rather than a
signed (off_t) shift. The mmap2 test in the testsuite catches this case
by mmap'ing with a large offset (with the sign bit set). The signed
shift repeats the sign bit making the page shift way out of range. This
is already fixed similarly in mmap64().
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
libc/sysdeps/linux/common/mmap.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libc/sysdeps/linux/common/mmap.c b/libc/sysdeps/linux/common/mmap.c
index 8995898..d53eabb 100644
--- a/libc/sysdeps/linux/common/mmap.c
+++ b/libc/sysdeps/linux/common/mmap.c
@@ -63,7 +63,8 @@ __ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offs
__set_errno(EINVAL);
return MAP_FAILED;
}
- return __syscall_mmap2(addr, len, prot, flags, fd, offset >> MMAP2_PAGE_SHIFT);
+ return __syscall_mmap2(addr, len, prot, flags,
+ fd, ((__u_long) offset >> MMAP2_PAGE_SHIFT));
}
libc_hidden_def(mmap)
--
1.7.10.4

View File

@ -0,0 +1,114 @@
From 923e6f201b1d792cf069ca7f13c3715f4e9c9353 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Wed, 30 May 2012 01:15:03 -0400
Subject: [PATCH] pread/pwrite: handle renamed syscalls in common/ppc/xtensa
code
Some arches got this fix, but many did not. So copy the ifdef logic to
the ones that missed it to fix behavior in linux-2.6+.
URL: https://bugs.busybox.net/show_bug.cgi?id=5258
Reported-by: David Laight <david.laight@aculab.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
libc/sysdeps/linux/common/pread_write.c | 12 +++++++++++-
libc/sysdeps/linux/powerpc/pread_write.c | 13 +++++++++++++
libc/sysdeps/linux/xtensa/pread_write.c | 14 ++++++++++++++
3 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c
index c142038..b13de66 100644
--- a/libc/sysdeps/linux/common/pread_write.c
+++ b/libc/sysdeps/linux/common/pread_write.c
@@ -35,6 +35,11 @@ extern __typeof(pread64) __libc_pread64;
extern __typeof(pwrite64) __libc_pwrite64;
#endif
+#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
+# undef __NR_pread
+# define __NR_pread __NR_pread64
+#endif
+
#include <bits/kernel_types.h>
# define __NR___syscall_pread __NR_pread64
@@ -64,7 +69,12 @@ ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
weak_alias(__libc_pread64,pread64)
# endif /* __UCLIBC_HAS_LFS__ */
-# define __NR___syscall_pwrite __NR_pwrite64
+#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
+# undef __NR_pwrite
+# define __NR_pwrite __NR_pwrite64
+#endif
+
+# define __NR___syscall_pwrite __NR_pwrite
static __inline__ _syscall5(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
size_t, count, off_t, offset_hi, off_t, offset_lo)
diff --git a/libc/sysdeps/linux/powerpc/pread_write.c b/libc/sysdeps/linux/powerpc/pread_write.c
index 7f988d3..23f256f 100644
--- a/libc/sysdeps/linux/powerpc/pread_write.c
+++ b/libc/sysdeps/linux/powerpc/pread_write.c
@@ -20,6 +20,13 @@
# define off64_t off_t
#endif
+#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
+# ifdef __NR_pread
+# error "__NR_pread and __NR_pread64 both defined???"
+# endif
+# define __NR_pread __NR_pread64
+#endif
+
#ifdef __NR_pread
extern __typeof(pread) __libc_pread;
# define __NR___syscall_pread __NR_pread
@@ -42,6 +49,12 @@ weak_alias(__libc_pread64,pread64)
# endif /* __UCLIBC_HAS_LFS__ */
#endif /* __NR_pread */
+#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
+# ifdef __NR_pwrite
+# error "__NR_pwrite and __NR_pwrite64 both defined???"
+# endif
+# define __NR_pwrite __NR_pwrite64
+#endif
#ifdef __NR_pwrite
extern __typeof(pwrite) __libc_pwrite;
diff --git a/libc/sysdeps/linux/xtensa/pread_write.c b/libc/sysdeps/linux/xtensa/pread_write.c
index 71ba22b..bcf7dee 100644
--- a/libc/sysdeps/linux/xtensa/pread_write.c
+++ b/libc/sysdeps/linux/xtensa/pread_write.c
@@ -27,6 +27,13 @@ extern __typeof(pwrite64) __libc_pwrite64;
#include <bits/kernel_types.h>
+#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
+# ifdef __NR_pread
+# error "__NR_pread and __NR_pread64 both defined???"
+# endif
+# define __NR_pread __NR_pread64
+#endif
+
#ifdef __NR_pread
# define __NR___syscall_pread __NR_pread
@@ -52,6 +59,13 @@ weak_alias(__libc_pread64,pread64)
#endif /* __NR_pread */
+#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
+# ifdef __NR_pwrite
+# error "__NR_pwrite and __NR_pwrite64 both defined???"
+# endif
+# define __NR_pwrite __NR_pwrite64
+#endif
+
#ifdef __NR_pwrite
# define __NR___syscall_pwrite __NR_pwrite
--
1.7.10.4

View File

@ -0,0 +1,78 @@
From 929b1a121c5ff0daa33b2107b4c1a68b650d93ee Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Mon, 30 Apr 2012 00:40:49 -0400
Subject: [PATCH] rpmatch: backport function
rpmatch will match ^[Yy] and ^[Nn] regardless of locale
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
include/stdlib.h | 2 +-
libc/stdlib/Makefile.in | 2 +-
libc/stdlib/rpmatch.c | 7 +++++++
libc/stdlib/stdlib.c | 8 ++++++++
4 files changed, 17 insertions(+), 2 deletions(-)
create mode 100644 libc/stdlib/rpmatch.c
diff --git a/include/stdlib.h b/include/stdlib.h
index 4aa1227..42b585c 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -851,7 +851,7 @@ __END_NAMESPACE_STD
#endif /* __UCLIBC_HAS_WCHAR__ */
-#if 0 /*def __USE_SVID*/
+#ifdef __USE_SVID
/* Determine whether the string value of RESPONSE matches the affirmation
or negative response expression as specified by the LC_MESSAGES category
in the program's current locale. Returns 1 if affirmative, 0 if
diff --git a/libc/stdlib/Makefile.in b/libc/stdlib/Makefile.in
index f219d21..e802441 100644
--- a/libc/stdlib/Makefile.in
+++ b/libc/stdlib/Makefile.in
@@ -33,7 +33,7 @@ endif
# multi source stdlib.c
CSRC-y += abs.c labs.c atoi.c atol.c strtol.c strtoul.c _stdlib_strto_l.c \
- qsort.c qsort_r.c bsearch.c \
+ qsort.c qsort_r.c bsearch.c rpmatch.c \
llabs.c atoll.c strtoll.c strtoull.c _stdlib_strto_ll.c
# (aliases) strtoq.o strtouq.o
CSRC-$(UCLIBC_HAS_FLOATS) += atof.c
diff --git a/libc/stdlib/rpmatch.c b/libc/stdlib/rpmatch.c
new file mode 100644
index 0000000..dce06b6
--- /dev/null
+++ b/libc/stdlib/rpmatch.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2012 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1+, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_rpmatch
+#include "stdlib.c"
diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c
index 9e8c347..de8f084 100644
--- a/libc/stdlib/stdlib.c
+++ b/libc/stdlib/stdlib.c
@@ -318,6 +318,14 @@ long long atoll(const char *nptr)
#endif
/**********************************************************************/
+#ifdef L_rpmatch
+int rpmatch (__const char *__response)
+{
+ return (__response[0] == 'y' || __response[0] == 'Y') ? 1 :
+ (__response[0] == 'n' || __response[0] == 'N') ? 0 : -1;
+}
+#endif
+/**********************************************************************/
#if defined(L_strtol) || defined(L_strtol_l)
libc_hidden_proto(__XL_NPP(strtol))
--
1.7.10.4

View File

@ -0,0 +1,189 @@
From 479f8407c4822d2b872afb8bb14e5ab596714744 Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Thu, 17 Jan 2013 22:44:00 +0100
Subject: [PATCH] statfs: support f_frsize
closes bugzilla #5834
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/misc/statfs/fstatfs64.c | 3 +++
libc/misc/statfs/internal_statvfs.c | 8 ++++++--
libc/misc/statfs/statfs64.c | 3 +++
test/.gitignore | 3 +++
test/misc/Makefile.in | 6 ++++++
test/misc/tst-statfs.c | 33 +++++++++++++++++++++++++++++++++
test/misc/tst-statvfs.c | 28 ++++++++++++++++++++++++++++
7 files changed, 82 insertions(+), 2 deletions(-)
create mode 100644 test/misc/tst-statfs.c
create mode 100644 test/misc/tst-statvfs.c
diff --git a/libc/misc/statfs/fstatfs64.c b/libc/misc/statfs/fstatfs64.c
index 27bb8d6..42df1ae 100644
--- a/libc/misc/statfs/fstatfs64.c
+++ b/libc/misc/statfs/fstatfs64.c
@@ -43,6 +43,9 @@ int fstatfs64 (int fd, struct statfs64 *buf)
buf->f_files = buf32.f_files;
buf->f_ffree = buf32.f_ffree;
buf->f_fsid = buf32.f_fsid;
+#ifdef _STATFS_F_FRSIZE
+ buf->f_frsize = buf32.f_frsize;
+#endif
buf->f_namelen = buf32.f_namelen;
memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
diff --git a/libc/misc/statfs/internal_statvfs.c b/libc/misc/statfs/internal_statvfs.c
index 6075e9c..c1862b5 100644
--- a/libc/misc/statfs/internal_statvfs.c
+++ b/libc/misc/statfs/internal_statvfs.c
@@ -19,8 +19,12 @@
/* Now fill in the fields we have information for. */
buf->f_bsize = fsbuf.f_bsize;
- /* Linux does not support f_frsize, so set it to the full block size. */
+#ifdef _STATFS_F_FRSIZE
+ buf->f_frsize = fsbuf.f_frsize;
+#else
+ /* No support for f_frsize so set it to the full block size. */
buf->f_frsize = fsbuf.f_bsize;
+#endif
buf->f_blocks = fsbuf.f_blocks;
buf->f_bfree = fsbuf.f_bfree;
buf->f_bavail = fsbuf.f_bavail;
@@ -39,7 +43,7 @@
buf->__f_unused = 0;
#endif
buf->f_namemax = fsbuf.f_namelen;
- memset (buf->__f_spare, '\0', 6 * sizeof (int));
+ memset (buf->__f_spare, '\0', sizeof(buf->__f_spare));
/* What remains to do is to fill the fields f_favail and f_flag. */
diff --git a/libc/misc/statfs/statfs64.c b/libc/misc/statfs/statfs64.c
index 0cc8595..35329bd 100644
--- a/libc/misc/statfs/statfs64.c
+++ b/libc/misc/statfs/statfs64.c
@@ -42,6 +42,9 @@ int statfs64 (const char *file, struct statfs64 *buf)
buf->f_ffree = buf32.f_ffree;
buf->f_fsid = buf32.f_fsid;
buf->f_namelen = buf32.f_namelen;
+#ifdef _STATFS_F_FRSIZE
+ buf->f_frsize = buf32.f_frsize;
+#endif
memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
return 0;
diff --git a/test/.gitignore b/test/.gitignore
index c892816..7234c48 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -148,6 +148,8 @@ misc/sem
misc/stdarg
misc/tst-scandir
misc/tst-seekdir
+misc/tst-statfs
+misc/tst-statvfs
misc/tst-utmp
mmap/mmap
mmap/mmap2
@@ -254,6 +256,7 @@ stdio/64bit
stdio/fclose-loop
stdlib/ptytest
stdlib/qsort
+stdlib/testarc4random
stdlib/testatexit
stdlib/test-canon
stdlib/test-canon2
diff --git a/test/misc/Makefile.in b/test/misc/Makefile.in
index 2263211..9b74d22 100644
--- a/test/misc/Makefile.in
+++ b/test/misc/Makefile.in
@@ -9,6 +9,12 @@ CFLAGS_dirent64 := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS
DODIFF_dirent := 1
DODIFF_dirent64 := 1
+DODIFF_tst-statfs := 1
+DODIFF_tst-statvfs := 1
OPTS_bug-glob1 := $(PWD)
OPTS_tst-fnmatch := < tst-fnmatch.input
+
+MNTENTS = $(shell mount | while read dev on mp rest; do echo $$mp; done)
+OPTS_tst-statfs := $(MNTENTS)
+OPTS_tst-statvfs := $(MNTENTS)
diff --git a/test/misc/tst-statfs.c b/test/misc/tst-statfs.c
new file mode 100644
index 0000000..44ab3aa
--- /dev/null
+++ b/test/misc/tst-statfs.c
@@ -0,0 +1,33 @@
+#define _FILE_OFFSET_BITS 64
+
+#include <sys/vfs.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(int argc, char* argv[])
+{
+ struct statfs s;
+ int ret = 0, i;
+
+ for (i = 1; i < argc; i++) {
+ if (statfs(argv[i], &s) != 0) {
+ fprintf(stderr, "%s: %s: statfs failed. %s\n",
+ *argv, argv[i], strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ ++ret;
+ printf("statfs %s:\n\tblocks=%lld\n\tblkfree=%lld\n\tbsize=%d\n",
+ argv[i], s.f_blocks, s.f_bfree, s.f_bsize);
+#ifdef _STATFS_F_FRSIZE
+ printf("\tfrsize=%lld\n", s.f_frsize);
+#elif defined __mips__
+ printf("\tfrsize=mips, unsupported?\n");
+#else
+# error no _STATFS_F_FRSIZE
+#endif
+ }
+ exit(ret ? EXIT_SUCCESS : EXIT_FAILURE);
+}
diff --git a/test/misc/tst-statvfs.c b/test/misc/tst-statvfs.c
new file mode 100644
index 0000000..c1e8fde
--- /dev/null
+++ b/test/misc/tst-statvfs.c
@@ -0,0 +1,28 @@
+#define _FILE_OFFSET_BITS 64
+
+#include <sys/statvfs.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(int argc, char* argv[])
+{
+ struct statvfs s;
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ if (statvfs(argv[i], &s) != 0) {
+ fprintf(stderr, "%s: %s: statvfs failed. %s\n",
+ *argv, argv[i], strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ printf("statvfs %s:\n\tblocks=%lld\n\tblkfree=%lld\n\tbsize=%d\n",
+ argv[i], s.f_blocks, s.f_bfree, s.f_bsize);
+#if 1 // def _STATFS_F_FRSIZE
+ printf("\tfrsize=%lld\n", s.f_frsize);
+#endif
+ }
+ exit(EXIT_SUCCESS);
+}
--
1.7.10.4

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,91 @@
From 641a5356a021f90ee922229bd8e1aa6eafe152bc Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Fri, 18 Jan 2013 11:12:49 +0100
Subject: [PATCH] mount.h: update
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
include/sys/mount.h | 45 +++++++++++++++++++++++++++++++++++----------
1 file changed, 35 insertions(+), 10 deletions(-)
diff --git a/include/sys/mount.h b/include/sys/mount.h
index 57d440f..9eecc5a 100644
--- a/include/sys/mount.h
+++ b/include/sys/mount.h
@@ -1,5 +1,5 @@
/* Header file for mounting/unmount Linux filesystems.
- Copyright (C) 1996,1997,1998,1999,2000,2004 Free Software Foundation, Inc.
+ Copyright (C) 1996-2000, 2004, 2010, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -47,23 +47,46 @@ enum
#define MS_REMOUNT MS_REMOUNT
MS_MANDLOCK = 64, /* Allow mandatory locks on an FS. */
#define MS_MANDLOCK MS_MANDLOCK
- S_WRITE = 128, /* Write on file/directory/symlink. */
-#define S_WRITE S_WRITE
- S_APPEND = 256, /* Append-only file. */
-#define S_APPEND S_APPEND
- S_IMMUTABLE = 512, /* Immutable file. */
-#define S_IMMUTABLE S_IMMUTABLE
+ MS_DIRSYNC = 128, /* Directory modifications are synchronous. */
+#define MS_DIRSYNC MS_DIRSYNC
MS_NOATIME = 1024, /* Do not update access times. */
#define MS_NOATIME MS_NOATIME
MS_NODIRATIME = 2048, /* Do not update directory access times. */
#define MS_NODIRATIME MS_NODIRATIME
MS_BIND = 4096, /* Bind directory at different place. */
#define MS_BIND MS_BIND
+ MS_MOVE = 8192,
+#define MS_MOVE MS_MOVE
+ MS_REC = 16384,
+#define MS_REC MS_REC
+ MS_SILENT = 32768,
+#define MS_SILENT MS_SILENT
+ MS_POSIXACL = 1 << 16, /* VFS does not apply the umask. */
+#define MS_POSIXACL MS_POSIXACL
+ MS_UNBINDABLE = 1 << 17, /* Change to unbindable. */
+#define MS_UNBINDABLE MS_UNBINDABLE
+ MS_PRIVATE = 1 << 18, /* Change to private. */
+#define MS_PRIVATE MS_PRIVATE
+ MS_SLAVE = 1 << 19, /* Change to slave. */
+#define MS_SLAVE MS_SLAVE
+ MS_SHARED = 1 << 20, /* Change to shared. */
+#define MS_SHARED MS_SHARED
+ MS_RELATIME = 1 << 21, /* Update atime relative to mtime/ctime. */
+#define MS_RELATIME MS_RELATIME
+ MS_KERNMOUNT = 1 << 22, /* This is a kern_mount call. */
+#define MS_KERNMOUNT MS_KERNMOUNT
+ MS_I_VERSION = 1 << 23, /* Update inode I_version field. */
+#define MS_I_VERSION MS_I_VERSION
+ MS_STRICTATIME = 1 << 24, /* Always perform atime updates. */
+#define MS_STRICTATIME MS_STRICTATIME
+ MS_ACTIVE = 1 << 30,
+#define MS_ACTIVE MS_ACTIVE
+ MS_NOUSER = 1 << 31
+#define MS_NOUSER MS_NOUSER
};
/* Flags that can be altered by MS_REMOUNT */
-#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME \
- |MS_NODIRATIME)
+#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION)
/* Magic mount flag number. Has to be or-ed to the flag values. */
@@ -100,8 +123,10 @@ enum
#define MNT_FORCE MNT_FORCE
MNT_DETACH = 2, /* Just detach from the tree. */
#define MNT_DETACH MNT_DETACH
- MNT_EXPIRE = 4 /* Mark for expiry. */
+ MNT_EXPIRE = 4, /* Mark for expiry. */
#define MNT_EXPIRE MNT_EXPIRE
+ UMOUNT_NOFOLLOW = 8 /* Don't follow symlink on umount. */
+#define UMOUNT_NOFOLLOW UMOUNT_NOFOLLOW
};
--
1.7.10.4

View File

@ -0,0 +1,38 @@
From 29411db7b6cf872e73b5560c46dd941f91e704cd Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Sat, 26 Jan 2013 14:13:12 -0500
Subject: [PATCH] buildsys: gen_bits_syscall_h: do not leave undefined SYS_xxx
around
If we end up doing '#undef __NR_xxx', we don't want to leave the
corresponding SYS_xxx symbol defined. So undef it too.
For example, with the ARM EABI layer, we have a bunch of legacy
syscalls that we define early on and then later undefine (such
as __NR_utime). But we left SYS_utime defined so code that tests
for that define before using it would be broken (since it'd be
defined to a non-existent symbol).
URL: https://bugs.gentoo.org/425006
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
extra/scripts/gen_bits_syscall_h.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/extra/scripts/gen_bits_syscall_h.sh b/extra/scripts/gen_bits_syscall_h.sh
index f6353ba..fd141f0 100755
--- a/extra/scripts/gen_bits_syscall_h.sh
+++ b/extra/scripts/gen_bits_syscall_h.sh
@@ -40,7 +40,8 @@ $CC -E $INCLUDE_OPTS - |
sed -ne 's/^UCLIBC\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\) *\(.*\)/#undef \1\2\
#define \1\2 \3\
#define SYS_\2 \1\2/gp' \
- -e 's/^UNDEFUCLIBC\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\).*/#undef \1\2/gp'
+ -e 's/^UNDEFUCLIBC\(__ARM_NR_\|__NR_\)\([A-Za-z0-9_]*\).*/#undef \1\2\
+#undef SYS_\2/gp'
echo ;
echo "#endif" ;
)
--
1.7.10.4

View File

@ -0,0 +1,117 @@
From 4b7f3716b8678c9ff423445f41e6ffb47fd295cd Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Sat, 26 Jan 2013 17:40:24 -0500
Subject: [PATCH] libc/sysdeps: sync bits/in.h with glibc
URL: https://bugs.busybox.net/show_bug.cgi?id=5888
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
libc/sysdeps/linux/common/bits/in.h | 61 +++++++++++++++++++++++------------
1 file changed, 41 insertions(+), 20 deletions(-)
diff --git a/libc/sysdeps/linux/common/bits/in.h b/libc/sysdeps/linux/common/bits/in.h
index 1f2b817..d9c5e2b 100644
--- a/libc/sysdeps/linux/common/bits/in.h
+++ b/libc/sysdeps/linux/common/bits/in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1999, 2000, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -43,31 +43,49 @@
#define IP_ADD_SOURCE_MEMBERSHIP 39 /* ip_mreq_source: join source group */
#define IP_DROP_SOURCE_MEMBERSHIP 40 /* ip_mreq_source: leave source group */
#define IP_MSFILTER 41
-#define MCAST_JOIN_GROUP 42 /* group_req: join any-source group */
-#define MCAST_BLOCK_SOURCE 43 /* group_source_req: block from given group */
-#define MCAST_UNBLOCK_SOURCE 44 /* group_source_req: unblock from given group*/
-#define MCAST_LEAVE_GROUP 45 /* group_req: leave any-source group */
-#define MCAST_JOIN_SOURCE_GROUP 46 /* group_source_req: join source-spec gr */
-#define MCAST_LEAVE_SOURCE_GROUP 47 /* group_source_req: leave source-spec gr*/
-#define MCAST_MSFILTER 48
-
-#define MCAST_EXCLUDE 0
-#define MCAST_INCLUDE 1
-
-#define IP_ROUTER_ALERT 5 /* bool */
-#define IP_PKTINFO 8 /* bool */
-#define IP_PKTOPTIONS 9
-#define IP_PMTUDISC 10 /* obsolete name? */
-#define IP_MTU_DISCOVER 10 /* int; see below */
-#define IP_RECVERR 11 /* bool */
-#define IP_RECVTTL 12 /* bool */
-#define IP_RECVTOS 13 /* bool */
+#if defined __USE_MISC || defined __USE_GNU
+# define MCAST_JOIN_GROUP 42 /* group_req: join any-source group */
+# define MCAST_BLOCK_SOURCE 43 /* group_source_req: block from given group */
+# define MCAST_UNBLOCK_SOURCE 44 /* group_source_req: unblock from given group*/
+# define MCAST_LEAVE_GROUP 45 /* group_req: leave any-source group */
+# define MCAST_JOIN_SOURCE_GROUP 46 /* group_source_req: join source-spec gr */
+# define MCAST_LEAVE_SOURCE_GROUP 47 /* group_source_req: leave source-spec gr*/
+# define MCAST_MSFILTER 48
+# define IP_MULTICAST_ALL 49
+# define IP_UNICAST_IF 50
+
+# define MCAST_EXCLUDE 0
+# define MCAST_INCLUDE 1
+#endif
+
+#define IP_ROUTER_ALERT 5 /* bool */
+#define IP_PKTINFO 8 /* bool */
+#define IP_PKTOPTIONS 9
+#define IP_PMTUDISC 10 /* obsolete name? */
+#define IP_MTU_DISCOVER 10 /* int; see below */
+#define IP_RECVERR 11 /* bool */
+#define IP_RECVTTL 12 /* bool */
+#define IP_RECVTOS 13 /* bool */
+#define IP_MTU 14 /* int */
+#define IP_FREEBIND 15
+#define IP_IPSEC_POLICY 16
+#define IP_XFRM_POLICY 17
+#define IP_PASSSEC 18
+#define IP_TRANSPARENT 19
+#define IP_MULTICAST_ALL 49 /* bool */
+
+/* TProxy original addresses */
+#define IP_ORIGDSTADDR 20
+#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR
+
+#define IP_MINTTL 21
/* IP_MTU_DISCOVER arguments. */
#define IP_PMTUDISC_DONT 0 /* Never send DF frames. */
#define IP_PMTUDISC_WANT 1 /* Use per route hints. */
#define IP_PMTUDISC_DO 2 /* Always DF. */
+#define IP_PMTUDISC_PROBE 3 /* Ignore dst pmtu. */
/* To select the IP level. */
#define SOL_IP 0
@@ -76,6 +94,7 @@
#define IP_DEFAULT_MULTICAST_LOOP 1
#define IP_MAX_MEMBERSHIPS 20
+#if defined __USE_MISC || defined __USE_GNU
/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS.
The `ip_dst' field is used for the first-hop gateway when using a
source route (this gets put into the header proper). */
@@ -100,6 +119,7 @@ struct in_pktinfo
struct in_addr ipi_spec_dst; /* Routing destination address */
struct in_addr ipi_addr; /* Header destination address */
};
+#endif
#ifdef __UCLIBC_HAS_IPV6__
/* Options for use with `getsockopt' and `setsockopt' at the IPv6 level.
@@ -159,6 +179,7 @@ struct in_pktinfo
#define IPV6_PMTUDISC_DONT 0 /* Never send DF frames. */
#define IPV6_PMTUDISC_WANT 1 /* Use per route hints. */
#define IPV6_PMTUDISC_DO 2 /* Always DF. */
+#define IPV6_PMTUDISC_PROBE 3 /* Ignore dst pmtu. */
/* Socket level values for IPv6. */
#define SOL_IPV6 41
--
1.7.10.4

View File

@ -0,0 +1,43 @@
From 893d4fb45bb0811bcc939054e60e37a47a1786c5 Mon Sep 17 00:00:00 2001
From: Ronald Wahl <ronald.wahl@raritan.com>
Date: Mon, 4 Feb 2013 14:51:46 +0100
Subject: [PATCH] libc: atexit: reuse free slots at the end of exit functions
table
Continuosly dlopen and dlclose of shared object will cause a memory leak
in atexit function. This fix reuse free slots at the end of the list.
For further detail see https://bugs.busybox.net/show_bug.cgi?id=2455
Signed-off-by: Ronald Wahl <ronald.wahl@raritan.com>
Tested-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
(cherry picked from commit 389cd96704f21549cafc0b5bdcd0ef762b98bc08)
---
libc/stdlib/_atexit.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libc/stdlib/_atexit.c b/libc/stdlib/_atexit.c
index 48b97ff..0af8c57 100644
--- a/libc/stdlib/_atexit.c
+++ b/libc/stdlib/_atexit.c
@@ -240,6 +240,16 @@ struct exit_function attribute_hidden *__new_exitfn(void)
__UCLIBC_MUTEX_LOCK(__atexit_lock);
+ /*
+ * Reuse free slots at the end of the list.
+ * This avoids eating memory when dlopen and dlclose modules multiple times.
+ */
+ while (__exit_count > 0) {
+ if (__exit_function_table[__exit_count-1].type == ef_free) {
+ --__exit_count;
+ } else break;
+ }
+
#ifdef __UCLIBC_DYNAMIC_ATEXIT__
/* If we are out of function table slots, make some more */
if (__exit_slots < __exit_count+1) {
--
1.7.10.4

View File

@ -0,0 +1,200 @@
From fb1b8fc191bffd6b3bc6db6bfa824b2d41e18485 Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Tue, 5 Feb 2013 19:13:06 +0100
Subject: [PATCH] mman: rename MAP_UNINITIALIZE to MAP_UNINITIALIZED
The name was changed to include a trailing 'D' when it went into the
kernel.
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
ldso/ldso/dl-elf.c | 2 +-
ldso/ldso/ldso.c | 2 +-
libc/stdlib/malloc-simple/alloc.c | 4 ++--
libc/stdlib/malloc-standard/malloc.h | 6 +++---
libc/stdlib/malloc/malloc.c | 2 +-
libc/sysdeps/linux/alpha/bits/mman.h | 2 +-
libc/sysdeps/linux/common/bits/mman-common.h | 2 +-
libc/sysdeps/linux/hppa/bits/mman.h | 2 +-
libc/sysdeps/linux/mips/bits/mman.h | 2 +-
libc/sysdeps/linux/powerpc/bits/mman.h | 2 +-
libc/sysdeps/linux/sparc/bits/mman.h | 2 +-
libc/sysdeps/linux/xtensa/bits/mman.h | 2 +-
12 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 9e2a12c..0e6d2cd 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -500,7 +500,7 @@ struct elf_resolve *_dl_load_elf_shared_library(unsigned rflags,
return NULL;
}
header = _dl_mmap((void *) 0, _dl_pagesize, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZE, -1, 0);
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZED, -1, 0);
if (_dl_mmap_check_error(header)) {
_dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname);
_dl_internal_error_number = LD_ERROR_MMAP_FAILED;
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 85d27a3..df46e24 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -245,7 +245,7 @@ void *_dl_malloc(size_t size)
_dl_debug_early("mmapping more memory\n");
_dl_mmap_zero = _dl_malloc_addr = _dl_mmap((void *) 0, rounded_size,
- PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZE, -1, 0);
+ PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZED, -1, 0);
if (_dl_mmap_check_error(_dl_mmap_zero)) {
_dl_dprintf(_dl_debug_file, "%s: mmap of a spare page failed!\n", _dl_progname);
_dl_exit(20);
diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c
index 914c89d..ec49781 100644
--- a/libc/stdlib/malloc-simple/alloc.c
+++ b/libc/stdlib/malloc-simple/alloc.c
@@ -36,7 +36,7 @@ void *malloc(size_t size)
#ifdef __ARCH_USE_MMU__
# define MMAP_FLAGS MAP_PRIVATE | MAP_ANONYMOUS
#else
-# define MMAP_FLAGS MAP_SHARED | MAP_ANONYMOUS | MAP_UNINITIALIZE
+# define MMAP_FLAGS MAP_SHARED | MAP_ANONYMOUS | MAP_UNINITIALIZED
#endif
result = mmap((void *) 0, size + sizeof(size_t), PROT_READ | PROT_WRITE,
@@ -63,7 +63,7 @@ void * calloc(size_t nmemb, size_t lsize)
result = malloc(size);
#ifndef __ARCH_USE_MMU__
- /* mmap'd with MAP_UNINITIALIZE, we have to blank memory ourselves */
+ /* mmap'd with MAP_UNINITIALIZED, we have to blank memory ourselves */
if (result != NULL) {
memset(result, 0, size);
}
diff --git a/libc/stdlib/malloc-standard/malloc.h b/libc/stdlib/malloc-standard/malloc.h
index 73d4b12..e6ae544 100644
--- a/libc/stdlib/malloc-standard/malloc.h
+++ b/libc/stdlib/malloc-standard/malloc.h
@@ -349,13 +349,13 @@ __UCLIBC_MUTEX_EXTERN(__malloc_lock);
#endif
#ifdef __ARCH_USE_MMU__
-# define _MAP_UNINITIALIZE 0
+# define _MAP_UNINITIALIZED 0
#else
-# define _MAP_UNINITIALIZE MAP_UNINITIALIZE
+# define _MAP_UNINITIALIZED MAP_UNINITIALIZED
#endif
#define MMAP(addr, size, prot) \
- (mmap((addr), (size), (prot), MAP_PRIVATE|MAP_ANONYMOUS|_MAP_UNINITIALIZE, 0, 0))
+ (mmap((addr), (size), (prot), MAP_PRIVATE|MAP_ANONYMOUS|_MAP_UNINITIALIZED, 0, 0))
/* ----------------------- Chunk representations ----------------------- */
diff --git a/libc/stdlib/malloc/malloc.c b/libc/stdlib/malloc/malloc.c
index d58a7d0..2b47077 100644
--- a/libc/stdlib/malloc/malloc.c
+++ b/libc/stdlib/malloc/malloc.c
@@ -124,7 +124,7 @@ __malloc_from_heap (size_t size, struct heap_free_area **heap
MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
#else
block = mmap ((void *)0, block_size, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_ANONYMOUS | MAP_UNINITIALIZE, 0, 0);
+ MAP_SHARED | MAP_ANONYMOUS | MAP_UNINITIALIZED, 0, 0);
#endif
#endif /* MALLOC_USE_SBRK */
diff --git a/libc/sysdeps/linux/alpha/bits/mman.h b/libc/sysdeps/linux/alpha/bits/mman.h
index cafad4a..31327ed 100644
--- a/libc/sysdeps/linux/alpha/bits/mman.h
+++ b/libc/sysdeps/linux/alpha/bits/mman.h
@@ -71,7 +71,7 @@
# define MAP_NORESERVE 0x10000 /* Don't check for reservations. */
# define MAP_POPULATE 0x20000 /* Populate (prefault) pagetables. */
# define MAP_NONBLOCK 0x40000 /* Do not block on IO. */
-# define MAP_UNINITIALIZE 0x4000000 /* For anonymous mmap, memory could
+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
be uninitialized. */
#endif
diff --git a/libc/sysdeps/linux/common/bits/mman-common.h b/libc/sysdeps/linux/common/bits/mman-common.h
index f00cb1a..c733a87 100644
--- a/libc/sysdeps/linux/common/bits/mman-common.h
+++ b/libc/sysdeps/linux/common/bits/mman-common.h
@@ -64,7 +64,7 @@
# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
# define MAP_STACK 0x20000 /* Allocation is for a stack. */
-# define MAP_UNINITIALIZE 0x4000000 /* For anonymous mmap, memory could
+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
be uninitialized. */
#endif
diff --git a/libc/sysdeps/linux/hppa/bits/mman.h b/libc/sysdeps/linux/hppa/bits/mman.h
index 7f9bf4e..fc73c91 100644
--- a/libc/sysdeps/linux/hppa/bits/mman.h
+++ b/libc/sysdeps/linux/hppa/bits/mman.h
@@ -45,7 +45,7 @@
#define MAP_GROWSDOWN 0x8000 /* stack-like segment */
#define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
#define MAP_NONBLOCK 0x20000 /* do not block on IO */
-#define MAP_UNINITIALIZE 0x4000000 /* For anonymous mmap, memory could
+#define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
be uninitialized. */
#define MS_SYNC 1 /* synchronous memory sync */
diff --git a/libc/sysdeps/linux/mips/bits/mman.h b/libc/sysdeps/linux/mips/bits/mman.h
index c480be4..f9a8128 100644
--- a/libc/sysdeps/linux/mips/bits/mman.h
+++ b/libc/sysdeps/linux/mips/bits/mman.h
@@ -66,7 +66,7 @@
# define MAP_LOCKED 0x8000 /* pages are locked */
# define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
# define MAP_NONBLOCK 0x20000 /* do not block on IO */
-# define MAP_UNINITIALIZE 0x4000000 /* For anonymous mmap, memory could
+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
be uninitialized. */
#endif
diff --git a/libc/sysdeps/linux/powerpc/bits/mman.h b/libc/sysdeps/linux/powerpc/bits/mman.h
index 2d234c5..b766cb6 100644
--- a/libc/sysdeps/linux/powerpc/bits/mman.h
+++ b/libc/sysdeps/linux/powerpc/bits/mman.h
@@ -63,7 +63,7 @@
# define MAP_NORESERVE 0x00040 /* Don't check for reservations. */
# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
-# define MAP_UNINITIALIZE 0x4000000 /* For anonymous mmap, memory could
+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
be uninitialized. */
#endif
diff --git a/libc/sysdeps/linux/sparc/bits/mman.h b/libc/sysdeps/linux/sparc/bits/mman.h
index 74921e4..2463e7d 100644
--- a/libc/sysdeps/linux/sparc/bits/mman.h
+++ b/libc/sysdeps/linux/sparc/bits/mman.h
@@ -65,7 +65,7 @@
# define _MAP_NEW 0x80000000 /* Binary compatibility with SunOS. */
# define MAP_POPULATE 0x8000 /* Populate (prefault) pagetables. */
# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
-# define MAP_UNINITIALIZE 0x4000000 /* For anonymous mmap, memory could
+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
be uninitialized. */
#endif
diff --git a/libc/sysdeps/linux/xtensa/bits/mman.h b/libc/sysdeps/linux/xtensa/bits/mman.h
index fead3ac..dfd9e4c 100644
--- a/libc/sysdeps/linux/xtensa/bits/mman.h
+++ b/libc/sysdeps/linux/xtensa/bits/mman.h
@@ -64,7 +64,7 @@
# define MAP_NORESERVE 0x0400 /* Don't check for reservations. */
# define MAP_POPULATE 0x10000 /* Populate (prefault) pagetables. */
# define MAP_NONBLOCK 0x20000 /* Do not block on IO. */
-# define MAP_UNINITIALIZE 0x4000000 /* For anonymous mmap, memory could
+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
be uninitialized. */
#endif
--
1.7.10.4

View File

@ -0,0 +1,337 @@
From 8fc83b7f3fd7425aa4e96c870a7d46df1d81c16c Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Tue, 17 Apr 2012 09:30:15 +0200
Subject: [PATCH] libc: add posix_fallocate()
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
include/fcntl.h | 4 +-
libc/sysdeps/linux/common/Makefile.in | 3 +-
libc/sysdeps/linux/common/bits/kernel-features.h | 8 ++
libc/sysdeps/linux/common/posix_fallocate.c | 43 ++++++++
libc/sysdeps/linux/common/posix_fallocate64.c | 39 +++++++
test/.gitignore | 2 +
test/unistd/Makefile.in | 5 +-
test/unistd/tst-posix_fallocate.c | 127 ++++++++++++++++++++++
test/unistd/tst-posix_fallocate64.c | 2 +
9 files changed, 228 insertions(+), 5 deletions(-)
create mode 100644 libc/sysdeps/linux/common/posix_fallocate.c
create mode 100644 libc/sysdeps/linux/common/posix_fallocate64.c
create mode 100644 test/unistd/tst-posix_fallocate.c
create mode 100644 test/unistd/tst-posix_fallocate64.c
diff --git a/include/fcntl.h b/include/fcntl.h
index 26ad1fe..c4a47af 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -210,9 +210,7 @@ extern int posix_fadvise64 (int __fd, __off64_t __offset, __off64_t __len,
#endif
-#if 0 /* && defined __UCLIBC_HAS_ADVANCED_REALTIME__ */
-
-/* FIXME -- uClibc should probably implement these... */
+#if defined __UCLIBC_HAS_ADVANCED_REALTIME__
/* Reserve storage for the data of the file associated with FD.
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index e9baa47..e4ac4ff 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -82,7 +82,8 @@ CSRC-$(UCLIBC_HAS_REALTIME) += clock_getres.c clock_gettime.c clock_settime.c \
sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c \
sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c sigqueue.c
# clock_getcpuclockid|clock_nanosleep|mq_timedreceive|mq_timedsend|posix_fadvise|posix_fallocate|posix_madvise|posix_memalign|posix_mem_offset|posix_spawnattr_destroy|posix_spawnattr_init|posix_spawnattr_getflags|posix_spawnattr_setflags|posix_spawnattr_getpgroup|posix_spawnattr_setpgroup|posix_spawnattr_getschedparam|posix_spawnattr_setschedparam|posix_spawnattr_getschedpolicy|posix_spawnattr_setschedpolicy|posix_spawnattr_getsigdefault|posix_spawnattr_setsigdefault|posix_spawnattr_getsigmask|posix_spawnattr_setsigmask|posix_spawnattr_init|posix_spawnattr_setflags|posix_spawnattr_setpgroup|posix_spawnattr_setschedparam|posix_spawnattr_setschedpolicy|posix_spawnattr_setsigdefault|posix_spawnattr_setsigmask|posix_spawn_file_actions_addclose|posix_spawn_file_actions_addopen|posix_spawn_file_actions_adddup2|posix_spawn_file_actions_addopen|posix_spawn_file_actions_destroy|posix_spawn_file_actions_init|posix_spawn_file_actions_init|posix_spawn|posix_spawnp|posix_spawnp|posix_typed_mem_get_info|pthread_mutex_timedlock|sem_timedwait
-CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c
+CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c \
+ posix_fallocate.c posix_fallocate64.c
CSRC-$(UCLIBC_SUSV4_LEGACY) += utime.c
CSRC-$(UCLIBC_HAS_EPOLL) += epoll.c
CSRC-$(UCLIBC_HAS_XATTR) += xattr.c
diff --git a/libc/sysdeps/linux/common/bits/kernel-features.h b/libc/sysdeps/linux/common/bits/kernel-features.h
index 5665e24..13c7a63 100644
--- a/libc/sysdeps/linux/common/bits/kernel-features.h
+++ b/libc/sysdeps/linux/common/bits/kernel-features.h
@@ -496,6 +496,14 @@
# define __ASSUME_PRIVATE_FUTEX 1
#endif
+/* Support for fallocate was added in 2.6.23,
+ on s390 only after 2.6.23-rc1, on alpha only after 2.6.33-rc1. */
+#if __LINUX_KERNEL_VERSION >= 0x020617 \
+ && (!defined __s390__ || __LINUX_KERNEL_VERSION >= 0x020618) \
+ && (!defined __alpha__ || __LINUX_KERNEL_VERSION >= 0x020621)
+# define __ASSUME_FALLOCATE 1
+#endif
+
/* getcpu is a syscall for x86-64 since 3.1. */
#if defined __x86_64__ && __LINUX_KERNEL_VERSION >= 0x030100
# define __ASSUME_GETCPU_SYSCALL 1
diff --git a/libc/sysdeps/linux/common/posix_fallocate.c b/libc/sysdeps/linux/common/posix_fallocate.c
new file mode 100644
index 0000000..9aaa6ce
--- /dev/null
+++ b/libc/sysdeps/linux/common/posix_fallocate.c
@@ -0,0 +1,43 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * posix_fallocate() for uClibc
+ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <fcntl.h>
+#include <bits/kernel-features.h>
+#include <stdint.h>
+
+#if defined __NR_fallocate
+int posix_fallocate(int fd, __off_t offset, __off_t len)
+{
+ int ret;
+
+# if __WORDSIZE == 32
+ uint32_t off_low = offset;
+ uint32_t len_low = len;
+ /* may assert that these >>31 are 0 */
+ uint32_t zero = 0;
+ INTERNAL_SYSCALL_DECL(err);
+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0,
+ __LONG_LONG_PAIR (zero, off_low),
+ __LONG_LONG_PAIR (zero, len_low)));
+# elif __WORDSIZE == 64
+ INTERNAL_SYSCALL_DECL(err);
+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 4, fd, 0, offset, len));
+# else
+# error your machine is neither 32 bit or 64 bit ... it must be magical
+#endif
+ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err)))
+ return INTERNAL_SYSCALL_ERRNO (ret, err);
+ return 0;
+}
+# if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
+strong_alias(posix_fallocate,posix_fallocate64)
+# endif
+#endif
diff --git a/libc/sysdeps/linux/common/posix_fallocate64.c b/libc/sysdeps/linux/common/posix_fallocate64.c
new file mode 100644
index 0000000..818d868
--- /dev/null
+++ b/libc/sysdeps/linux/common/posix_fallocate64.c
@@ -0,0 +1,39 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * posix_fallocate() for uClibc
+ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <fcntl.h>
+#include <bits/kernel-features.h>
+#include <stdint.h>
+
+#if defined __NR_fallocate
+
+# if __WORDSIZE == 64
+/* Can use normal posix_fallocate() */
+# elif __WORDSIZE == 32
+int posix_fallocate64(int fd, __off64_t offset, __off64_t len)
+{
+ int ret;
+ uint32_t off_low = offset & 0xffffffff;
+ uint32_t off_high = offset >> 32;
+ uint32_t len_low = len & 0xffffffff;
+ uint32_t len_high = len >> 32;
+ INTERNAL_SYSCALL_DECL(err);
+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0,
+ __LONG_LONG_PAIR (off_high, off_low),
+ __LONG_LONG_PAIR (len_high, len_low)));
+ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err)))
+ return INTERNAL_SYSCALL_ERRNO (ret, err);
+ return 0;
+}
+# else
+# error your machine is neither 32 bit or 64 bit ... it must be magical
+# endif
+#endif
diff --git a/test/.gitignore b/test/.gitignore
index 7234c48..ef152e9 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -305,6 +305,8 @@ unistd/getcwd
unistd/getopt
unistd/getopt_long
unistd/tstgetopt
+unistd/tst-posix_fallocate
+unistd/tst-posix_fallocate64
unistd/tst-preadwrite
unistd/tst-preadwrite64
unistd/vfork
diff --git a/test/unistd/Makefile.in b/test/unistd/Makefile.in
index c542f98..24b9a37 100644
--- a/test/unistd/Makefile.in
+++ b/test/unistd/Makefile.in
@@ -2,7 +2,10 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
ifeq ($(UCLIBC_HAS_LFS),)
-TESTS_DISABLED := tst-preadwrite64
+TESTS_DISABLED := tst-preadwrite64 tst-posix_fallocate64
+endif
+ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),)
+TESTS_DISABLED := tst-posix_fallocate
endif
OPTS_getopt := -abcXXX -9
OPTS_getopt_long := --add XXX --delete YYY --verbose
diff --git a/test/unistd/tst-posix_fallocate.c b/test/unistd/tst-posix_fallocate.c
new file mode 100644
index 0000000..d41c604
--- /dev/null
+++ b/test/unistd/tst-posix_fallocate.c
@@ -0,0 +1,127 @@
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#ifndef TST_POSIX_FALLOCATE64
+# define stat64 stat
+# define fstat64 fstat
+# else
+# ifndef O_LARGEFILE
+# error no O_LARGEFILE but you want to test with LFS enabled
+# endif
+#endif
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static int fd;
+static void
+do_prepare (void)
+{
+ fd = create_temp_file ("tst-posix_fallocate.", NULL);
+ if (fd == -1)
+ {
+ printf ("cannot create temporary file: %m\n");
+ exit (1);
+ }
+}
+
+
+static int
+do_test (void)
+{
+ struct stat64 st;
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("1st fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 0)
+ {
+ puts ("file not created with size 0");
+ return 1;
+ }
+
+ if (posix_fallocate (fd, 512, 768) != 0)
+ {
+ puts ("1st posix_fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("2nd fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 512 + 768)
+ {
+ printf ("file size after 1st posix_fallocate call is %llu, expected %u\n",
+ (unsigned long long int) st.st_size, 512u + 768u);
+ return 1;
+ }
+
+ if (posix_fallocate (fd, 0, 1024) != 0)
+ {
+ puts ("2nd posix_fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("3rd fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 512 + 768)
+ {
+ puts ("file size changed in 2nd posix_fallocate");
+ return 1;
+ }
+
+ if (posix_fallocate (fd, 2048, 64) != 0)
+ {
+ puts ("3rd posix_fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("4th fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 2048 + 64)
+ {
+ printf ("file size after 3rd posix_fallocate call is %llu, expected %u\n",
+ (unsigned long long int) st.st_size, 2048u + 64u);
+ return 1;
+ }
+#ifdef TST_POSIX_FALLOCATE64
+ if (posix_fallocate64 (fd, 4097ULL, 4294967295ULL + 2ULL) != 0)
+ {
+ puts ("4th posix_fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("5th fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 4097ULL + 4294967295ULL + 2ULL)
+ {
+ printf ("file size after 4th posix_fallocate call is %llu, expected %llu\n",
+ (unsigned long long int) st.st_size, 4097ULL + 4294967295ULL + 2ULL);
+ return 1;
+ }
+#endif
+ close (fd);
+
+ return 0;
+}
diff --git a/test/unistd/tst-posix_fallocate64.c b/test/unistd/tst-posix_fallocate64.c
new file mode 100644
index 0000000..b1ee0ff
--- /dev/null
+++ b/test/unistd/tst-posix_fallocate64.c
@@ -0,0 +1,2 @@
+#define TST_POSIX_FALLOCATE64
+#include "tst-posix_fallocate.c"
--
1.7.10.4

View File

@ -0,0 +1,44 @@
From e6735556ed0a5e791ea81a015a90c130a0eea060 Mon Sep 17 00:00:00 2001
From: Xi Wang <xi@mit.edu>
Date: Wed, 20 Feb 2013 12:45:45 -0500
Subject: [PATCH] nice: fix overflow checking in int_add_no_wrap()
In C, signed integer overflow is undefined behavior. Many compilers
optimize away checks like `a + b < a'.
Use safe precondition testing instead.
Signed-off-by: Xi Wang <xi@mit.edu>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/sysdeps/linux/common/nice.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libc/sysdeps/linux/common/nice.c b/libc/sysdeps/linux/common/nice.c
index 3694db8..ed39946 100644
--- a/libc/sysdeps/linux/common/nice.c
+++ b/libc/sysdeps/linux/common/nice.c
@@ -25,15 +25,15 @@ static __inline__ _syscall1(int, __syscall_nice, int, incr)
static __inline__ int int_add_no_wrap(int a, int b)
{
- int s = a + b;
-
if (b < 0) {
- if (s > a) s = INT_MIN;
+ if (a < INT_MIN - b)
+ return INT_MIN;
} else {
- if (s < a) s = INT_MAX;
+ if (a > INT_MAX - b)
+ return INT_MAX;
}
- return s;
+ return a + b;
}
static __inline__ int __syscall_nice(int incr)
--
1.7.10.4

View File

@ -0,0 +1,86 @@
From 0600966321c011c31edbb60945bbdca3fa34b7cb Mon Sep 17 00:00:00 2001
From: Markos Chandras <markos.chandras@imgtec.com>
Date: Mon, 25 Feb 2013 09:41:25 +0000
Subject: [PATCH] buildsys: Add missing $(SYMBOL_PREFIX) to symbol names
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
Makerules | 2 +-
ldso/ldso/Makefile.in | 2 +-
ldso/ldso/bfin/dl-startup.h | 5 +----
ldso/libdl/Makefile.in | 2 +-
libpthread/nptl/Makefile.in | 2 +-
5 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/Makerules b/Makerules
index 60acaa8..28bbdef 100644
--- a/Makerules
+++ b/Makerules
@@ -300,7 +300,7 @@ define create-lds
-Wl,-z,relro -Wl,--hash-style=gnu -Wl,-z,defs \
-Wl,--verbose 2>&1 | LC_ALL=C \
sed -e '/^=========/,/^=========/!d;/^=========/d' \
- -e 's/\. = .* + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' > $@.lds
+ -e 's/\. = .* + SIZEOF_HEADERS;/& $(SYMBOL_PREFIX)_begin = . - SIZEOF_HEADERS;/' > $@.lds
endef
define link.so
diff --git a/ldso/ldso/Makefile.in b/ldso/ldso/Makefile.in
index eb1570a..91165c6 100644
--- a/ldso/ldso/Makefile.in
+++ b/ldso/ldso/Makefile.in
@@ -36,7 +36,7 @@ LDFLAGS-$(UCLIBC_LDSO_NAME).so := $(LDFLAGS)
else
LDFLAGS-$(UCLIBC_LDSO_NAME).so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs
endif
-LDFLAGS-$(UCLIBC_LDSO_NAME).so += -Wl,-e,_start -Wl,-z,now -Wl,-Bsymbolic \
+LDFLAGS-$(UCLIBC_LDSO_NAME).so += -Wl,-e,$(SYMBOL_PREFIX)_start -Wl,-z,now -Wl,-Bsymbolic \
-Wl,--export-dynamic $(CFLAG_-Wl--sort-common) -Wl,--discard-locals \
$(CFLAG_-Wl--discard-all) -Wl,--no-undefined
diff --git a/ldso/ldso/bfin/dl-startup.h b/ldso/ldso/bfin/dl-startup.h
index 76ae150..860b7c6 100644
--- a/ldso/ldso/bfin/dl-startup.h
+++ b/ldso/ldso/bfin/dl-startup.h
@@ -40,10 +40,7 @@ __asm__(
" .text\n"
" .global __start\n"
" .type __start,@function\n"
- /* Build system expects a "_start" for the entry point;
- provide it as it's free to do so with aliases. */
- " .set _start, __start\n"
- " .global _start\n"
+ " .hidden __start\n"
"__start:\n"
" call .Lcall\n"
".Lcall:\n"
diff --git a/ldso/libdl/Makefile.in b/ldso/libdl/Makefile.in
index be236c8..edf95a6 100644
--- a/ldso/libdl/Makefile.in
+++ b/ldso/libdl/Makefile.in
@@ -23,7 +23,7 @@ LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libdl.so := -Wl,--dsbt-index=3
LDFLAGS-libdl.so := $(LDFLAGS)
ifeq ($(LDSO_NO_CLEANUP),)
-LDFLAGS-libdl.so += -Wl,-fini,dl_cleanup
+LDFLAGS-libdl.so += -Wl,-fini,$(SYMBOL_PREFIX)dl_cleanup
endif
LIBS-libdl.so := $(LIBS) $(ldso)
diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in
index 158bcae..0008822 100644
--- a/libpthread/nptl/Makefile.in
+++ b/libpthread/nptl/Makefile.in
@@ -145,7 +145,7 @@ LDFLAGS-libpthread.so += $(LDFLAGS)
endif
LDFLAGS-libpthread.so += $(top_builddir)lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so $(top_builddir)lib/libdl-$(VERSION).so \
- -Wl,-z,nodelete,-z,initfirst,-init=__pthread_initialize_minimal_internal
+ -Wl,-z,nodelete,-z,initfirst,-init=$(SYMBOL_PREFIX)__pthread_initialize_minimal_internal
LIBS-libpthread.so := $(LIBS)
--
1.7.10.4

View File

@ -0,0 +1,46 @@
From 5e40582d549b4a186de2fea9efafadd06904424c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Thu, 18 Jun 2009 06:55:46 +0000
Subject: [PATCH] inet: do not filter responses in res_query
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes bug #5342
res_query was silently rejecting responses against T_ANY DNS
questions.
Remove the type-filtering from res_query altogether.
__dns_lookup is supposed to return the proper stuff that you asked
for (and only that).
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/inet/resolv.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index e738098..7bd634c 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -3740,11 +3740,10 @@ int res_query(const char *dname, int class, int type,
free(a.dotted);
- if (a.atype == type) { /* CNAME */
- if (i > anslen)
- i = anslen;
- memcpy(answer, packet, i);
- }
+ if (i > anslen)
+ i = anslen;
+ memcpy(answer, packet, i);
+
free(packet);
return i;
}
--
1.7.10.4

View File

@ -0,0 +1,39 @@
From 9a7b71facfcaee5f3a45429358c55fcd5377c509 Mon Sep 17 00:00:00 2001
From: Bernd Schmidt <bernds@codesourcery.com>
Date: Tue, 24 Jul 2012 15:39:48 +0200
Subject: [PATCH] Remove pragma weak for undeclared symbol
pthread_initialize is a static function and should not be mentioned in a
header. The #pragma weak for it appears to confuse gcc-4.7.
see gcc PR middle-end/36282
Signed-off-by: Bernd Schmidt <bernds@codesourcery.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h b/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h
index 78593ac..f41375b 100644
--- a/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h
+++ b/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h
@@ -375,7 +375,6 @@ weak_extern (BP_SYM (__pthread_key_create))
weak_extern (BP_SYM (__pthread_setspecific))
weak_extern (BP_SYM (__pthread_getspecific))
weak_extern (BP_SYM (__pthread_once))
-weak_extern (__pthread_initialize)
weak_extern (__pthread_atfork)
weak_extern (BP_SYM (_pthread_cleanup_push))
weak_extern (BP_SYM (_pthread_cleanup_pop))
@@ -400,7 +399,6 @@ weak_extern (BP_SYM (_pthread_cleanup_pop_restore))
# pragma weak __pthread_setspecific
# pragma weak __pthread_getspecific
# pragma weak __pthread_once
-# pragma weak __pthread_initialize
# pragma weak __pthread_atfork
# pragma weak _pthread_cleanup_push_defer
# pragma weak _pthread_cleanup_pop_restore
--
1.7.10.4

View File

@ -0,0 +1,34 @@
From 41063cebafa7b90427837757db00cdbfe2690f82 Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Fri, 21 Sep 2012 17:29:12 +0200
Subject: [PATCH] inet: fix getting the nameserver from _res state after
res_init.
Fixes displaying the nameserver in busybox nslookup.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/inet/resolv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 7bd634c..6f58260 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -3653,11 +3653,11 @@ res_init(void)
*/
if (!_res.id)
_res.id = res_randomid();
- __res_sync = res_sync_func;
__UCLIBC_MUTEX_UNLOCK(__resolv_lock);
__res_vinit(&_res, 1);
+ __res_sync = res_sync_func;
return 0;
}
--
1.7.10.4

View File

@ -0,0 +1,30 @@
From 543460903545b59903bc83221a6cea02afd0e04f Mon Sep 17 00:00:00 2001
From: Mirko Vogt <dev@nanl.de>
Date: Fri, 21 Sep 2012 17:29:15 +0200
Subject: [PATCH] _vfprintf.c: use 'fputws_unlocked(S, F)' instead of
'fputws(S, F)'
This eliminates a source of reproduceable freezes
Signed-off-by: Mirko Vogt <dev@nanl.de>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/stdio/_vfprintf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/stdio/_vfprintf.c b/libc/stdio/_vfprintf.c
index 3db8cdf..069db16 100644
--- a/libc/stdio/_vfprintf.c
+++ b/libc/stdio/_vfprintf.c
@@ -1229,7 +1229,7 @@ static size_t _fp_out_narrow(FILE *fp, intptr_t type, intptr_t len, intptr_t buf
#define STRLEN wcslen
#define _PPFS_init _ppwfs_init
/* Pulls in fseek: */
-#define OUTPUT(F,S) fputws(S,F)
+#define OUTPUT(F,S) fputws_unlocked(S,F)
/* TODO: #define OUTPUT(F,S) _wstdio_fwrite((S),wcslen(S),(F)) */
#define _outnwcs(stream, wstring, len) _wstdio_fwrite((const wchar_t *)(wstring), len, stream)
#define FP_OUT _fp_out_wide
--
1.7.10.4

View File

@ -0,0 +1,66 @@
From 12846e741d925630a4079ac02290b28c6f00b887 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell <nathan@codesourcery.com>
Date: Fri, 22 Mar 2013 17:46:52 +0100
Subject: [PATCH] Fix a problem with scanning wide chars.
We found that the testcase
int
main (void)
{
wchar_t s[10];
memset (s, 0, sizeof (s));
int r = sscanf ("s", "%ls", s);
printf ("%d\n", r);
printf ("%ls\n", s);
return 0;
}
printed
0
<blankline>
rather than the expected
1
s
The problem was the enum in _scanf.c, which has had a 'CONV_m' value
inserted. The attached patch fixes the problem in __psfs_parse_spec by
not presuming a particular displacement between the two sets of
char-like conversion values. With this patch the above program produces
the expected output.
Signed-off-by: Nathan Sidwell <nathan@codesourcery.com>
Signed-off-by: Bernd Schmidt <bernds@codesourcery.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/stdio/_scanf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c
index 952853c..3848a09 100644
--- a/libc/stdio/_scanf.c
+++ b/libc/stdio/_scanf.c
@@ -429,8 +429,8 @@ libc_hidden_def(vswscanf)
/* npxXoudif eEgG CS cs[ */
/* NOTE: the 'm' flag must come before any convs that support it */
-/* NOTE: Ordering is important! In particular, CONV_LEFTBRACKET
- * must immediately precede CONV_c. */
+/* NOTE: Ordering is important! The CONV_{C,S,LEFTBRACKET} must map
+ simply to their lowercase equivalents. */
enum {
CONV_n = 0,
@@ -921,7 +921,7 @@ int attribute_hidden __psfs_parse_spec(register psfs_t *psfs)
psfs->dataargtype = PA_FLAG_LONG;
} else if ((p_m_spec_chars >= CONV_c)
&& (psfs->dataargtype & PA_FLAG_LONG)) {
- p_m_spec_chars -= 3; /* lc -> C, ls -> S, l[ -> ?? */
+ p_m_spec_chars -= CONV_c - CONV_C; /* lc -> C, ls -> S, l[ -> ?? */
}
psfs->conv_num = p_m_spec_chars;
--
1.7.10.4

View File

@ -0,0 +1,66 @@
From 2f0580cece3ab2baaf9214f434c7146e389566a4 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell <nathan@codesourcery.com>
Date: Fri, 22 Mar 2013 17:48:51 +0100
Subject: [PATCH] Fix some fragileness in dlopen/do_dlopen wrapper & worker
pair.
do_dlopen contains __builtin_return_address to determine from
whence it was called, and uses that to determine which dynamic
object's data it should use to start the search. (In the bug I was
tracking, this related to whether the application's RPATH was used or
not.) For that to work, it has to have been inlined into the wrapper
function.
As it happens, it wasn't being inlined. That's an unfortunate compiler
behaviour, but it isn't wrong and shouldn't have caused dlopen to fail.
This patch changes things so the wrapper function determines the
return address, and passes it to the worker. If the worker's inlined,
the generated code should be exactly the same as before.
Signed-off-by: Nathan Sidwell <nathan@codesourcery.com>
Signed-off-by: Bernd Schmidt <bernds@codesourcery.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
ldso/libdl/libdl.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 71ade1f..018c720 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -296,11 +296,10 @@ static ptrdiff_t _dl_build_local_scope (struct elf_resolve **list,
return p - list;
}
-static void *do_dlopen(const char *libname, int flag)
+static void *do_dlopen(const char *libname, int flag, ElfW(Addr) from)
{
struct elf_resolve *tpnt, *tfrom;
struct dyn_elf *dyn_chain, *rpnt = NULL, *dyn_ptr, *relro_ptr, *handle;
- ElfW(Addr) from;
struct elf_resolve *tpnt1;
void (*dl_brk) (void);
int now_flag;
@@ -320,8 +319,6 @@ static void *do_dlopen(const char *libname, int flag)
return NULL;
}
- from = (ElfW(Addr)) __builtin_return_address(0);
-
if (!_dl_init) {
_dl_init = true;
_dl_malloc_function = malloc;
@@ -661,7 +658,8 @@ void *dlopen(const char *libname, int flag)
void *ret;
__UCLIBC_MUTEX_CONDITIONAL_LOCK(_dl_mutex, 1);
- ret = do_dlopen(libname, flag);
+ ret = do_dlopen(libname, flag,
+ (ElfW(Addr)) __builtin_return_address(0));
__UCLIBC_MUTEX_CONDITIONAL_UNLOCK(_dl_mutex, 1);
return ret;
--
1.7.10.4

View File

@ -0,0 +1,60 @@
From 7f82a682a730899d30d8640b6af5178919339837 Mon Sep 17 00:00:00 2001
From: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Date: Thu, 9 May 2013 09:04:20 +0200
Subject: [PATCH] libdl: fix dlopen implementation from statically linked
application
Calling dlopen from statically linked application is actually broken,
because _dl_find_hash enters into an infinite loop when trying to
resolve symbols. In this case it doesn't need to extend the global
scope, it is readyto be used as it is, because _dl_loaded_modules already points
to the dlopened library.
The patch also fixesi a typo in __LDSO_LD_LIBRARY_PATH__ macro, that was
preventing to get the actual value of the LD_LIBRARY_PATH.
Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
(cherry picked from commit 231e4a9b4b972662a6832f714a05525a3754892d)
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
---
ldso/libdl/libdl.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 018c720..49711a8 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -374,7 +374,7 @@ static void *do_dlopen(const char *libname, int flag, ElfW(Addr) from)
if (getenv("LD_BIND_NOW"))
now_flag = RTLD_NOW;
-#if !defined SHARED && defined __LDSO_LIBRARY_PATH__
+#if !defined SHARED && defined __LDSO_LD_LIBRARY_PATH__
/* When statically linked, the _dl_library_path is not yet initialized */
_dl_library_path = getenv("LD_LIBRARY_PATH");
#endif
@@ -541,11 +541,18 @@ static void *do_dlopen(const char *libname, int flag, ElfW(Addr) from)
* to the GOT tables. We need to do this in reverse order so that COPY
* directives work correctly */
- /* Get the tail of the list */
+#ifdef SHARED
+ /*
+ * Get the tail of the list.
+ * In the static case doesn't need to extend the global scope, it is
+ * ready to be used as it is, because _dl_loaded_modules already points
+ * to the dlopened library.
+ */
for (ls = &_dl_loaded_modules->symbol_scope; ls && ls->next; ls = ls->next);
/* Extend the global scope by adding the local scope of the dlopened DSO. */
ls->next = &dyn_chain->dyn->symbol_scope;
+#endif
#ifdef __mips__
/*
* Relocation of the GOT entries for MIPS have to be done
--
1.7.10.4

View File

@ -0,0 +1,168 @@
From 6b2250a1a39362abe53e78a45897caecf65ec73f Mon Sep 17 00:00:00 2001
From: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Date: Thu, 9 May 2013 11:42:23 +0200
Subject: [PATCH] libubacktrace: fix backtrace for statically linked
application
libgcc_s.so's unwinder could not access unwind tables of statically
linked binaries, so we really want to use _Unwind_* stuff from
libgcc_eh.a.
It required to build backtrace.c differentiating between shared and
static case.
Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
(cherry picked from commit 71c10c484e7dc113396cccb7e503befb759c6346)
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
---
libubacktrace/Makefile.in | 23 ++++++++++++++---------
libubacktrace/arm/Makefile.arch | 2 +-
libubacktrace/arm/backtrace.c | 7 +++++++
libubacktrace/backtrace.c | 7 +++++++
4 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/libubacktrace/Makefile.in b/libubacktrace/Makefile.in
index 8a4b081..612bf2d 100644
--- a/libubacktrace/Makefile.in
+++ b/libubacktrace/Makefile.in
@@ -25,11 +25,13 @@ libubacktrace_ARCH_OUT:=$(libubacktrace_OUT)/$(TARGET_ARCH)
-include $(libubacktrace_ARCH_DIR)/Makefile.arch
libubacktrace_SRC-y :=
-libubacktrace_SRC-$(UCLIBC_HAS_BACKTRACE) := backtrace.c backtracesyms.c backtracesymsfd.c
+libubacktrace_SRC-$(UCLIBC_HAS_BACKTRACE) := backtracesyms.c backtracesymsfd.c
+libubacktrace_SRC_SHARED-$(UCLIBC_HAS_BACKTRACE) := backtrace.c
# remove generic sources, if arch specific version is present
ifneq ($(strip $(libubacktrace_ARCH_SRC-y)),)
libubacktrace_SRC-y := $(filter-out $(notdir $(libubacktrace_ARCH_SRC-y)),$(libubacktrace_SRC-y))
+libubacktrace_SRC_SHARED-y := $(filter-out $(notdir $(libubacktrace_ARCH_SRC-y)),$(libubacktrace_SRC_SHARED-y))
endif
# -fasynchronous-unwind-tables is required for backtrace to work using dwarf2
@@ -43,12 +45,19 @@ endif
libubacktrace_SRCS := $(patsubst %.c,$(libubacktrace_DIR)/%.c,$(libubacktrace_SRC-y))
libubacktrace_OBJS := $(patsubst $(libubacktrace_DIR)/%.c,$(libubacktrace_OUT)/%.o,$(libubacktrace_SRCS))
+libubacktrace_SHARED_SRCS := $(patsubst %.c,$(libubacktrace_DIR)/%.c,$(libubacktrace_SHARED_SRC-y))
+libubacktrace_SHARED_OBJS := $(patsubst $(libubacktrace_DIR)/%.c,$(libubacktrace_OUT)/%.s,$(libubacktrace_SHARED_SRCS))
+
+libubacktrace-shared-y := $(libubacktrace_SHARED_OBJS:.os=.oS)
+libubacktrace-static-y := $(libubacktrace_SHARED_OBJS)
+
ifeq ($(DOPIC),y)
-libubacktrace-a-y += $(libubacktrace_OBJS:.o=.os)
+libubacktrace-a-y += $(libubacktrace_OBJS:.o=.os) $(libubacktrace-static-y:.o=.os)
else
-libubacktrace-a-y += $(libubacktrace_OBJS)
+libubacktrace-a-y += $(libubacktrace_OBJS) $(libubacktrace-static-y)
endif
-libubacktrace-so-y += $(libubacktrace_OBJS:.o=.os)
+libubacktrace-so-y += $(libubacktrace_OBJS:.o=.os) $(libubacktrace-shared-y)
+
lib-a-$(UCLIBC_HAS_BACKTRACE) += $(top_builddir)lib/libubacktrace.a
lib-so-$(UCLIBC_HAS_BACKTRACE) += $(top_builddir)lib/libubacktrace.so
@@ -56,11 +65,7 @@ lib-so-$(UCLIBC_HAS_BACKTRACE) += $(top_builddir)lib/libubacktrace.so
objclean-y += CLEAN_libubacktrace
ifeq ($(DOMULTI),n)
-ifeq ($(DOPIC),y)
-$(top_builddir)lib/libubacktrace.so: $(top_builddir)lib/libubacktrace.a $(libdl.depend)
-else
$(top_builddir)lib/libubacktrace.so: $(libubacktrace_OUT)/libubacktrace_so.a $(libdl.depend)
-endif
$(call link.so,$(libubacktrace_FULL_NAME),$(ABI_VERSION))
else
$(top_builddir)lib/libubacktrace.so: $(libubacktrace_OUT)/libubacktrace.oS | $(libdl.depend)
@@ -71,7 +76,7 @@ $(libubacktrace_OUT)/libubacktrace_so.a: $(libubacktrace-so-y)
$(Q)$(RM) $@
$(do_ar)
-$(libubacktrace_OUT)/libubacktrace.oS: $(libubacktrace_SRCS) $(libubacktrace_ARCH_SRCS)
+$(libubacktrace_OUT)/libubacktrace.oS: $(libubacktrace_SRCS) $(libubacktrace_ARCH_SRCS) $(libubacktrace_SHARED_SRCS)
$(Q)$(RM) $@
$(compile-m)
diff --git a/libubacktrace/arm/Makefile.arch b/libubacktrace/arm/Makefile.arch
index 53b8c0e..b3fb500 100644
--- a/libubacktrace/arm/Makefile.arch
+++ b/libubacktrace/arm/Makefile.arch
@@ -14,4 +14,4 @@ libubacktrace-a-y+=$(libubacktrace_ARCH_OBJS:.o=.os)
else
libubacktrace-a-y+=$(libubacktrace_ARCH_OBJS)
endif
-libubacktrace-so-y+=$(libubacktrace_ARCH_OBJS:.o=.os)
+libubacktrace-so-y+=$(libubacktrace_ARCH_OBJS:.o=.oS)
diff --git a/libubacktrace/arm/backtrace.c b/libubacktrace/arm/backtrace.c
index d4eca32..5955189 100644
--- a/libubacktrace/arm/backtrace.c
+++ b/libubacktrace/arm/backtrace.c
@@ -25,6 +25,7 @@ struct trace_arg
int cnt, size;
};
+#ifdef SHARED
static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
static _Unwind_VRS_Result (*unwind_vrs_get) (_Unwind_Context *,
_Unwind_VRS_RegClass,
@@ -42,6 +43,10 @@ static void backtrace_init (void)
abort();
}
}
+#else
+# define unwind_backtrace _Unwind_Backtrace
+# define unwind_vrs_get _Unwind_VRS_Get
+#endif
/* This function is identical to "_Unwind_GetGR", except that it uses
"unwind_vrs_get" instead of "_Unwind_VRS_Get". */
static inline _Unwind_Word
@@ -80,8 +85,10 @@ int backtrace (void **array, int size)
{
struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+#ifdef SHARED
if (unwind_backtrace == NULL)
backtrace_init();
+#endif
if (size >= 1)
unwind_backtrace (backtrace_helper, &arg);
diff --git a/libubacktrace/backtrace.c b/libubacktrace/backtrace.c
index fdd5981..1e0a0ec 100644
--- a/libubacktrace/backtrace.c
+++ b/libubacktrace/backtrace.c
@@ -33,6 +33,7 @@ struct trace_arg
int cnt, size;
};
+#ifdef SHARED
static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *);
@@ -47,6 +48,10 @@ static void backtrace_init (void)
abort();
}
}
+#else
+# define unwind_backtrace _Unwind_Backtrace
+# define unwind_getip _Unwind_GetIP
+#endif
static _Unwind_Reason_Code
backtrace_helper (struct _Unwind_Context *ctx, void *a)
@@ -71,8 +76,10 @@ int backtrace (void **array, int size)
{
struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+#ifdef SHARED
if (unwind_backtrace == NULL)
backtrace_init();
+#endif
if (size >= 1)
unwind_backtrace (backtrace_helper, &arg);
--
1.7.10.4

View File

@ -0,0 +1,39 @@
From bcfb096af20bac667381c1601e54c78bcbb09d42 Mon Sep 17 00:00:00 2001
From: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Date: Mon, 13 May 2013 14:06:11 +0200
Subject: [PATCH] libubacktrace: fix build due to some typos
Commit 71c10c484e7dc113396cccb7e503befb759c6346 broke libubactrace build
due to some typos, so that backtrace.o[sS] were not built.
This definetively fixes this problem.
Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
(cherry picked from commit e19afed1bd3af6bf8976912517c0677d238309f8)
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
---
libubacktrace/Makefile.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libubacktrace/Makefile.in b/libubacktrace/Makefile.in
index 612bf2d..1cd5f83 100644
--- a/libubacktrace/Makefile.in
+++ b/libubacktrace/Makefile.in
@@ -45,10 +45,10 @@ endif
libubacktrace_SRCS := $(patsubst %.c,$(libubacktrace_DIR)/%.c,$(libubacktrace_SRC-y))
libubacktrace_OBJS := $(patsubst $(libubacktrace_DIR)/%.c,$(libubacktrace_OUT)/%.o,$(libubacktrace_SRCS))
-libubacktrace_SHARED_SRCS := $(patsubst %.c,$(libubacktrace_DIR)/%.c,$(libubacktrace_SHARED_SRC-y))
-libubacktrace_SHARED_OBJS := $(patsubst $(libubacktrace_DIR)/%.c,$(libubacktrace_OUT)/%.s,$(libubacktrace_SHARED_SRCS))
+libubacktrace_SHARED_SRCS := $(patsubst %.c,$(libubacktrace_DIR)/%.c,$(libubacktrace_SRC_SHARED-y))
+libubacktrace_SHARED_OBJS := $(patsubst $(libubacktrace_DIR)/%.c,$(libubacktrace_OUT)/%.o,$(libubacktrace_SHARED_SRCS))
-libubacktrace-shared-y := $(libubacktrace_SHARED_OBJS:.os=.oS)
+libubacktrace-shared-y := $(libubacktrace_SHARED_OBJS:.o=.oS)
libubacktrace-static-y := $(libubacktrace_SHARED_OBJS)
ifeq ($(DOPIC),y)
--
1.7.10.4

View File

@ -0,0 +1,30 @@
From b8fb56dcd9686d1bdaf02c2f4f395bb185c093d7 Mon Sep 17 00:00:00 2001
From: Carmelo Amoroso <carmelo.amoroso@st.com>
Date: Mon, 27 May 2013 16:30:36 +0200
Subject: [PATCH] libc: elf: explicitly include uClibc_page.h to make
PAGE_SIZE visible
Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
(cherry picked from commit 215c2868aca096364a4725a42c3ffb46dc4e8b39)
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
---
libc/misc/elf/dl-support.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libc/misc/elf/dl-support.c b/libc/misc/elf/dl-support.c
index f194692..908fb06 100644
--- a/libc/misc/elf/dl-support.c
+++ b/libc/misc/elf/dl-support.c
@@ -19,6 +19,7 @@
#include <ldsodefs.h>
#include <string.h>
#endif
+#include <bits/uClibc_page.h>
#if defined(USE_TLS) && USE_TLS
--
1.7.10.4