aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2014-06-26 08:22:04 +0300
committerTimo Teräs <timo.teras@iki.fi>2014-06-26 08:22:04 +0300
commite9ccfe866b0f763a87875e9232c807d364256a53 (patch)
tree31c8b487f17d7bc0efaf1b6a6f00afe976078a81 /main/musl
parent0a31b4923b9e7bee5148bfc641f88950e3146906 (diff)
downloadaports-e9ccfe866b0f763a87875e9232c807d364256a53.tar.bz2
aports-e9ccfe866b0f763a87875e9232c807d364256a53.tar.xz
main/musl: upgrade to 1.1.3
Diffstat (limited to 'main/musl')
-rw-r--r--main/musl/0001-v1.1.2-to-66fcde4a.patch376
-rw-r--r--main/musl/0002-66fcde4a-to-3fa2eb2a.patch1194
-rw-r--r--main/musl/0003-3fa2eb2a-to-70d9c303.patch84
-rw-r--r--main/musl/APKBUILD22
4 files changed, 5 insertions, 1671 deletions
diff --git a/main/musl/0001-v1.1.2-to-66fcde4a.patch b/main/musl/0001-v1.1.2-to-66fcde4a.patch
deleted file mode 100644
index 0c53a38f4f..0000000000
--- a/main/musl/0001-v1.1.2-to-66fcde4a.patch
+++ /dev/null
@@ -1,376 +0,0 @@
-diff --git a/configure b/configure
-index 03c193d..0cff13d 100755
---- a/configure
-+++ b/configure
-@@ -123,7 +123,7 @@ target=
- optimize=auto
- debug=no
- warnings=no
--shared=yes
-+shared=auto
- static=yes
- wrapper=auto
-
-@@ -412,12 +412,15 @@ fi
- tryflag CFLAGS_AUTO -fno-stack-protector
- tryldflag LDFLAGS_AUTO -Wl,--hash-style=both
-
-+test "$shared" = "no" || {
- # Disable dynamic linking if ld is broken and can't do -Bsymbolic-functions
- LDFLAGS_DUMMY=
- tryldflag LDFLAGS_DUMMY -Wl,-Bsymbolic-functions || {
-+test "$shared" = "yes" && fail "$0: error: linker cannot build shared library"
- printf "warning: disabling dynamic linking support\n"
- shared=no
- }
-+}
-
- # Find compiler runtime library
- test -z "$LIBCC" && tryldflag LIBCC -lgcc && tryldflag LIBCC -lgcc_eh
-diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c
-index 89d081e..f7eab8d 100644
---- a/src/env/__init_tls.c
-+++ b/src/env/__init_tls.c
-@@ -11,17 +11,11 @@ int __init_tp(void *p)
- {
- pthread_t td = p;
- td->self = td;
-- if (__set_thread_area(TP_ADJ(p)) < 0)
-- return -1;
-- td->tid = td->pid = __syscall(SYS_set_tid_address, &td->tid);
-- td->errno_ptr = &td->errno_val;
-- /* Currently, both of these predicates depend in the same thing:
-- * successful initialization of the thread pointer. However, in
-- * the future, we may support setups where setting the thread
-- * pointer is possible but threads other than the main thread
-- * cannot work, so it's best to keep the predicates separate. */
-+ int r = __set_thread_area(TP_ADJ(p));
-+ if (r < 0) return -1;
-+ if (!r) libc.can_do_threads = 1;
- libc.has_thread_pointer = 1;
-- libc.can_do_threads = 1;
-+ td->tid = td->pid = __syscall(SYS_set_tid_address, &td->tid);
- return 0;
- }
-
-diff --git a/src/errno/__errno_location.c b/src/errno/__errno_location.c
-index 8419107..49654ef 100644
---- a/src/errno/__errno_location.c
-+++ b/src/errno/__errno_location.c
-@@ -3,6 +3,6 @@
- int *__errno_location(void)
- {
- static int e;
-- if (libc.has_thread_pointer) return __pthread_self()->errno_ptr;
-+ if (libc.has_thread_pointer) return &__pthread_self()->errno_val;
- return &e;
- }
-diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
-index 2e910b3..650e811 100644
---- a/src/internal/pthread_impl.h
-+++ b/src/internal/pthread_impl.h
-@@ -18,7 +18,7 @@ struct pthread {
- uintptr_t sysinfo;
- uintptr_t canary;
- pid_t tid, pid;
-- int tsd_used, errno_val, *errno_ptr;
-+ int tsd_used, errno_val;
- volatile int cancel, canceldisable, cancelasync;
- int detached;
- unsigned char *map_base;
-diff --git a/src/locale/uselocale.c b/src/locale/uselocale.c
-index 224ef38..4fc5c64 100644
---- a/src/locale/uselocale.c
-+++ b/src/locale/uselocale.c
-@@ -4,7 +4,7 @@
-
- locale_t uselocale(locale_t l)
- {
-- pthread_t self = pthread_self();
-+ pthread_t self = __pthread_self();
- locale_t old = self->locale;
- if (l) self->locale = l;
- return old;
-diff --git a/src/misc/getopt.c b/src/misc/getopt.c
-index f1a1639..8a2e4d5 100644
---- a/src/misc/getopt.c
-+++ b/src/misc/getopt.c
-@@ -65,8 +65,11 @@ int getopt(int argc, char * const argv[], const char *optstring)
- }
- return '?';
- }
-- optarg = argv[optind++] + optpos;
-- optpos = 0;
-+ if (optstring[i+2] == ':') optarg = 0;
-+ if (optstring[i+2] != ':' || optpos) {
-+ optarg = argv[optind++] + optpos;
-+ optpos = 0;
-+ }
- }
- return c;
- }
-diff --git a/src/network/res_msend.c b/src/network/res_msend.c
-index 5192b4d..35f106d 100644
---- a/src/network/res_msend.c
-+++ b/src/network/res_msend.c
-@@ -34,7 +34,7 @@ int __res_msend(int nqueries, const unsigned char *const *queries,
- FILE *f, _f;
- unsigned char _buf[256];
- char line[64], *s, *z;
-- int timeout = 5000, attempts = 2, retry_interval;
-+ int timeout = 5000, attempts = 2, retry_interval, servfail_retry;
- union {
- struct sockaddr_in sin;
- struct sockaddr_in6 sin6;
-@@ -152,6 +152,7 @@ int __res_msend(int nqueries, const unsigned char *const *queries,
- qlens[i], MSG_NOSIGNAL,
- (void *)&ns[j], sl);
- t1 = t2;
-+ servfail_retry = 2 * nqueries;
- }
-
- /* Wait for a response, or until time to retry */
-@@ -160,12 +161,12 @@ int __res_msend(int nqueries, const unsigned char *const *queries,
- while ((rlen = recvfrom(fd, answers[next], asize, 0,
- (void *)&sa, (socklen_t[1]){sl})) >= 0) {
-
-- /* Ignore non-identifiable packets (no query id) */
-- if (rlen < 2) continue;
-+ /* Ignore non-identifiable packets */
-+ if (rlen < 4) continue;
-
- /* Ignore replies from addresses we didn't send to */
-- for (i=0; i<nns && memcmp(ns+i, &sa, sl); i++);
-- if (i==nns) continue;
-+ for (j=0; j<nns && memcmp(ns+j, &sa, sl); j++);
-+ if (j==nns) continue;
-
- /* Find which query this answer goes with, if any */
- for (i=next; i<nqueries && (
-@@ -174,6 +175,22 @@ int __res_msend(int nqueries, const unsigned char *const *queries,
- if (i==nqueries) continue;
- if (alens[i]) continue;
-
-+ /* Only accept positive or negative responses;
-+ * retry immediately on server failure, and ignore
-+ * all other codes such as refusal. */
-+ switch (answers[next][3] & 15) {
-+ case 0:
-+ case 3:
-+ break;
-+ case 2:
-+ if (servfail_retry && servfail_retry--)
-+ sendto(fd, queries[i],
-+ qlens[i], MSG_NOSIGNAL,
-+ (void *)&ns[j], sl);
-+ default:
-+ continue;
-+ }
-+
- /* Store answer in the right slot, or update next
- * available temp slot if it's already in place. */
- alens[i] = rlen;
-diff --git a/src/stdio/ftrylockfile.c b/src/stdio/ftrylockfile.c
-index eef4e25..56cccaf 100644
---- a/src/stdio/ftrylockfile.c
-+++ b/src/stdio/ftrylockfile.c
-@@ -4,7 +4,7 @@
-
- int ftrylockfile(FILE *f)
- {
-- int tid = pthread_self()->tid;
-+ int tid = __pthread_self()->tid;
- if (f->lock == tid) {
- if (f->lockcount == LONG_MAX)
- return -1;
-diff --git a/src/thread/cancel_impl.c b/src/thread/cancel_impl.c
-index 525d290..41cf2b8 100644
---- a/src/thread/cancel_impl.c
-+++ b/src/thread/cancel_impl.c
-@@ -58,7 +58,7 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx)
- void __testcancel()
- {
- if (!libc.has_thread_pointer) return;
-- pthread_t self = pthread_self();
-+ pthread_t self = __pthread_self();
- if (self->cancel && !self->canceldisable)
- __cancel();
- }
-diff --git a/src/thread/i386/__set_thread_area.s b/src/thread/i386/__set_thread_area.s
-index cccf1cd..ad53815 100644
---- a/src/thread/i386/__set_thread_area.s
-+++ b/src/thread/i386/__set_thread_area.s
-@@ -12,11 +12,25 @@ __set_thread_area:
- mov $243,%al
- int $128
- testl %eax,%eax
-- jnz 1f
-- movl (%esp),%ecx
-- leal 3(,%ecx,8),%ecx
-- movw %cx,%gs
-+ jnz 2f
-+ movl (%esp),%edx
-+ leal 3(,%edx,8),%edx
-+3: movw %dx,%gs
- 1:
- addl $16,%esp
- popl %ebx
- ret
-+2:
-+ mov %ebx,%ecx
-+ xor %ebx,%ebx
-+ xor %edx,%edx
-+ mov %ebx,(%esp)
-+ mov $1,%bl
-+ mov $16,%dl
-+ mov $123,%al
-+ int $128
-+ testl %eax,%eax
-+ jnz 1b
-+ mov $7,%dl
-+ inc %al
-+ jmp 3b
-diff --git a/src/thread/pthread_cond_broadcast.c b/src/thread/pthread_cond_broadcast.c
-index 848e288..0901daf 100644
---- a/src/thread/pthread_cond_broadcast.c
-+++ b/src/thread/pthread_cond_broadcast.c
-@@ -28,7 +28,7 @@ int pthread_cond_broadcast(pthread_cond_t *c)
- /* Perform the futex requeue, waking one waiter unless we know
- * that the calling thread holds the mutex. */
- __syscall(SYS_futex, &c->_c_seq, FUTEX_REQUEUE,
-- !m->_m_type || (m->_m_lock&INT_MAX)!=pthread_self()->tid,
-+ !m->_m_type || (m->_m_lock&INT_MAX)!=__pthread_self()->tid,
- INT_MAX, &m->_m_lock);
-
- out:
-diff --git a/src/thread/pthread_cond_timedwait.c b/src/thread/pthread_cond_timedwait.c
-index 1f25c8e..99d62cc 100644
---- a/src/thread/pthread_cond_timedwait.c
-+++ b/src/thread/pthread_cond_timedwait.c
-@@ -41,7 +41,7 @@ int pthread_cond_timedwait(pthread_cond_t *restrict c, pthread_mutex_t *restrict
- struct cm cm = { .c=c, .m=m };
- int r, e=0, seq;
-
-- if (m->_m_type && (m->_m_lock&INT_MAX) != pthread_self()->tid)
-+ if (m->_m_type && (m->_m_lock&INT_MAX) != __pthread_self()->tid)
- return EPERM;
-
- if (ts && ts->tv_nsec >= 1000000000UL)
-diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
-index e0b5ef1..e9c8160 100644
---- a/src/thread/pthread_create.c
-+++ b/src/thread/pthread_create.c
-@@ -13,7 +13,7 @@ weak_alias(dummy_0, __pthread_tsd_run_dtors);
-
- _Noreturn void pthread_exit(void *result)
- {
-- pthread_t self = pthread_self();
-+ pthread_t self = __pthread_self();
- sigset_t set;
-
- self->result = result;
-@@ -78,7 +78,7 @@ _Noreturn void pthread_exit(void *result)
- void __do_cleanup_push(struct __ptcb *cb)
- {
- if (!libc.has_thread_pointer) return;
-- struct pthread *self = pthread_self();
-+ struct pthread *self = __pthread_self();
- cb->__next = self->cancelbuf;
- self->cancelbuf = cb;
- }
-@@ -201,7 +201,6 @@ int pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attrp
- new->stack = stack;
- new->stack_size = stack - stack_limit;
- new->pid = self->pid;
-- new->errno_ptr = &new->errno_val;
- new->start = entry;
- new->start_arg = arg;
- new->self = new;
-diff --git a/src/thread/pthread_mutex_consistent.c b/src/thread/pthread_mutex_consistent.c
-index 7dfb904..65da29f 100644
---- a/src/thread/pthread_mutex_consistent.c
-+++ b/src/thread/pthread_mutex_consistent.c
-@@ -3,7 +3,7 @@
- int pthread_mutex_consistent(pthread_mutex_t *m)
- {
- if (m->_m_type < 8) return EINVAL;
-- if ((m->_m_lock & 0x3fffffff) != pthread_self()->tid)
-+ if ((m->_m_lock & 0x3fffffff) != __pthread_self()->tid)
- return EPERM;
- m->_m_type -= 8;
- return 0;
-diff --git a/src/thread/pthread_mutex_timedlock.c b/src/thread/pthread_mutex_timedlock.c
-index c24270d..7b1afc0 100644
---- a/src/thread/pthread_mutex_timedlock.c
-+++ b/src/thread/pthread_mutex_timedlock.c
-@@ -10,7 +10,7 @@ int pthread_mutex_timedlock(pthread_mutex_t *restrict m, const struct timespec *
- while ((r=pthread_mutex_trylock(m)) == EBUSY) {
- if (!(r=m->_m_lock) || (r&0x40000000)) continue;
- if ((m->_m_type&3) == PTHREAD_MUTEX_ERRORCHECK
-- && (r&0x1fffffff) == pthread_self()->tid)
-+ && (r&0x1fffffff) == __pthread_self()->tid)
- return EDEADLK;
-
- a_inc(&m->_m_waiters);
-diff --git a/src/thread/pthread_mutex_trylock.c b/src/thread/pthread_mutex_trylock.c
-index db784a7..00ad65d 100644
---- a/src/thread/pthread_mutex_trylock.c
-+++ b/src/thread/pthread_mutex_trylock.c
-@@ -8,7 +8,7 @@ int pthread_mutex_trylock(pthread_mutex_t *m)
- if (m->_m_type == PTHREAD_MUTEX_NORMAL)
- return a_cas(&m->_m_lock, 0, EBUSY) & EBUSY;
-
-- self = pthread_self();
-+ self = __pthread_self();
- tid = self->tid;
-
- if (m->_m_type >= 4) {
-diff --git a/src/thread/pthread_mutex_unlock.c b/src/thread/pthread_mutex_unlock.c
-index 5fc0f4e..b4bd74b 100644
---- a/src/thread/pthread_mutex_unlock.c
-+++ b/src/thread/pthread_mutex_unlock.c
-@@ -13,7 +13,7 @@ int pthread_mutex_unlock(pthread_mutex_t *m)
- if (m->_m_type != PTHREAD_MUTEX_NORMAL) {
- if (!m->_m_lock)
- return EPERM;
-- self = pthread_self();
-+ self = __pthread_self();
- if ((m->_m_lock&0x1fffffff) != self->tid)
- return EPERM;
- if ((m->_m_type&3) == PTHREAD_MUTEX_RECURSIVE && m->_m_count)
-diff --git a/src/thread/pthread_setcanceltype.c b/src/thread/pthread_setcanceltype.c
-index ce2fff0..bf0a3f3 100644
---- a/src/thread/pthread_setcanceltype.c
-+++ b/src/thread/pthread_setcanceltype.c
-@@ -2,7 +2,7 @@
-
- int pthread_setcanceltype(int new, int *old)
- {
-- struct pthread *self = pthread_self();
-+ struct pthread *self = __pthread_self();
- if (new > 1U) return EINVAL;
- if (old) *old = self->cancelasync;
- self->cancelasync = new;
-diff --git a/src/time/__tz.c b/src/time/__tz.c
-index 6d7173c..92c43a5 100644
---- a/src/time/__tz.c
-+++ b/src/time/__tz.c
-@@ -128,7 +128,7 @@ static void do_tzset()
- "/usr/share/zoneinfo/\0/share/zoneinfo/\0/etc/zoneinfo/\0";
-
- s = getenv("TZ");
-- if (!s || !*s) s = __gmt;
-+ if (!s || !*s) s = "/etc/localtime";
-
- if (old_tz && !strcmp(s, old_tz)) return;
-
-@@ -153,7 +153,8 @@ static void do_tzset()
- if (*s == ':' || ((p=strchr(s, '/')) && !memchr(s, ',', p-s))) {
- if (*s == ':') s++;
- if (*s == '/' || *s == '.') {
-- if (!libc.secure) map = __map_file(s, &map_size);
-+ if (!libc.secure || !strcmp(s, "/etc/localtime"))
-+ map = __map_file(s, &map_size);
- } else {
- size_t l = strlen(s);
- if (l <= NAME_MAX && !strchr(s, '.')) {
diff --git a/main/musl/0002-66fcde4a-to-3fa2eb2a.patch b/main/musl/0002-66fcde4a-to-3fa2eb2a.patch
deleted file mode 100644
index 5b30442f06..0000000000
--- a/main/musl/0002-66fcde4a-to-3fa2eb2a.patch
+++ /dev/null
@@ -1,1194 +0,0 @@
-diff --git a/Makefile b/Makefile
-index 0ab0bfd..d5a64fc 100644
---- a/Makefile
-+++ b/Makefile
-@@ -125,7 +125,7 @@ $(foreach s,$(wildcard src/*/$(ARCH)*/*.s),$(eval $(call mkasmdep,$(s))))
-
- lib/libc.so: $(LOBJS)
- $(CC) $(CFLAGS_ALL_SHARED) $(LDFLAGS) -nostdlib -shared \
-- -Wl,-e,_start -Wl,-Bsymbolic-functions \
-+ -Wl,-e,_dlstart -Wl,-Bsymbolic-functions \
- -o $@ $(LOBJS) $(LIBCC)
-
- lib/libc.a: $(OBJS)
-diff --git a/arch/arm/reloc.h b/arch/arm/reloc.h
-index 264b7ab..ee39b7f 100644
---- a/arch/arm/reloc.h
-+++ b/arch/arm/reloc.h
-@@ -16,41 +16,29 @@
-
- #define LDSO_ARCH "arm" ENDIAN_SUFFIX FP_SUFFIX
-
--#define IS_COPY(x) ((x)==R_ARM_COPY)
--#define IS_PLT(x) ((x)==R_ARM_JUMP_SLOT)
-+#define NO_LEGACY_INITFINI
-+
-+#define TPOFF_K 8
-
--static inline void do_single_reloc(
-- struct dso *self, unsigned char *base_addr,
-- size_t *reloc_addr, int type, size_t addend,
-- Sym *sym, size_t sym_size,
-- struct symdef def, size_t sym_val)
-+static int remap_rel(int type)
- {
- switch(type) {
- case R_ARM_ABS32:
-- *reloc_addr += sym_val;
-- break;
-+ return REL_SYMBOLIC;
- case R_ARM_GLOB_DAT:
-+ return REL_GOT;
- case R_ARM_JUMP_SLOT:
-- *reloc_addr = sym_val;
-- break;
-+ return REL_PLT;
- case R_ARM_RELATIVE:
-- *reloc_addr += (size_t)base_addr;
-- break;
-+ return REL_RELATIVE;
- case R_ARM_COPY:
-- memcpy(reloc_addr, (void *)sym_val, sym_size);
-- break;
-+ return REL_COPY;
- case R_ARM_TLS_DTPMOD32:
-- *reloc_addr = def.dso ? def.dso->tls_id : self->tls_id;
-- break;
-+ return REL_DTPMOD;
- case R_ARM_TLS_DTPOFF32:
-- *reloc_addr += def.sym->st_value;
-- break;
-+ return REL_DTPOFF;
- case R_ARM_TLS_TPOFF32:
-- *reloc_addr += def.sym
-- ? def.sym->st_value + def.dso->tls_offset + 8
-- : self->tls_offset + 8;
-- break;
-+ return REL_TPOFF;
- }
-+ return 0;
- }
--
--#define NO_LEGACY_INITFINI
-diff --git a/arch/i386/reloc.h b/arch/i386/reloc.h
-index 3923b54..eaf5aae 100644
---- a/arch/i386/reloc.h
-+++ b/arch/i386/reloc.h
-@@ -3,47 +3,31 @@
-
- #define LDSO_ARCH "i386"
-
--#define IS_COPY(x) ((x)==R_386_COPY)
--#define IS_PLT(x) ((x)==R_386_JMP_SLOT)
--
--static inline void do_single_reloc(
-- struct dso *self, unsigned char *base_addr,
-- size_t *reloc_addr, int type, size_t addend,
-- Sym *sym, size_t sym_size,
-- struct symdef def, size_t sym_val)
-+static int remap_rel(int type)
- {
- switch(type) {
- case R_386_32:
-- *reloc_addr += sym_val;
-- break;
-+ return REL_SYMBOLIC;
- case R_386_PC32:
-- *reloc_addr += sym_val - (size_t)reloc_addr;
-- break;
-+ return REL_OFFSET;
- case R_386_GLOB_DAT:
-+ return REL_GOT;
- case R_386_JMP_SLOT:
-- *reloc_addr = sym_val;
-- break;
-+ return REL_PLT;
- case R_386_RELATIVE:
-- *reloc_addr += (size_t)base_addr;
-- break;
-+ return REL_RELATIVE;
- case R_386_COPY:
-- memcpy(reloc_addr, (void *)sym_val, sym_size);
-- break;
-+ return REL_COPY;
- case R_386_TLS_DTPMOD32:
-- *reloc_addr = def.dso ? def.dso->tls_id : self->tls_id;
-- break;
-+ return REL_DTPMOD;
- case R_386_TLS_DTPOFF32:
-- *reloc_addr = def.sym->st_value;
-- break;
-+ return REL_DTPOFF;
- case R_386_TLS_TPOFF:
-- *reloc_addr += def.sym
-- ? def.sym->st_value - def.dso->tls_offset
-- : 0 - self->tls_offset;
-- break;
-+ return REL_TPOFF;
- case R_386_TLS_TPOFF32:
-- *reloc_addr += def.sym
-- ? def.dso->tls_offset - def.sym->st_value
-- : self->tls_offset;
-- break;
-+ return REL_TPOFF_NEG;
-+ case R_386_TLS_DESC:
-+ return REL_TLSDESC;
- }
-+ return 0;
- }
-diff --git a/arch/microblaze/reloc.h b/arch/microblaze/reloc.h
-index 7bf3a5b..71a6219 100644
---- a/arch/microblaze/reloc.h
-+++ b/arch/microblaze/reloc.h
-@@ -10,34 +10,27 @@
-
- #define LDSO_ARCH "microblaze" ENDIAN_SUFFIX
-
--#define IS_COPY(x) ((x)==R_MICROBLAZE_COPY)
--#define IS_PLT(x) ((x)==R_MICROBLAZE_JUMP_SLOT)
-+#define TPOFF_K 0
-
--static inline void do_single_reloc(
-- struct dso *self, unsigned char *base_addr,
-- size_t *reloc_addr, int type, size_t addend,
-- Sym *sym, size_t sym_size,
-- struct symdef def, size_t sym_val)
-+static int remap_rel(int type)
- {
- switch(type) {
- case R_MICROBLAZE_32:
-+ return REL_SYMBOLIC;
- case R_MICROBLAZE_GLOB_DAT:
-+ return REL_GOT;
- case R_MICROBLAZE_JUMP_SLOT:
-- *reloc_addr = sym_val + addend;
-- break;
-+ return REL_PLT;
- case R_MICROBLAZE_REL:
-- *reloc_addr = (size_t)base_addr + addend;
-- break;
-+ return REL_RELATIVE;
- case R_MICROBLAZE_COPY:
-- memcpy(reloc_addr, (void *)sym_val, sym_size);
-- break;
-+ return REL_COPY;
- case R_MICROBLAZE_TLSDTPMOD32:
-- *reloc_addr = def.dso ? def.dso->tls_id : self->tls_id;
-- break;
-+ return REL_DTPMOD;
- case R_MICROBLAZE_TLSDTPREL32:
-- *reloc_addr = def.sym->st_value + addend;
-- break;
-+ return REL_DTPOFF;
- }
-+ return 0;
- }
-
- #include "syscall.h"
-diff --git a/arch/mips/reloc.h b/arch/mips/reloc.h
-index 4ca8125..91fa097 100644
---- a/arch/mips/reloc.h
-+++ b/arch/mips/reloc.h
-@@ -16,38 +16,25 @@
-
- #define LDSO_ARCH "mips" ENDIAN_SUFFIX FP_SUFFIX
-
--#define IS_COPY(x) ((x)==R_MIPS_COPY)
--#define IS_PLT(x) 1
-+#define TPOFF_K (-0x7000)
-
--static inline void do_single_reloc(
-- struct dso *self, unsigned char *base_addr,
-- size_t *reloc_addr, int type, size_t addend,
-- Sym *sym, size_t sym_size,
-- struct symdef def, size_t sym_val)
-+static int remap_rel(int type)
- {
- switch(type) {
-- case R_MIPS_JUMP_SLOT:
-- *reloc_addr = sym_val;
-- break;
- case R_MIPS_REL32:
-- if (sym_val) *reloc_addr += sym_val;
-- else *reloc_addr += (size_t)base_addr;
-- break;
-+ return REL_SYM_OR_REL;
-+ case R_MIPS_JUMP_SLOT:
-+ return REL_PLT;
- case R_MIPS_COPY:
-- memcpy(reloc_addr, (void *)sym_val, sym_size);
-- break;
-+ return REL_COPY;
- case R_MIPS_TLS_DTPMOD32:
-- *reloc_addr = def.dso ? def.dso->tls_id : self->tls_id;
-- break;
-+ return REL_DTPMOD;
- case R_MIPS_TLS_DTPREL32:
-- *reloc_addr += def.sym->st_value;
-- break;
-+ return REL_DTPOFF;
- case R_MIPS_TLS_TPREL32:
-- *reloc_addr += def.sym
-- ? def.sym->st_value + def.dso->tls_offset - 0x7000
-- : self->tls_offset - 0x7000;
-- break;
-+ return REL_TPOFF;
- }
-+ return 0;
- }
-
- void __reloc_self(int c, size_t *a, size_t *dynv, size_t *got)
-diff --git a/arch/powerpc/reloc.h b/arch/powerpc/reloc.h
-index 38034c5..73c583b 100644
---- a/arch/powerpc/reloc.h
-+++ b/arch/powerpc/reloc.h
-@@ -3,40 +3,29 @@
-
- #define LDSO_ARCH "powerpc"
-
--#define IS_COPY(x) ((x)==R_PPC_COPY)
--#define IS_PLT(x) ((x)==R_PPC_JMP_SLOT)
-+#define TPOFF_K (-0x7000)
-
--// see linux' arch/powerpc/include/asm/elf.h
--static inline void do_single_reloc(
-- struct dso *self, unsigned char *base_addr,
-- size_t *reloc_addr, int type, size_t addend,
-- Sym *sym, size_t sym_size,
-- struct symdef def, size_t sym_val)
-+static int remap_rel(int type)
- {
- switch(type) {
-+ case R_PPC_ADDR32:
-+ return REL_SYMBOLIC;
- case R_PPC_GLOB_DAT:
-+ return REL_GOT;
- case R_PPC_JMP_SLOT:
-- case R_PPC_ADDR32:
-- *reloc_addr = sym_val + addend;
-- break;
-- case R_PPC_COPY:
-- memcpy(reloc_addr, (void *)sym_val, sym_size);
-- break;
-+ return REL_PLT;
- case R_PPC_RELATIVE:
-- *reloc_addr = (size_t)base_addr + addend;
-- break;
-+ return REL_RELATIVE;
-+ case R_PPC_COPY:
-+ return REL_COPY;
- case R_PPC_DTPMOD32:
-- *reloc_addr = def.dso ? def.dso->tls_id : self->tls_id;
-- break;
-+ return REL_DTPMOD;
- case R_PPC_DTPREL32:
-- *reloc_addr = def.sym->st_value + addend;
-- break;
-+ return REL_DTPOFF;
- case R_PPC_TPREL32:
-- *reloc_addr += def.sym
-- ? def.sym->st_value + def.dso->tls_offset - 0x7000
-- : self->tls_offset - 0x7000;
-- break;
-+ return REL_TPOFF;
- }
-+ return 0;
- }
-
- void __reloc_self(int c, size_t *a, size_t *dynv)
-diff --git a/arch/sh/reloc.h b/arch/sh/reloc.h
-index db3de08..aeb02d0 100644
---- a/arch/sh/reloc.h
-+++ b/arch/sh/reloc.h
-@@ -6,42 +6,29 @@
-
- #define LDSO_ARCH "sh" ENDIAN_SUFFIX
-
--#define IS_COPY(x) ((x) == R_SH_COPY)
--#define IS_PLT(x) ((x) == R_SH_JMP_SLOT)
-+#define TPOFF_K 8
-
--static inline void do_single_reloc(
-- struct dso *self, unsigned char *base_addr,
-- size_t *reloc_addr, int type, size_t addend,
-- Sym *sym, size_t sym_size,
-- struct symdef def, size_t sym_val)
-+static int remap_rel(int type)
- {
- switch(type) {
-+ case R_SH_DIR32:
-+ return REL_SYMBOLIC;
-+ case R_SH_REL32:
-+ return REL_OFFSET;
- case R_SH_GLOB_DAT:
-+ return REL_GOT;
- case R_SH_JMP_SLOT:
-- *reloc_addr = sym_val;
-- break;
-+ return REL_PLT;
- case R_SH_RELATIVE:
-- *reloc_addr = (size_t)base_addr + addend;
-- break;
-- case R_SH_DIR32:
-- *reloc_addr = sym_val + addend;
-- break;
-- case R_SH_REL32:
-- *reloc_addr = sym_val + addend - (size_t)reloc_addr + (size_t)base_addr;
-- break;
-+ return REL_RELATIVE;
- case R_SH_COPY:
-- memcpy(reloc_addr, (void *)sym_val, sym_size);
-- break;
-+ return REL_COPY;
- case R_SH_TLS_DTPMOD32:
-- *reloc_addr += def.dso ? def.dso->tls_id : self->tls_id;
-- break;
-+ return REL_DTPMOD;
- case R_SH_TLS_DTPOFF32:
-- *reloc_addr += def.sym->st_value;
-- break;
-+ return REL_DTPOFF;
- case R_SH_TLS_TPOFF32:
-- *reloc_addr += def.sym
-- ? def.sym->st_value + def.dso->tls_offset + 8
-- : self->tls_offset + 8;
-- break;
-+ return REL_TPOFF;
- }
-+ return 0;
- }
-diff --git a/arch/x32/reloc.h b/arch/x32/reloc.h
-index f294eec..fcfbf99 100644
---- a/arch/x32/reloc.h
-+++ b/arch/x32/reloc.h
-@@ -4,43 +4,37 @@
-
- #define LDSO_ARCH "x32"
-
--#define IS_COPY(x) ((x)==R_X86_64_COPY)
--#define IS_PLT(x) ((x)==R_X86_64_JUMP_SLOT)
-+/* FIXME: x32 is very strange in its use of 64-bit relocation types in
-+ * a 32-bit environment. As long as the memory at reloc_addr is
-+ * zero-filled prior to relocations, just treating 64-bit relocations
-+ * as operating on 32-bit slots should be fine, but this should be
-+ * checked. In particular, R_X86_64_64, R_X86_64_DTPOFF64, and
-+ * R_X86_64_TPOFF64 may need checking. */
-
--static inline void do_single_reloc(
-- struct dso *self, unsigned char *base_addr,
-- size_t *reloc_addr, int type, size_t addend,
-- Sym *sym, size_t sym_size,
-- struct symdef def, size_t sym_val)
-+static int remap_rel(int type)
- {
- switch(type) {
-- case R_X86_64_GLOB_DAT:
-- case R_X86_64_JUMP_SLOT:
- case R_X86_64_64:
-- *reloc_addr = sym_val + addend;
-- break;
- case R_X86_64_32:
-- *(uint32_t *)reloc_addr = sym_val + addend;
-- break;
-+ return REL_SYMBOLIC;
- case R_X86_64_PC32:
-- *reloc_addr = sym_val + addend - (size_t)reloc_addr + (size_t)base_addr;
-- break;
-+ return REL_OFFSET;
-+ case R_X86_64_GLOB_DAT:
-+ return REL_GOT;
-+ case R_X86_64_JUMP_SLOT:
-+ return REL_PLT;
- case R_X86_64_RELATIVE:
-- *reloc_addr = (size_t)base_addr + addend;
-- break;
-+ return REL_RELATIVE;
- case R_X86_64_COPY:
-- memcpy(reloc_addr, (void *)sym_val, sym_size);
-- break;
-+ return REL_COPY;
- case R_X86_64_DTPMOD64:
-- *reloc_addr = def.dso ? def.dso->tls_id : self->tls_id;
-- break;
-+ return REL_DTPMOD;
- case R_X86_64_DTPOFF64:
-- *reloc_addr = def.sym->st_value + addend;
-- break;
-+ case R_X86_64_DTPOFF32:
-+ return REL_DTPOFF;
- case R_X86_64_TPOFF64:
-- *reloc_addr = (def.sym
-- ? def.sym->st_value - def.dso->tls_offset
-- : 0 - self->tls_offset) + addend;
-- break;
-+ case R_X86_64_TPOFF32:
-+ return REL_TPOFF;
- }
-+ return 0;
- }
-diff --git a/arch/x86_64/reloc.h b/arch/x86_64/reloc.h
-index 28cf7cc..9bc5849 100644
---- a/arch/x86_64/reloc.h
-+++ b/arch/x86_64/reloc.h
-@@ -4,43 +4,29 @@
-
- #define LDSO_ARCH "x86_64"
-
--#define IS_COPY(x) ((x)==R_X86_64_COPY)
--#define IS_PLT(x) ((x)==R_X86_64_JUMP_SLOT)
--
--static inline void do_single_reloc(
-- struct dso *self, unsigned char *base_addr,
-- size_t *reloc_addr, int type, size_t addend,
-- Sym *sym, size_t sym_size,
-- struct symdef def, size_t sym_val)
-+static int remap_rel(int type)
- {
- switch(type) {
-- case R_X86_64_GLOB_DAT:
-- case R_X86_64_JUMP_SLOT:
- case R_X86_64_64:
-- *reloc_addr = sym_val + addend;
-- break;
-- case R_X86_64_32:
-- *(uint32_t *)reloc_addr = sym_val + addend;
-- break;
-+ return REL_SYMBOLIC;
- case R_X86_64_PC32:
-- *reloc_addr = sym_val + addend - (size_t)reloc_addr + (size_t)base_addr;
-- break;
-+ return REL_OFFSET32;
-+ case R_X86_64_GLOB_DAT:
-+ return REL_GOT;
-+ case R_X86_64_JUMP_SLOT:
-+ return REL_PLT;
- case R_X86_64_RELATIVE:
-- *reloc_addr = (size_t)base_addr + addend;
-- break;
-+ return REL_RELATIVE;
- case R_X86_64_COPY:
-- memcpy(reloc_addr, (void *)sym_val, sym_size);
-- break;
-+ return REL_COPY;
- case R_X86_64_DTPMOD64:
-- *reloc_addr = def.dso ? def.dso->tls_id : self->tls_id;
-- break;
-+ return REL_DTPMOD;
- case R_X86_64_DTPOFF64:
-- *reloc_addr = def.sym->st_value + addend;
-- break;
-+ return REL_DTPOFF;
- case R_X86_64_TPOFF64:
-- *reloc_addr = (def.sym
-- ? def.sym->st_value - def.dso->tls_offset
-- : 0 - self->tls_offset) + addend;
-- break;
-+ return REL_TPOFF;
-+ case R_X86_64_TLSDESC:
-+ return REL_TLSDESC;
- }
-+ return 0;
- }
-diff --git a/include/sys/socket.h b/include/sys/socket.h
-index d752791..b911d6e 100644
---- a/include/sys/socket.h
-+++ b/include/sys/socket.h
-@@ -26,6 +26,17 @@ struct ucred
- uid_t uid;
- gid_t gid;
- };
-+
-+struct mmsghdr
-+{
-+ struct msghdr msg_hdr;
-+ unsigned int msg_len;
-+};
-+
-+struct timespec;
-+
-+int sendmmsg (int, struct mmsghdr *, unsigned int, unsigned int);
-+int recvmmsg (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *);
- #endif
-
- struct linger
-diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c
-index f7eab8d..13cf2ee 100644
---- a/src/env/__init_tls.c
-+++ b/src/env/__init_tls.c
-@@ -53,11 +53,6 @@ void *__copy_tls(unsigned char *mem)
- return td;
- }
-
--void *__tls_get_addr(size_t *v)
--{
-- return (char *)__pthread_self()->dtv[1]+v[1];
--}
--
- #if ULONG_MAX == 0xffffffff
- typedef Elf32_Phdr Phdr;
- #else
-diff --git a/src/ldso/arm/start.s b/src/ldso/arm/start.s
-index dfa3657..5dd93b5 100644
---- a/src/ldso/arm/start.s
-+++ b/src/ldso/arm/start.s
-@@ -1,6 +1,6 @@
- .text
--.global _start
--_start:
-+.global _dlstart
-+_dlstart:
- ldr r0,[sp]
- add r1,sp,#4
- bl __dynlink
-diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
-index 1cb3fb4..bc4f2f6 100644
---- a/src/ldso/dynlink.c
-+++ b/src/ldso/dynlink.c
-@@ -1,6 +1,8 @@
- #define _GNU_SOURCE
- #include <stdio.h>
- #include <stdlib.h>
-+#include <stdarg.h>
-+#include <stddef.h>
- #include <string.h>
- #include <unistd.h>
- #include <stdint.h>
-@@ -48,6 +50,11 @@ struct debug {
- void *base;
- };
-
-+struct td_index {
-+ size_t args[2];
-+ struct td_index *next;
-+};
-+
- struct dso {
- unsigned char *base;
- char *name;
-@@ -79,6 +86,7 @@ struct dso {
- void **new_dtv;
- unsigned char *new_tls;
- int new_dtv_idx, new_tls_idx;
-+ struct td_index *td_index;
- struct dso *fini_next;
- char *shortname;
- char buf[];
-@@ -89,6 +97,24 @@ struct symdef {
- struct dso *dso;
- };
-
-+enum {
-+ REL_ERR,
-+ REL_SYMBOLIC,
-+ REL_GOT,
-+ REL_PLT,
-+ REL_RELATIVE,
-+ REL_OFFSET,
-+ REL_OFFSET32,
-+ REL_COPY,
-+ REL_SYM_OR_REL,
-+ REL_TLS, /* everything past here is TLS */
-+ REL_DTPMOD,
-+ REL_DTPOFF,
-+ REL_TPOFF,
-+ REL_TPOFF_NEG,
-+ REL_TLSDESC,
-+};
-+
- #include "reloc.h"
-
- int __init_tp(void *);
-@@ -107,6 +133,7 @@ static jmp_buf *rtld_fail;
- static pthread_rwlock_t lock;
- static struct debug debug;
- static size_t tls_cnt, tls_offset, tls_align = 4*sizeof(size_t);
-+static size_t static_tls_cnt;
- static pthread_mutex_t init_fini_lock = { ._m_type = PTHREAD_MUTEX_RECURSIVE };
- static long long builtin_tls[(sizeof(struct pthread) + 64)/sizeof(long long)];
-
-@@ -132,6 +159,17 @@ static int search_vec(size_t *v, size_t *r, size_t key)
- return 1;
- }
-
-+static void error(const char *fmt, ...)
-+{
-+ va_list ap;
-+ va_start(ap, fmt);
-+ vsnprintf(errbuf, sizeof errbuf, fmt, ap);
-+ va_end(ap);
-+ if (runtime) longjmp(*rtld_fail, 1);
-+ dprintf(2, "%s\n", errbuf);
-+ ldso_fail = 1;
-+}
-+
- static uint32_t sysv_hash(const char *s0)
- {
- const unsigned char *s = (void *)s0;
-@@ -227,6 +265,10 @@ static struct symdef find_sym(struct dso *dso, const char *s, int need_def)
- return def;
- }
-
-+#define NO_INLINE_ADDEND (1<<REL_COPY | 1<<REL_GOT | 1<<REL_PLT)
-+
-+ptrdiff_t __tlsdesc_static(), __tlsdesc_dynamic();
-+
- static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stride)
- {
- unsigned char *base = dso->base;
-@@ -235,36 +277,116 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
- Sym *sym;
- const char *name;
- void *ctx;
-- int type;
-+ int astype, type;
- int sym_index;
- struct symdef def;
-+ size_t *reloc_addr;
-+ size_t sym_val;
-+ size_t tls_val;
-+ size_t addend;
-
- for (; rel_size; rel+=stride, rel_size-=stride*sizeof(size_t)) {
-- type = R_TYPE(rel[1]);
-+ astype = R_TYPE(rel[1]);
-+ if (!astype) continue;
-+ type = remap_rel(astype);
-+ if (!type) {
-+ error(errbuf, sizeof errbuf,
-+ "Error relocating %s: unsupported relocation type %d",
-+ dso->name, astype);
-+ continue;
-+ }
- sym_index = R_SYM(rel[1]);
-+ reloc_addr = (void *)(base + rel[0]);
- if (sym_index) {
- sym = syms + sym_index;
- name = strings + sym->st_name;
-- ctx = IS_COPY(type) ? head->next : head;
-- def = find_sym(ctx, name, IS_PLT(type));
-+ ctx = type==REL_COPY ? head->next : head;
-+ def = find_sym(ctx, name, type==REL_PLT);
- if (!def.sym && (sym->st_shndx != SHN_UNDEF
- || sym->st_info>>4 != STB_WEAK)) {
-- snprintf(errbuf, sizeof errbuf,
-+ error(errbuf, sizeof errbuf,
- "Error relocating %s: %s: symbol not found",
- dso->name, name);
-- if (runtime) longjmp(*rtld_fail, 1);
-- dprintf(2, "%s\n", errbuf);
-- ldso_fail = 1;
- continue;
- }
- } else {
- sym = 0;
- def.sym = 0;
-- def.dso = 0;
-+ def.dso = dso;
-+ }
-+
-+ addend = stride>2 ? rel[2]
-+ : (1<<type & NO_INLINE_ADDEND) ? 0
-+ : *reloc_addr;
-+
-+ sym_val = def.sym ? (size_t)def.dso->base+def.sym->st_value : 0;
-+ tls_val = def.sym ? def.sym->st_value : 0;
-+
-+ switch(type) {
-+ case REL_OFFSET:
-+ addend -= (size_t)reloc_addr;
-+ case REL_SYMBOLIC:
-+ case REL_GOT:
-+ case REL_PLT:
-+ *reloc_addr = sym_val + addend;
-+ break;
-+ case REL_RELATIVE:
-+ *reloc_addr = (size_t)base + addend;
-+ break;
-+ case REL_SYM_OR_REL:
-+ if (sym) *reloc_addr = sym_val + addend;
-+ else *reloc_addr = (size_t)base + addend;
-+ break;
-+ case REL_COPY:
-+ memcpy(reloc_addr, (void *)sym_val, sym->st_size);
-+ break;
-+ case REL_OFFSET32:
-+ *(uint32_t *)reloc_addr = sym_val + addend
-+ - (size_t)reloc_addr;
-+ break;
-+ case REL_DTPMOD:
-+ *reloc_addr = def.dso->tls_id;
-+ break;
-+ case REL_DTPOFF:
-+ *reloc_addr = tls_val + addend;
-+ break;
-+#ifdef TLS_ABOVE_TP
-+ case REL_TPOFF:
-+ *reloc_addr = tls_val + def.dso->tls_offset + TPOFF_K + addend;
-+ break;
-+#else
-+ case REL_TPOFF:
-+ *reloc_addr = tls_val - def.dso->tls_offset + addend;
-+ break;
-+ case REL_TPOFF_NEG:
-+ *reloc_addr = def.dso->tls_offset - tls_val + addend;
-+ break;
-+#endif
-+ case REL_TLSDESC:
-+ if (stride<3) addend = reloc_addr[1];
-+ if (runtime && def.dso->tls_id >= static_tls_cnt) {
-+ struct td_index *new = malloc(sizeof *new);
-+ if (!new) error(errbuf, sizeof errbuf,
-+ "Error relocating %s: cannot allocate TLSDESC for %s",
-+ dso->name, sym ? name : "(local)" );
-+ new->next = dso->td_index;
-+ dso->td_index = new;
-+ new->args[0] = def.dso->tls_id;
-+ new->args[1] = tls_val + addend;
-+ reloc_addr[0] = (size_t)__tlsdesc_dynamic;
-+ reloc_addr[1] = (size_t)new;
-+ } else {
-+ reloc_addr[0] = (size_t)__tlsdesc_static;
-+#ifdef TLS_ABOVE_TP
-+ reloc_addr[1] = tls_val + def.dso->tls_offset
-+ + TPOFF_K + addend;
-+#else
-+ reloc_addr[1] = tls_val - def.dso->tls_offset
-+ + addend;
-+#endif
-+ }
-+ break;
- }
-- do_single_reloc(dso, base, (void *)(base + rel[0]), type,
-- stride>2 ? rel[2] : 0, sym, sym?sym->st_size:0, def,
-- def.sym?(size_t)(def.dso->base+def.sym->st_value):0);
- }
- }
-
-@@ -717,12 +839,9 @@ static void load_deps(struct dso *p)
- if (p->dynv[i] != DT_NEEDED) continue;
- dep = load_library(p->strings + p->dynv[i+1], p);
- if (!dep) {
-- snprintf(errbuf, sizeof errbuf,
-+ error(errbuf, sizeof errbuf,
- "Error loading shared library %s: %m (needed by %s)",
- p->strings + p->dynv[i+1], p->name);
-- if (runtime) longjmp(*rtld_fail, 1);
-- dprintf(2, "%s\n", errbuf);
-- ldso_fail = 1;
- continue;
- }
- if (runtime) {
-@@ -771,12 +890,9 @@ static void reloc_all(struct dso *p)
-
- if (p->relro_start != p->relro_end &&
- mprotect(p->base+p->relro_start, p->relro_end-p->relro_start, PROT_READ) < 0) {
-- snprintf(errbuf, sizeof errbuf,
-+ error(errbuf, sizeof errbuf,
- "Error relocating %s: RELRO protection failed: %m",
- p->name);
-- if (runtime) longjmp(*rtld_fail, 1);
-- dprintf(2, "%s\n", errbuf);
-- ldso_fail = 1;
- }
-
- p->relocated = 1;
-@@ -915,17 +1031,15 @@ void *__copy_tls(unsigned char *mem)
- return td;
- }
-
--void *__tls_get_addr(size_t *v)
-+void *__tls_get_new(size_t *v)
- {
- pthread_t self = __pthread_self();
-- if (v[0]<=(size_t)self->dtv[0] && self->dtv[v[0]])
-- return (char *)self->dtv[v[0]]+v[1];
-
- /* Block signals to make accessing new TLS async-signal-safe */
- sigset_t set;
-- pthread_sigmask(SIG_BLOCK, SIGALL_SET, &set);
-- if (v[0]<=(size_t)self->dtv[0] && self->dtv[v[0]]) {
-- pthread_sigmask(SIG_SETMASK, &set, 0);
-+ __block_all_sigs(&set);
-+ if (v[0]<=(size_t)self->dtv[0]) {
-+ __restore_sigs(&set);
- return (char *)self->dtv[v[0]]+v[1];
- }
-
-@@ -946,13 +1060,19 @@ void *__tls_get_addr(size_t *v)
- self->dtv = newdtv;
- }
-
-- /* Get new TLS memory from new DSO */
-- unsigned char *mem = p->new_tls +
-- (p->tls_size + p->tls_align) * a_fetch_add(&p->new_tls_idx,1);
-- mem += ((uintptr_t)p->tls_image - (uintptr_t)mem) & (p->tls_align-1);
-- self->dtv[v[0]] = mem;
-- memcpy(mem, p->tls_image, p->tls_len);
-- pthread_sigmask(SIG_SETMASK, &set, 0);
-+ /* Get new TLS memory from all new DSOs up to the requested one */
-+ unsigned char *mem;
-+ for (p=head; ; p=p->next) {
-+ if (!p->tls_id || self->dtv[p->tls_id]) continue;
-+ mem = p->new_tls + (p->tls_size + p->tls_align)
-+ * a_fetch_add(&p->new_tls_idx,1);
-+ mem += ((uintptr_t)p->tls_image - (uintptr_t)mem)
-+ & (p->tls_align-1);
-+ self->dtv[p->tls_id] = mem;
-+ memcpy(mem, p->tls_image, p->tls_len);
-+ if (p->tls_id == v[0]) break;
-+ }
-+ __restore_sigs(&set);
- return mem + v[1];
- }
-
-@@ -1196,6 +1316,7 @@ void *__dynlink(int argc, char **argv)
- dprintf(2, "%s: Thread-local storage not supported by kernel.\n", argv[0]);
- _exit(127);
- }
-+ static_tls_cnt = tls_cnt;
-
- if (ldso_fail) _exit(127);
- if (ldd_mode) _exit(0);
-@@ -1251,6 +1372,11 @@ void *dlopen(const char *file, int mode)
- for (p=orig_tail->next; p; p=next) {
- next = p->next;
- munmap(p->map, p->map_len);
-+ while (p->td_index) {
-+ void *tmp = p->td_index->next;
-+ free(p->td_index);
-+ p->td_index = tmp;
-+ }
- free(p->deps);
- free(p);
- }
-@@ -1314,6 +1440,8 @@ static int invalid_dso_handle(void *h)
- return 1;
- }
-
-+void *__tls_get_addr(size_t *);
-+
- static void *do_dlsym(struct dso *p, const char *s, void *ra)
- {
- size_t i;
-diff --git a/src/ldso/i386/start.s b/src/ldso/i386/start.s
-index b16f8af..c37a1fa 100644
---- a/src/ldso/i386/start.s
-+++ b/src/ldso/i386/start.s
-@@ -1,6 +1,6 @@
- .text
--.global _start
--_start:
-+.global _dlstart
-+_dlstart:
- xor %ebp,%ebp
- pop %edi
- mov %esp,%esi
-diff --git a/src/ldso/i386/tlsdesc.s b/src/ldso/i386/tlsdesc.s
-new file mode 100644
-index 0000000..3ac6129
---- /dev/null
-+++ b/src/ldso/i386/tlsdesc.s
-@@ -0,0 +1,27 @@
-+.text
-+.global __tlsdesc_static
-+.type __tlsdesc_static,@function
-+__tlsdesc_static:
-+ mov 4(%eax),%eax
-+ ret
-+
-+.global __tlsdesc_dynamic
-+.type __tlsdesc_dynamic,@function
-+__tlsdesc_dynamic:
-+ mov 4(%eax),%eax
-+ push %edx
-+ mov %gs:4,%edx
-+ push %ecx
-+ mov (%eax),%ecx
-+ cmp %ecx,(%edx)
-+ jc 1f
-+ mov 4(%eax),%eax
-+ add (%edx,%ecx,4),%eax
-+2: pop %ecx
-+ sub %gs:0,%eax
-+ pop %edx
-+ ret
-+1: push %eax
-+ call __tls_get_addr
-+ pop %ecx
-+ jmp 2b
-diff --git a/src/ldso/microblaze/start.s b/src/ldso/microblaze/start.s
-index 4e0a0e5..067e861 100644
---- a/src/ldso/microblaze/start.s
-+++ b/src/ldso/microblaze/start.s
-@@ -1,6 +1,6 @@
- # FIXME: clearing argv entries
--.global _start
--_start:
-+.global _dlstart
-+_dlstart:
- add r19, r0, r0
-
- lw r5, r0, r1
-diff --git a/src/ldso/mips/start.s b/src/ldso/mips/start.s
-index 2e98529..0cadbf8 100644
---- a/src/ldso/mips/start.s
-+++ b/src/ldso/mips/start.s
-@@ -2,9 +2,9 @@
- .hidden __reloc_self
- .set noreorder
- .set nomacro
--.global _start
--.type _start,@function
--_start:
-+.global _dlstart
-+.type _dlstart,@function
-+_dlstart:
- move $fp, $0
-
- bgezal $0, 1f
-diff --git a/src/ldso/powerpc/start.s b/src/ldso/powerpc/start.s
-index 6c499e8..6548d58 100644
---- a/src/ldso/powerpc/start.s
-+++ b/src/ldso/powerpc/start.s
-@@ -1,6 +1,6 @@
-- .global _start
-- .type _start,@function
--_start:
-+ .global _dlstart
-+ .type _dlstart,@function
-+_dlstart:
- bl 1f
- 2: .long _DYNAMIC-2b
- 1: mflr 5
-diff --git a/src/ldso/sh/start.s b/src/ldso/sh/start.s
-index ca6b7fc..0d2d913 100644
---- a/src/ldso/sh/start.s
-+++ b/src/ldso/sh/start.s
-@@ -1,7 +1,7 @@
- .text
--.global _start
--.type _start, @function
--_start:
-+.global _dlstart
-+.type _dlstart, @function
-+_dlstart:
- mov.l @r15, r4
- mov r15, r5
- mov.l L1, r0
-diff --git a/src/ldso/tlsdesc.c b/src/ldso/tlsdesc.c
-new file mode 100644
-index 0000000..031b5b8
---- /dev/null
-+++ b/src/ldso/tlsdesc.c
-@@ -0,0 +1,13 @@
-+#ifdef SHARED
-+
-+#include <stddef.h>
-+#include "libc.h"
-+
-+ptrdiff_t __tlsdesc_static()
-+{
-+ return 0;
-+}
-+
-+weak_alias(__tlsdesc_static, __tlsdesc_dynamic);
-+
-+#endif
-diff --git a/src/ldso/x32/start.s b/src/ldso/x32/start.s
-index 0fcf46d..3c3800a 100644
---- a/src/ldso/x32/start.s
-+++ b/src/ldso/x32/start.s
-@@ -1,6 +1,6 @@
- .text
--.global _start
--_start:
-+.global _dlstart
-+_dlstart:
- mov (%rsp),%rdi /* move argc into 1st argument slot */
- lea 4(%rsp),%rsi /* move argv into 2nd argument slot */
- call __dynlink
-diff --git a/src/ldso/x86_64/start.s b/src/ldso/x86_64/start.s
-index 80c1d08..1c5598a 100644
---- a/src/ldso/x86_64/start.s
-+++ b/src/ldso/x86_64/start.s
-@@ -1,6 +1,6 @@
- .text
--.global _start
--_start:
-+.global _dlstart
-+_dlstart:
- mov (%rsp),%rdi
- lea 8(%rsp),%rsi
- call __dynlink
-diff --git a/src/ldso/x86_64/tlsdesc.s b/src/ldso/x86_64/tlsdesc.s
-new file mode 100644
-index 0000000..57b78e0
---- /dev/null
-+++ b/src/ldso/x86_64/tlsdesc.s
-@@ -0,0 +1,40 @@
-+.text
-+.global __tlsdesc_static
-+.type __tlsdesc_static,@function
-+__tlsdesc_static:
-+ mov 8(%rax),%rax
-+ ret
-+
-+.global __tlsdesc_dynamic
-+.type __tlsdesc_dynamic,@function
-+__tlsdesc_dynamic:
-+ mov 8(%rax),%rax
-+ push %rdx
-+ mov %fs:8,%rdx
-+ push %rcx
-+ mov (%rax),%rcx
-+ cmp %rcx,(%rdx)
-+ jc 1f
-+ mov 8(%rax),%rax
-+ add (%rdx,%rcx,8),%rax
-+2: pop %rcx
-+ sub %fs:0,%rax
-+ pop %rdx
-+ ret
-+1: push %rdi
-+ push %rdi
-+ push %rsi
-+ push %r8
-+ push %r9
-+ push %r10
-+ push %r11
-+ mov %rax,%rdi
-+ call __tls_get_addr
-+ pop %r11
-+ pop %r10
-+ pop %r9
-+ pop %r8
-+ pop %rsi
-+ pop %rdi
-+ pop %rdi
-+ jmp 2b
-diff --git a/src/linux/fanotify.c b/src/linux/fanotify.c
-index 1f4ef93..c6211af 100644
---- a/src/linux/fanotify.c
-+++ b/src/linux/fanotify.c
-@@ -9,6 +9,6 @@ int fanotify_init(unsigned flags, unsigned event_f_flags)
- int fanotify_mark(int fanotify_fd, unsigned flags, unsigned long long mask,
- int dfd, const char *pathname)
- {
-- return syscall(SYS_fanotify_mark, flags, __SYSCALL_LL_O(mask), dfd, pathname);
-+ return syscall(SYS_fanotify_mark, fanotify_fd, flags, __SYSCALL_LL_E(mask), dfd, pathname);
- }
-
-diff --git a/src/network/recvmmsg.c b/src/network/recvmmsg.c
-new file mode 100644
-index 0000000..58b1b2f
---- /dev/null
-+++ b/src/network/recvmmsg.c
-@@ -0,0 +1,15 @@
-+#define _GNU_SOURCE
-+#include <sys/socket.h>
-+#include <limits.h>
-+#include "syscall.h"
-+
-+int recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec *timeout)
-+{
-+#if LONG_MAX > INT_MAX
-+ struct mmsghdr *mh = msgvec;
-+ unsigned int i;
-+ for (i = vlen; i; i--, mh++)
-+ mh->msg_hdr.__pad1 = mh->msg_hdr.__pad2 = 0;
-+#endif
-+ return syscall_cp(SYS_recvmmsg, fd, msgvec, vlen, flags, timeout);
-+}
-diff --git a/src/network/sendmmsg.c b/src/network/sendmmsg.c
-new file mode 100644
-index 0000000..ff9f861
---- /dev/null
-+++ b/src/network/sendmmsg.c
-@@ -0,0 +1,29 @@
-+#define _GNU_SOURCE
-+#include <sys/socket.h>
-+#include <limits.h>
-+#include <errno.h>
-+#include "syscall.h"
-+
-+int sendmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags)
-+{
-+#if LONG_MAX > INT_MAX
-+ /* Can't use the syscall directly because the kernel has the wrong
-+ * idea for the types of msg_iovlen, msg_controllen, and cmsg_len,
-+ * and the cmsg blocks cannot be modified in-place. */
-+ int i;
-+ if (vlen > IOV_MAX) vlen = IOV_MAX; /* This matches the kernel. */
-+ for (i=0; i<vlen; i++) {
-+ /* As an unfortunate inconsistency, the sendmmsg API uses
-+ * unsigned int for the resulting msg_len, despite sendmsg
-+ * returning ssize_t. However Linux limits the total bytes
-+ * sent by sendmsg to INT_MAX, so the assignment is safe. */
-+ ssize_t r = sendmsg(fd, &msgvec[i].msg_hdr, flags);
-+ if (r < 0) goto error;
-+ msgvec[i].msg_len = r;
-+ }
-+error:
-+ return i ? i : -1;
-+#else
-+ return syscall_cp(SYS_sendmmsg, fd, msgvec, vlen, flags);
-+#endif
-+}
-diff --git a/src/string/memmem.c b/src/string/memmem.c
-index 3b1ae18..d7e1221 100644
---- a/src/string/memmem.c
-+++ b/src/string/memmem.c
-@@ -112,8 +112,8 @@ static char *twoway_memmem(const unsigned char *h, const unsigned char *z, const
- }
-
- /* Compare right half */
-- for (k=MAX(ms+1,mem); n[k] && n[k] == h[k]; k++);
-- if (n[k]) {
-+ for (k=MAX(ms+1,mem); k<l && n[k] == h[k]; k++);
-+ if (k < l) {
- h += k-ms;
- mem = 0;
- continue;
-diff --git a/src/thread/__tls_get_addr.c b/src/thread/__tls_get_addr.c
-new file mode 100644
-index 0000000..28ec7f0
---- /dev/null
-+++ b/src/thread/__tls_get_addr.c
-@@ -0,0 +1,17 @@
-+#include <stddef.h>
-+#include "pthread_impl.h"
-+#include "libc.h"
-+
-+void *__tls_get_new(size_t *) ATTR_LIBC_VISIBILITY;
-+
-+void *__tls_get_addr(size_t *v)
-+{
-+ pthread_t self = __pthread_self();
-+#ifdef SHARED
-+ if (v[0]<=(size_t)self->dtv[0])
-+ return (char *)self->dtv[v[0]]+v[1];
-+ return __tls_get_new(v);
-+#else
-+ return (char *)self->dtv[1]+v[1];
-+#endif
-+}
-diff --git a/src/thread/i386/tls.s b/src/thread/i386/tls.s
-index e1f2262..6e01adf 100644
---- a/src/thread/i386/tls.s
-+++ b/src/thread/i386/tls.s
-@@ -2,7 +2,14 @@
- .global ___tls_get_addr
- .type ___tls_get_addr,@function
- ___tls_get_addr:
-- push %eax
-+ mov %gs:4,%edx
-+ mov (%eax),%ecx
-+ cmp %ecx,(%edx)
-+ jc 1f
-+ mov 4(%eax),%eax
-+ add (%edx,%ecx,4),%eax
-+ ret
-+1: push %eax
- call __tls_get_addr
- pop %edx
- ret
diff --git a/main/musl/0003-3fa2eb2a-to-70d9c303.patch b/main/musl/0003-3fa2eb2a-to-70d9c303.patch
deleted file mode 100644
index f2d218cee0..0000000000
--- a/main/musl/0003-3fa2eb2a-to-70d9c303.patch
+++ /dev/null
@@ -1,84 +0,0 @@
-diff --git a/configure b/configure
-index 0cff13d..b1cf998 100755
---- a/configure
-+++ b/configure
-@@ -298,12 +298,9 @@ fi
- tryflag CFLAGS_MEMOPS -fno-tree-loop-distribute-patterns
-
- #
--# If debugging is explicitly enabled, don't auto-enable optimizations
-+# Enable debugging if requessted.
- #
--if test "$debug" = yes ; then
--CFLAGS_AUTO=-g
--test "$optimize" = auto && optimize=no
--fi
-+test "$debug" = yes && CFLAGS_AUTO=-g
-
- #
- # Possibly add a -O option to CFLAGS and select modules to optimize with
-diff --git a/include/syslog.h b/include/syslog.h
-index 71dbd99..5b4d296 100644
---- a/include/syslog.h
-+++ b/include/syslog.h
-@@ -69,21 +69,17 @@ void vsyslog (int, const char *, va_list);
- #if defined(SYSLOG_NAMES)
- #define INTERNAL_NOPRI 0x10
- #define INTERNAL_MARK (LOG_NFACILITIES<<3)
--struct __CODE {
-- const char *c_name;
-- int c_val;
--};
- typedef struct {
- char *c_name;
- int c_val;
- } CODE;
--#define prioritynames ((CODE *)(const struct __CODE []){ \
-+#define prioritynames ((CODE *)(const CODE []){ \
- { "alert", LOG_ALERT }, { "crit", LOG_CRIT }, { "debug", LOG_DEBUG }, \
- { "emerg", LOG_EMERG }, { "err", LOG_ERR }, { "error", LOG_ERR }, \
- { "info", LOG_INFO }, { "none", INTERNAL_NOPRI }, \
- { "notice", LOG_NOTICE }, { "panic", LOG_EMERG }, \
- { "warn", LOG_WARNING }, { "warning", LOG_WARNING }, { 0, -1 } })
--#define facilitynames ((CODE *)(const struct __CODE []){ \
-+#define facilitynames ((CODE *)(const CODE []){ \
- { "auth", LOG_AUTH }, { "authpriv", LOG_AUTHPRIV }, \
- { "cron", LOG_CRON }, { "daemon", LOG_DAEMON }, { "ftp", LOG_FTP }, \
- { "kern", LOG_KERN }, { "lpr", LOG_LPR }, { "mail", LOG_MAIL }, \
-diff --git a/src/network/gethostbyaddr_r.c b/src/network/gethostbyaddr_r.c
-index 73e7644..66e0330 100644
---- a/src/network/gethostbyaddr_r.c
-+++ b/src/network/gethostbyaddr_r.c
-@@ -18,6 +18,8 @@ int gethostbyaddr_r(const void *a, socklen_t l, int af,
- socklen_t sl = af==AF_INET6 ? sizeof sa.sin6 : sizeof sa.sin;
- int i;
-
-+ *res = 0;
-+
- /* Load address argument into sockaddr structure */
- if (af==AF_INET6 && l==16) memcpy(&sa.sin6.sin6_addr, a, 16);
- else if (af==AF_INET && l==4) memcpy(&sa.sin.sin_addr, a, 4);
-diff --git a/src/network/gethostbyname2_r.c b/src/network/gethostbyname2_r.c
-index aa8b0a9..81f71d2 100644
---- a/src/network/gethostbyname2_r.c
-+++ b/src/network/gethostbyname2_r.c
-@@ -17,6 +17,7 @@ int gethostbyname2_r(const char *name, int af,
- int i, cnt;
- size_t align, need;
-
-+ *res = 0;
- cnt = __lookup_name(addrs, canon, name, af, AI_CANONNAME);
- if (cnt<0) switch (cnt) {
- case EAI_NONAME:
-diff --git a/src/network/sendmmsg.c b/src/network/sendmmsg.c
-index ff9f861..eeae1d0 100644
---- a/src/network/sendmmsg.c
-+++ b/src/network/sendmmsg.c
-@@ -12,6 +12,7 @@ int sendmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int fla
- * and the cmsg blocks cannot be modified in-place. */
- int i;
- if (vlen > IOV_MAX) vlen = IOV_MAX; /* This matches the kernel. */
-+ if (!vlen) return 0;
- for (i=0; i<vlen; i++) {
- /* As an unfortunate inconsistency, the sendmmsg API uses
- * unsigned int for the resulting msg_len, despite sendmsg
diff --git a/main/musl/APKBUILD b/main/musl/APKBUILD
index b1cbac3512..cb0620472f 100644
--- a/main/musl/APKBUILD
+++ b/main/musl/APKBUILD
@@ -1,8 +1,8 @@
# Contributor: William Pitcock <nenolod@dereferenced.org>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
-pkgver=1.1.2
-pkgrel=5
+pkgver=1.1.3
+pkgrel=0
pkgdesc="the musl c library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
@@ -13,9 +13,6 @@ makedepends="$depends_dev"
install="$pkgname.post-upgrade"
subpackages="$pkgname-dev $pkgname-utils $pkgname-dbg"
source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz
- 0001-v1.1.2-to-66fcde4a.patch
- 0002-66fcde4a-to-3fa2eb2a.patch
- 0003-3fa2eb2a-to-70d9c303.patch
1001-add-basic-dns-record-parsing-functions.patch
1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
@@ -118,10 +115,7 @@ utils() {
install -D -m755 "$srcdir"/ldconfig "$subpkgdir"/sbin
}
-md5sums="a81309e54efdf9c68baf679790fc5678 musl-1.1.2.tar.gz
-a6a1f5c4f34f80cb1fd4c6e1b7936013 0001-v1.1.2-to-66fcde4a.patch
-3a852204b383784506d861b3a307b939 0002-66fcde4a-to-3fa2eb2a.patch
-1f4f1caf7be196015e1444c6acfeb7f4 0003-3fa2eb2a-to-70d9c303.patch
+md5sums="1628bd4c86b14b90447e1dcf8421aed7 musl-1.1.3.tar.gz
a3810683ef61ac27e2f6ec9801280c81 1001-add-basic-dns-record-parsing-functions.patch
83c3bd2a50b1de5ef948704d3f4e0583 1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
013be8897f27c3909ada59c62020502f ldconfig
@@ -130,10 +124,7 @@ a3810683ef61ac27e2f6ec9801280c81 1001-add-basic-dns-record-parsing-functions.pa
cb82d21fed17a116b44b830adba71c5a getconf.c
2b941c4251cac44988a4abfc50e21267 getent.c
45f92f8d59cf84d765de698a9578dbf4 iconv.c"
-sha256sums="dac94112b9a22d2657cd3f36ca0d62ee1eb10707a22bfc97d5746147ef92852b musl-1.1.2.tar.gz
-2cd863b8a7d4af3d592607b20479163c1a011cf5a458cf7f0dc2dc9c08f5b57c 0001-v1.1.2-to-66fcde4a.patch
-0c09923f514729533992f251b7eaa776c414373b3fa20ec2274257c29323028d 0002-66fcde4a-to-3fa2eb2a.patch
-a65e7423db737122b2cc0d0f17b613c38a98ade638a9b87eeca86ee8399fb91a 0003-3fa2eb2a-to-70d9c303.patch
+sha256sums="4ef8a7559b947808d41dbea98e24d9f36be38326fb2754a91a35520b4ca4af9f musl-1.1.3.tar.gz
758390768b1bc4159d56908ca332b9640cd0552ed3b4b2b8d4a6d499c54c11a1 1001-add-basic-dns-record-parsing-functions.patch
1c25880095e869b827f02997e864fdf4bf157a4e923e52d97dbd05e657aedb70 1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
398dc26ec82cc6af056c738e8ac62da212ba978229d9839eb8b61f7ce536da4a ldconfig
@@ -142,10 +133,7 @@ d9b644ec20bc33e81a7c52b9fcf7973d835923a69faf50f03db45534b811bd96 getopt_long.c
1b540709f83b7b9a03073b39066810fdb90537d840b50c2016a84bedce038606 getconf.c
68373a55e89ce85c562d941ccf588337d6cc6c9c17689d695f65cd7607134bbe getent.c
f79a2930a2e5bb0624321589edf8b889d1e9b603e01e6b7ae214616605b3fdd7 iconv.c"
-sha512sums="54d279efea6e122567c936e47401df5c0f1493c42eb3199b0ba3053b1882a864fc1a71d19ad945bc4f328407231c54a7897413e37f4bc33337a243c044a26b4a musl-1.1.2.tar.gz
-631b93b875d0b4451e8ab4587d4cd495617fe4b8627387bb7d19af5e9b354ae726e91b24abea87acc63f9b30ea55e1f65d87cf8ecfba2c69e0cdcdab15d84fa9 0001-v1.1.2-to-66fcde4a.patch
-a29bc04846875ce54f00ce14c11dfc0075ace05acd15c7c95a14c639fd02d6dad7c57f1fbffea85984d13c089d2620e25238ee377041cf15c742b831c8a1e6f2 0002-66fcde4a-to-3fa2eb2a.patch
-c60d044380d1c60739a24c6dc970d416c8921ce6faacc23387a375b1180809b5b964f0b0b1a4c5039d0607a764ed8d503edf6bc7399ec589fafa2074e388d4a9 0003-3fa2eb2a-to-70d9c303.patch
+sha512sums="c580c700d609eced15dc398ff6dcbc2e38fab24eaa5ea80a58c3d41d9f749579cce328bbad149f2b5975533d6ec051e6cc08be3bea4d65e143fc850745bf24c2 musl-1.1.3.tar.gz
dad965258daf69371b844f76bfe5a914b0eca0ca76f3fc340b8fd7acf598b5f87bbe6d68b1f43ed0293ee0ed3bfd85d5173ccc169aa6265646248d5b8a906708 1001-add-basic-dns-record-parsing-functions.patch
72cf33738d2cf31f6ec02312bc494d754c17470b519172bb8bd7e2e29ac3b119023088a2b3fbc0dbc2fddd0078ccbae62096106cae361f8c31d6a9950043af25 1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
33e13d2242063f3dc9ec199ae9528e469a52ccae4d3726faa3c866e0c7dcf546f69294f9c00307324cee05fd965f84350ae100b8b1138f9d9c8c916de04ab0d1 ldconfig