aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2014-04-16 12:04:52 +0300
committerTimo Teräs <timo.teras@iki.fi>2014-04-16 12:05:49 +0300
commit38be4b4d0ceb6e213d6f69815d5074230f1d42ba (patch)
tree879db3b0b0a16ff8d241f8eacd76d1441369306b /main/musl
parentb8c8f0500d4176ef0c63c5cb99a90bf707fb52d3 (diff)
downloadaports-38be4b4d0ceb6e213d6f69815d5074230f1d42ba.tar.bz2
aports-38be4b4d0ceb6e213d6f69815d5074230f1d42ba.tar.xz
main/musl: upgrade to 1.1.0
Diffstat (limited to 'main/musl')
-rw-r--r--main/musl/0001-v1.0.0-to-2b74315d.patch810
-rw-r--r--main/musl/0002-2b74315d-to-b9b2db2f.patch457
-rw-r--r--main/musl/0003-b9b2db2f-to-e94d0692.patch166
-rw-r--r--main/musl/0004-e94d0692-to-83c98aac.patch59
-rw-r--r--main/musl/APKBUILD27
5 files changed, 5 insertions, 1514 deletions
diff --git a/main/musl/0001-v1.0.0-to-2b74315d.patch b/main/musl/0001-v1.0.0-to-2b74315d.patch
deleted file mode 100644
index 57ca3e469c..0000000000
--- a/main/musl/0001-v1.0.0-to-2b74315d.patch
+++ /dev/null
@@ -1,810 +0,0 @@
-git diff v1.0.0...2b74315d8a31ad8fbcd369116c82e055e0ec3fb7
-
-diff --git a/src/conf/confstr.c b/src/conf/confstr.c
-index 4332f72..6e9c23a 100644
---- a/src/conf/confstr.c
-+++ b/src/conf/confstr.c
-@@ -13,5 +13,5 @@ size_t confstr(int name, char *buf, size_t len)
- }
- // snprintf is overkill but avoid wasting code size to implement
- // this completely useless function and its truncation semantics
-- return snprintf(buf, len, "%s", s);
-+ return snprintf(buf, len, "%s", s) + 1;
- }
-diff --git a/src/env/__init_security.c b/src/env/__init_security.c
-index 6204c5e..da5ae94 100644
---- a/src/env/__init_security.c
-+++ b/src/env/__init_security.c
-@@ -15,9 +15,7 @@ void __init_security(size_t *aux)
- struct pollfd pfd[3] = { {.fd=0}, {.fd=1}, {.fd=2} };
- int i;
-
--#ifndef SHARED
- __init_ssp((void *)aux[AT_RANDOM]);
--#endif
-
- if (aux[AT_UID]==aux[AT_EUID] && aux[AT_GID]==aux[AT_EGID]
- && !aux[AT_SECURE]) return;
-diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c
-index 5c17681..8ac0036 100644
---- a/src/env/__init_tls.c
-+++ b/src/env/__init_tls.c
-@@ -5,9 +5,30 @@
- #include "pthread_impl.h"
- #include "libc.h"
- #include "atomic.h"
-+#include "syscall.h"
-+
-+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. */
-+ libc.has_thread_pointer = 1;
-+ libc.can_do_threads = 1;
-+ return 0;
-+}
-
- #ifndef SHARED
-
-+static long long builtin_tls[(sizeof(struct pthread) + 64)/sizeof(long long)];
-+
- struct tls_image {
- void *image;
- size_t len, size, align;
-@@ -61,10 +82,11 @@ typedef Elf64_Phdr Phdr;
-
- void __init_tls(size_t *aux)
- {
-- unsigned char *p, *mem;
-+ unsigned char *p;
- size_t n;
- Phdr *phdr, *tls_phdr=0;
- size_t base = 0;
-+ void *mem;
-
- libc.tls_size = sizeof(struct pthread);
-
-@@ -75,21 +97,38 @@ void __init_tls(size_t *aux)
- if (phdr->p_type == PT_TLS)
- tls_phdr = phdr;
- }
-- if (!tls_phdr) return;
-
-- T.image = (void *)(base + tls_phdr->p_vaddr);
-- T.len = tls_phdr->p_filesz;
-- T.size = tls_phdr->p_memsz;
-- T.align = tls_phdr->p_align;
-+ if (tls_phdr) {
-+ T.image = (void *)(base + tls_phdr->p_vaddr);
-+ T.len = tls_phdr->p_filesz;
-+ T.size = tls_phdr->p_memsz;
-+ T.align = tls_phdr->p_align;
-+ }
-
- T.size += (-T.size - (uintptr_t)T.image) & (T.align-1);
- if (T.align < 4*sizeof(size_t)) T.align = 4*sizeof(size_t);
-
- libc.tls_size = 2*sizeof(void *)+T.size+T.align+sizeof(struct pthread);
-
-- mem = __mmap(0, libc.tls_size, PROT_READ|PROT_WRITE,
-- MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
-- if (!__install_initial_tls(__copy_tls(mem))) a_crash();
-+ if (libc.tls_size > sizeof builtin_tls) {
-+ mem = (void *)__syscall(
-+#ifdef SYS_mmap2
-+ SYS_mmap2,
-+#else
-+ SYS_mmap,
-+#endif
-+ 0, libc.tls_size, PROT_READ|PROT_WRITE,
-+ MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
-+ /* -4095...-1 cast to void * will crash on dereference anyway,
-+ * so don't bloat the init code checking for error codes and
-+ * explicitly calling a_crash(). */
-+ } else {
-+ mem = builtin_tls;
-+ }
-+
-+ /* Failure to initialize thread pointer is fatal if TLS is used. */
-+ if (__init_tp(__copy_tls(mem)) < 0 && tls_phdr)
-+ a_crash();
- }
- #else
- void __init_tls(size_t *auxv) { }
-diff --git a/src/env/__stack_chk_fail.c b/src/env/__stack_chk_fail.c
-index daa1b07..87ac473 100644
---- a/src/env/__stack_chk_fail.c
-+++ b/src/env/__stack_chk_fail.c
-@@ -1,18 +1,16 @@
- #include <string.h>
- #include <stdint.h>
- #include "pthread_impl.h"
--#include "atomic.h"
-
- uintptr_t __stack_chk_guard;
-
- void __init_ssp(void *entropy)
- {
-- pthread_t self = __pthread_self_init();
-- uintptr_t canary;
-- if (entropy) memcpy(&canary, entropy, sizeof canary);
-- else canary = (uintptr_t)&canary * 1103515245;
-- a_cas_l(&__stack_chk_guard, 0, canary);
-- self->canary = __stack_chk_guard;
-+ if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t));
-+ else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245;
-+
-+ if (libc.has_thread_pointer)
-+ __pthread_self()->canary = __stack_chk_guard;
- }
-
- void __stack_chk_fail(void)
-diff --git a/src/errno/__errno_location.c b/src/errno/__errno_location.c
-index 3e92d7c..8419107 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.main_thread) return __pthread_self()->errno_ptr;
-+ if (libc.has_thread_pointer) return __pthread_self()->errno_ptr;
- return &e;
- }
-diff --git a/src/internal/libc.h b/src/internal/libc.h
-index d625b56..fb4d9bc 100644
---- a/src/internal/libc.h
-+++ b/src/internal/libc.h
-@@ -6,12 +6,12 @@
- #include <limits.h>
-
- struct __libc {
-- void *main_thread;
-+ int has_thread_pointer;
-+ int can_do_threads;
- int threaded;
- int secure;
- size_t *auxv;
- volatile int threads_minus_1;
-- int canceldisable;
- FILE *ofl_head;
- int ofl_lock[2];
- size_t tls_size;
-diff --git a/src/internal/syscall_ret.c b/src/internal/syscall_ret.c
-index d99f4a5..a3f4713 100644
---- a/src/internal/syscall_ret.c
-+++ b/src/internal/syscall_ret.c
-@@ -1,4 +1,5 @@
- #include <errno.h>
-+#include "syscall.h"
-
- long __syscall_ret(unsigned long r)
- {
-diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
-index a1bdf0f..1517281 100644
---- a/src/ldso/dynlink.c
-+++ b/src/ldso/dynlink.c
-@@ -56,6 +56,7 @@ struct dso {
-
- Phdr *phdr;
- int phnum;
-+ size_t phentsize;
- int refcnt;
- Sym *syms;
- uint32_t *hashtab;
-@@ -74,6 +75,7 @@ struct dso {
- char *rpath_orig, *rpath;
- void *tls_image;
- size_t tls_len, tls_size, tls_align, tls_id, tls_offset;
-+ size_t relro_start, relro_end;
- void **new_dtv;
- unsigned char *new_tls;
- int new_dtv_idx, new_tls_idx;
-@@ -89,8 +91,7 @@ struct symdef {
-
- #include "reloc.h"
-
--void __init_ssp(size_t *);
--void *__install_initial_tls(void *);
-+int __init_tp(void *);
- void __init_libc(char **, char *);
-
- const char *__libc_get_version(void);
-@@ -98,7 +99,6 @@ const char *__libc_get_version(void);
- static struct dso *head, *tail, *ldso, *fini_head;
- static char *env_path, *sys_path;
- static unsigned long long gencnt;
--static int ssp_used;
- static int runtime;
- static int ldd_mode;
- static int ldso_fail;
-@@ -108,6 +108,7 @@ static pthread_rwlock_t lock;
- static struct debug debug;
- static size_t tls_cnt, tls_offset, tls_align = 4*sizeof(size_t);
- static pthread_mutex_t init_fini_lock = { ._m_type = PTHREAD_MUTEX_RECURSIVE };
-+static long long builtin_tls[(sizeof(struct pthread) + 64)/sizeof(long long)];
-
- struct debug *_dl_debug_addr = &debug;
-
-@@ -198,13 +199,6 @@ static struct symdef find_sym(struct dso *dso, const char *s, int need_def)
- {
- uint32_t h = 0, gh = 0;
- struct symdef def = {0};
-- if (dso->ghashtab) {
-- gh = gnu_hash(s);
-- if (gh == 0x1f4039c9 && !strcmp(s, "__stack_chk_fail")) ssp_used = 1;
-- } else {
-- h = sysv_hash(s);
-- if (h == 0x595a4cc && !strcmp(s, "__stack_chk_fail")) ssp_used = 1;
-- }
- for (; dso; dso=dso->next) {
- Sym *sym;
- if (!dso->global) continue;
-@@ -280,27 +274,32 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
- * and "donate" them to the heap by setting up minimal malloc
- * structures and then freeing them. */
-
--static void reclaim(unsigned char *base, size_t start, size_t end)
-+static void reclaim(struct dso *dso, size_t start, size_t end)
- {
- size_t *a, *z;
-+ if (start >= dso->relro_start && start < dso->relro_end) start = dso->relro_end;
-+ if (end >= dso->relro_start && end < dso->relro_end) end = dso->relro_start;
- start = start + 6*sizeof(size_t)-1 & -4*sizeof(size_t);
- end = (end & -4*sizeof(size_t)) - 2*sizeof(size_t);
- if (start>end || end-start < 4*sizeof(size_t)) return;
-- a = (size_t *)(base + start);
-- z = (size_t *)(base + end);
-+ a = (size_t *)(dso->base + start);
-+ z = (size_t *)(dso->base + end);
- a[-2] = 1;
- a[-1] = z[0] = end-start + 2*sizeof(size_t) | 1;
- z[1] = 1;
- free(a);
- }
-
--static void reclaim_gaps(unsigned char *base, Phdr *ph, size_t phent, size_t phcnt)
-+static void reclaim_gaps(struct dso *dso)
- {
-- for (; phcnt--; ph=(void *)((char *)ph+phent)) {
-+ Phdr *ph = dso->phdr;
-+ size_t phcnt = dso->phnum;
-+
-+ for (; phcnt--; ph=(void *)((char *)ph+dso->phentsize)) {
- if (ph->p_type!=PT_LOAD) continue;
- if ((ph->p_flags&(PF_R|PF_W))!=(PF_R|PF_W)) continue;
-- reclaim(base, ph->p_vaddr & -PAGE_SIZE, ph->p_vaddr);
-- reclaim(base, ph->p_vaddr+ph->p_memsz,
-+ reclaim(dso, ph->p_vaddr & -PAGE_SIZE, ph->p_vaddr);
-+ reclaim(dso, ph->p_vaddr+ph->p_memsz,
- ph->p_vaddr+ph->p_memsz+PAGE_SIZE-1 & -PAGE_SIZE);
- }
- }
-@@ -343,13 +342,16 @@ static void *map_library(int fd, struct dso *dso)
- ph = ph0 = (void *)((char *)buf + eh->e_phoff);
- }
- for (i=eh->e_phnum; i; i--, ph=(void *)((char *)ph+eh->e_phentsize)) {
-- if (ph->p_type == PT_DYNAMIC)
-+ if (ph->p_type == PT_DYNAMIC) {
- dyn = ph->p_vaddr;
-- if (ph->p_type == PT_TLS) {
-+ } else if (ph->p_type == PT_TLS) {
- tls_image = ph->p_vaddr;
- dso->tls_align = ph->p_align;
- dso->tls_len = ph->p_filesz;
- dso->tls_size = ph->p_memsz;
-+ } else if (ph->p_type == PT_GNU_RELRO) {
-+ dso->relro_start = ph->p_vaddr & -PAGE_SIZE;
-+ dso->relro_end = (ph->p_vaddr + ph->p_memsz) & -PAGE_SIZE;
- }
- if (ph->p_type != PT_LOAD) continue;
- if (ph->p_vaddr < addr_min) {
-@@ -393,6 +395,7 @@ static void *map_library(int fd, struct dso *dso)
- dso->phdr = (void *)(base + ph->p_vaddr
- + (eh->e_phoff-ph->p_offset));
- dso->phnum = eh->e_phnum;
-+ dso->phentsize = eh->e_phentsize;
- }
- /* Reuse the existing mapping for the lowest-address LOAD */
- if ((ph->p_vaddr & -PAGE_SIZE) == addr_min) continue;
-@@ -418,12 +421,12 @@ static void *map_library(int fd, struct dso *dso)
- goto error;
- break;
- }
-- if (!runtime) reclaim_gaps(base, ph0, eh->e_phentsize, eh->e_phnum);
- dso->map = map;
- dso->map_len = map_len;
- dso->base = base;
- dso->dynv = (void *)(base+dyn);
- if (dso->tls_size) dso->tls_image = (void *)(base+tls_image);
-+ if (!runtime) reclaim_gaps(dso);
- free(allocated_buf);
- return map;
- noexec:
-@@ -673,9 +676,10 @@ static struct dso *load_library(const char *name, struct dso *needed_by)
- /* Add a shortname only if name arg was not an explicit pathname. */
- if (pathname != name) p->shortname = strrchr(p->name, '/')+1;
- if (p->tls_image) {
-- if (runtime && !__pthread_self_init()) {
-+ if (runtime && !libc.has_thread_pointer) {
- munmap(map, p->map_len);
- free(p);
-+ errno = ENOSYS;
- return 0;
- }
- p->tls_id = ++tls_cnt;
-@@ -764,22 +768,32 @@ static void reloc_all(struct dso *p)
- 2+(dyn[DT_PLTREL]==DT_RELA));
- do_relocs(p, (void *)(p->base+dyn[DT_REL]), dyn[DT_RELSZ], 2);
- do_relocs(p, (void *)(p->base+dyn[DT_RELA]), dyn[DT_RELASZ], 3);
-+
-+ 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 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;
- }
- }
-
--static size_t find_dyn(Phdr *ph, size_t cnt, size_t stride)
-+static void kernel_mapped_dso(struct dso *p)
- {
-- for (; cnt--; ph = (void *)((char *)ph + stride))
-- if (ph->p_type == PT_DYNAMIC)
-- return ph->p_vaddr;
-- return 0;
--}
--
--static void find_map_range(Phdr *ph, size_t cnt, size_t stride, struct dso *p)
--{
-- size_t min_addr = -1, max_addr = 0;
-- for (; cnt--; ph = (void *)((char *)ph + stride)) {
-+ size_t min_addr = -1, max_addr = 0, cnt;
-+ Phdr *ph = p->phdr;
-+ for (cnt = p->phnum; cnt--; ph = (void *)((char *)ph + p->phentsize)) {
-+ if (ph->p_type == PT_DYNAMIC) {
-+ p->dynv = (void *)(p->base + ph->p_vaddr);
-+ } else if (ph->p_type == PT_GNU_RELRO) {
-+ p->relro_start = ph->p_vaddr & -PAGE_SIZE;
-+ p->relro_end = (ph->p_vaddr + ph->p_memsz) & -PAGE_SIZE;
-+ }
- if (ph->p_type != PT_LOAD) continue;
- if (ph->p_vaddr < min_addr)
- min_addr = ph->p_vaddr;
-@@ -790,6 +804,7 @@ static void find_map_range(Phdr *ph, size_t cnt, size_t stride, struct dso *p)
- max_addr = (max_addr + PAGE_SIZE-1) & -PAGE_SIZE;
- p->map = p->base + min_addr;
- p->map_len = max_addr - min_addr;
-+ p->kernel_mapped = 1;
- }
-
- static void do_fini()
-@@ -866,10 +881,13 @@ void *__copy_tls(unsigned char *mem)
- pthread_t td;
- struct dso *p;
-
-- if (!tls_cnt) return mem;
--
- void **dtv = (void *)mem;
- dtv[0] = (void *)tls_cnt;
-+ if (!tls_cnt) {
-+ td = (void *)(dtv+1);
-+ td->dtv = dtv;
-+ return td;
-+ }
-
- #ifdef TLS_ABOVE_TP
- mem += sizeof(void *) * (tls_cnt+1);
-@@ -962,6 +980,7 @@ void *__dynlink(int argc, char **argv)
- size_t vdso_base;
- size_t *auxv;
- char **envp = argv+argc+1;
-+ void *initial_tls;
-
- /* Find aux vector just past environ[] */
- for (i=argc+1; argv[i]; i++)
-@@ -996,13 +1015,11 @@ void *__dynlink(int argc, char **argv)
- lib->base = (void *)aux[AT_BASE];
- lib->name = lib->shortname = "libc.so";
- lib->global = 1;
-- lib->kernel_mapped = 1;
- ehdr = (void *)lib->base;
- lib->phnum = ehdr->e_phnum;
- lib->phdr = (void *)(aux[AT_BASE]+ehdr->e_phoff);
-- find_map_range(lib->phdr, ehdr->e_phnum, ehdr->e_phentsize, lib);
-- lib->dynv = (void *)(lib->base + find_dyn(lib->phdr,
-- ehdr->e_phnum, ehdr->e_phentsize));
-+ lib->phentsize = ehdr->e_phentsize;
-+ kernel_mapped_dso(lib);
- decode_dyn(lib);
-
- if (aux[AT_PHDR]) {
-@@ -1011,6 +1028,7 @@ void *__dynlink(int argc, char **argv)
- /* Find load address of the main program, via AT_PHDR vs PT_PHDR. */
- app->phdr = phdr = (void *)aux[AT_PHDR];
- app->phnum = aux[AT_PHNUM];
-+ app->phentsize = aux[AT_PHENT];
- for (i=aux[AT_PHNUM]; i; i--, phdr=(void *)((char *)phdr + aux[AT_PHENT])) {
- if (phdr->p_type == PT_PHDR)
- app->base = (void *)(aux[AT_PHDR] - phdr->p_vaddr);
-@@ -1030,11 +1048,7 @@ void *__dynlink(int argc, char **argv)
- app->name = (char *)aux[AT_EXECFN];
- else
- app->name = argv[0];
-- app->kernel_mapped = 1;
-- app->dynv = (void *)(app->base + find_dyn(
-- (void *)aux[AT_PHDR], aux[AT_PHNUM], aux[AT_PHENT]));
-- find_map_range((void *)aux[AT_PHDR],
-- aux[AT_PHNUM], aux[AT_PHENT], app);
-+ kernel_mapped_dso(app);
- } else {
- int fd;
- char *ldname = argv[0];
-@@ -1100,6 +1114,7 @@ void *__dynlink(int argc, char **argv)
- ehdr = (void *)vdso_base;
- vdso->phdr = phdr = (void *)(vdso_base + ehdr->e_phoff);
- vdso->phnum = ehdr->e_phnum;
-+ vdso->phentsize = ehdr->e_phentsize;
- for (i=ehdr->e_phnum; i; i--, phdr=(void *)((char *)phdr + ehdr->e_phentsize)) {
- if (phdr->p_type == PT_DYNAMIC)
- vdso->dynv = (void *)(vdso_base + phdr->p_offset);
-@@ -1127,10 +1142,8 @@ void *__dynlink(int argc, char **argv)
- /* PAST THIS POINT, ALL LIBC INTERFACES ARE FULLY USABLE. */
-
- /* Donate unused parts of app and library mapping to malloc */
-- reclaim_gaps(app->base, (void *)aux[AT_PHDR], aux[AT_PHENT], aux[AT_PHNUM]);
-- ehdr = (void *)lib->base;
-- reclaim_gaps(lib->base, (void *)(lib->base+ehdr->e_phoff),
-- ehdr->e_phentsize, ehdr->e_phnum);
-+ reclaim_gaps(app);
-+ reclaim_gaps(lib);
-
- /* Load preload/needed libraries, add their symbols to the global
- * namespace, and perform all remaining relocations. The main
-@@ -1140,19 +1153,29 @@ void *__dynlink(int argc, char **argv)
- load_deps(app);
- make_global(app);
-
-+#ifndef DYNAMIC_IS_RO
-+ for (i=0; app->dynv[i]; i+=2)
-+ if (app->dynv[i]==DT_DEBUG)
-+ app->dynv[i+1] = (size_t)&debug;
-+#endif
-+
- reloc_all(app->next);
- reloc_all(app);
-
- update_tls_size();
-- if (tls_cnt) {
-- void *mem = mmap(0, libc.tls_size, PROT_READ|PROT_WRITE,
-- MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
-- if (mem==MAP_FAILED ||
-- !__install_initial_tls(__copy_tls(mem))) {
-+ if (libc.tls_size > sizeof builtin_tls) {
-+ initial_tls = calloc(libc.tls_size, 1);
-+ if (!initial_tls) {
- dprintf(2, "%s: Error getting %zu bytes thread-local storage: %m\n",
- argv[0], libc.tls_size);
- _exit(127);
- }
-+ } else {
-+ initial_tls = builtin_tls;
-+ }
-+ if (__init_tp(__copy_tls(initial_tls)) < 0 && tls_cnt) {
-+ dprintf(2, "%s: Thread-local storage not supported by kernel.\n", argv[0]);
-+ _exit(127);
- }
-
- if (ldso_fail) _exit(127);
-@@ -1164,11 +1187,6 @@ void *__dynlink(int argc, char **argv)
- * all memory used by the dynamic linker. */
- runtime = 1;
-
--#ifndef DYNAMIC_IS_RO
-- for (i=0; app->dynv[i]; i+=2)
-- if (app->dynv[i]==DT_DEBUG)
-- app->dynv[i+1] = (size_t)&debug;
--#endif
- debug.ver = 1;
- debug.bp = _dl_debug_state;
- debug.head = head;
-@@ -1176,7 +1194,6 @@ void *__dynlink(int argc, char **argv)
- debug.state = 0;
- _dl_debug_state();
-
-- if (ssp_used) __init_ssp((void *)aux[AT_RANDOM]);
- __init_libc(envp, argv[0]);
- atexit(do_fini);
- errno = 0;
-@@ -1258,9 +1275,6 @@ void *dlopen(const char *file, int mode)
- }
-
- update_tls_size();
--
-- if (ssp_used) __init_ssp(libc.auxv);
--
- _dl_debug_state();
- orig_tail = tail;
- end:
-diff --git a/src/process/fork.c b/src/process/fork.c
-index 1a82f42..864c7d7 100644
---- a/src/process/fork.c
-+++ b/src/process/fork.c
-@@ -17,12 +17,11 @@ pid_t fork(void)
- __fork_handler(-1);
- __block_all_sigs(&set);
- ret = syscall(SYS_fork);
-- if (libc.main_thread && !ret) {
-+ if (libc.has_thread_pointer && !ret) {
- pthread_t self = __pthread_self();
-- self->tid = self->pid = syscall(SYS_getpid);
-+ self->tid = self->pid = __syscall(SYS_getpid);
- memset(&self->robust_list, 0, sizeof self->robust_list);
- libc.threads_minus_1 = 0;
-- libc.main_thread = self;
- }
- __restore_sigs(&set);
- __fork_handler(!ret);
-diff --git a/src/signal/sigaction.c b/src/signal/sigaction.c
-index f7ff4a6..d5f4774 100644
---- a/src/signal/sigaction.c
-+++ b/src/signal/sigaction.c
-@@ -8,9 +8,7 @@
-
- void __restore(), __restore_rt();
-
--static pthread_t dummy(void) { return 0; }
--weak_alias(dummy, __pthread_self_def);
--
-+static int unmask_done;
- static unsigned long handler_set[_NSIG/(8*sizeof(long))];
-
- void __get_handler_set(sigset_t *set)
-@@ -29,7 +27,20 @@ int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigact
- if ((uintptr_t)sa->sa_handler > 1UL) {
- a_or_l(handler_set+(sig-1)/(8*sizeof(long)),
- 1UL<<(sig-1)%(8*sizeof(long)));
-- __pthread_self_def();
-+
-+ /* If pthread_create has not yet been called,
-+ * implementation-internal signals might not
-+ * yet have been unblocked. They must be
-+ * unblocked before any signal handler is
-+ * installed, so that an application cannot
-+ * receive an illegal sigset_t (with them
-+ * blocked) as part of the ucontext_t passed
-+ * to the signal handler. */
-+ if (!libc.threaded && !unmask_done) {
-+ __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK,
-+ SIGPT_SET, 0, _NSIG/8);
-+ unmask_done = 1;
-+ }
- }
- ksa.handler = sa->sa_handler;
- ksa.flags = sa->sa_flags | SA_RESTORER;
-diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c
-index 05e56f9..6cd7b07 100644
---- a/src/stdio/__stdio_read.c
-+++ b/src/stdio/__stdio_read.c
-@@ -16,13 +16,9 @@ size_t __stdio_read(FILE *f, unsigned char *buf, size_t len)
- };
- ssize_t cnt;
-
-- if (libc.main_thread) {
-- pthread_cleanup_push(cleanup, f);
-- cnt = syscall_cp(SYS_readv, f->fd, iov, 2);
-- pthread_cleanup_pop(0);
-- } else {
-- cnt = syscall(SYS_readv, f->fd, iov, 2);
-- }
-+ pthread_cleanup_push(cleanup, f);
-+ cnt = syscall_cp(SYS_readv, f->fd, iov, 2);
-+ pthread_cleanup_pop(0);
- if (cnt <= 0) {
- f->flags |= F_EOF ^ ((F_ERR^F_EOF) & cnt);
- f->rpos = f->rend = 0;
-diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c
-index e52e91a..8c89389 100644
---- a/src/stdio/__stdio_write.c
-+++ b/src/stdio/__stdio_write.c
-@@ -19,13 +19,9 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len)
- int iovcnt = 2;
- ssize_t cnt;
- for (;;) {
-- if (libc.main_thread) {
-- pthread_cleanup_push(cleanup, f);
-- cnt = syscall_cp(SYS_writev, f->fd, iov, iovcnt);
-- pthread_cleanup_pop(0);
-- } else {
-- cnt = syscall(SYS_writev, f->fd, iov, iovcnt);
-- }
-+ pthread_cleanup_push(cleanup, f);
-+ cnt = syscall_cp(SYS_writev, f->fd, iov, iovcnt);
-+ pthread_cleanup_pop(0);
- if (cnt == rem) {
- f->wend = f->buf + f->buf_size;
- f->wpos = f->wbase = f->buf;
-diff --git a/src/thread/cancel_impl.c b/src/thread/cancel_impl.c
-index c835813..525d290 100644
---- a/src/thread/cancel_impl.c
-+++ b/src/thread/cancel_impl.c
-@@ -20,7 +20,7 @@ long (__syscall_cp)(syscall_arg_t nr,
- pthread_t self;
- long r;
-
-- if (!libc.main_thread || (self = __pthread_self())->canceldisable)
-+ if (!libc.has_thread_pointer || (self = __pthread_self())->canceldisable)
- return __syscall(nr, u, v, w, x, y, z);
-
- r = __syscall_cp_asm(&self->cancel, nr, u, v, w, x, y, z);
-@@ -57,6 +57,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();
- if (self->cancel && !self->canceldisable)
- __cancel();
-diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
-index ee6c31c..e0b5ef1 100644
---- a/src/thread/pthread_create.c
-+++ b/src/thread/pthread_create.c
-@@ -77,6 +77,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();
- cb->__next = self->cancelbuf;
- self->cancelbuf = cb;
-@@ -84,6 +85,7 @@ void __do_cleanup_push(struct __ptcb *cb)
-
- void __do_cleanup_pop(struct __ptcb *cb)
- {
-+ if (!libc.has_thread_pointer) return;
- __pthread_self()->cancelbuf = cb->__next;
- }
-
-@@ -110,6 +112,8 @@ static int start(void *p)
- /* pthread_key_create.c overrides this */
- static const size_t dummy = 0;
- weak_alias(dummy, __pthread_tsd_size);
-+static void *const dummy_tsd[1] = { 0 };
-+weak_alias(dummy_tsd, __pthread_tsd_main);
-
- static FILE *const dummy_file = 0;
- weak_alias(dummy_file, __stdin_used);
-@@ -127,7 +131,7 @@ int pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attrp
- {
- int ret;
- size_t size, guard;
-- struct pthread *self = pthread_self(), *new;
-+ struct pthread *self, *new;
- unsigned char *map = 0, *stack = 0, *tsd = 0, *stack_limit;
- unsigned flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND
- | CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS
-@@ -135,13 +139,16 @@ int pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attrp
- int do_sched = 0;
- pthread_attr_t attr = {0};
-
-- if (!self) return ENOSYS;
-+ if (!libc.can_do_threads) return ENOSYS;
-+ self = __pthread_self();
- if (!libc.threaded) {
- for (FILE *f=libc.ofl_head; f; f=f->next)
- init_file_lock(f);
- init_file_lock(__stdin_used);
- init_file_lock(__stdout_used);
- init_file_lock(__stderr_used);
-+ __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK, SIGPT_SET, 0, _NSIG/8);
-+ self->tsd = (void **)__pthread_tsd_main;
- libc.threaded = 1;
- }
- if (attrp) attr = *attrp;
-diff --git a/src/thread/pthread_key_create.c b/src/thread/pthread_key_create.c
-index c29935c..ef8a755 100644
---- a/src/thread/pthread_key_create.c
-+++ b/src/thread/pthread_key_create.c
-@@ -14,7 +14,13 @@ int pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
- unsigned i = (uintptr_t)&k / 16 % PTHREAD_KEYS_MAX;
- unsigned j = i;
-
-- __pthread_self_init();
-+ if (libc.has_thread_pointer) {
-+ pthread_t self = __pthread_self();
-+ /* This can only happen in the main thread before
-+ * pthread_create has been called. */
-+ if (!self->tsd) self->tsd = __pthread_tsd_main;
-+ }
-+
- if (!dtor) dtor = nodtor;
- do {
- if (!a_cas_p(keys+j, 0, (void *)dtor)) {
-diff --git a/src/thread/pthread_self.c b/src/thread/pthread_self.c
-index aed4b5f..5f9e651 100644
---- a/src/thread/pthread_self.c
-+++ b/src/thread/pthread_self.c
-@@ -1,45 +1,6 @@
- #include "pthread_impl.h"
-
--static struct pthread *main_thread = &(struct pthread){0};
--
--/* pthread_key_create.c overrides this */
--static const void *dummy[1] = { 0 };
--weak_alias(dummy, __pthread_tsd_main);
--
--static int init_main_thread()
--{
-- __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK,
-- SIGPT_SET, 0, _NSIG/8);
-- if (__set_thread_area(TP_ADJ(main_thread)) < 0) return -1;
-- main_thread->canceldisable = libc.canceldisable;
-- main_thread->tsd = (void **)__pthread_tsd_main;
-- main_thread->errno_ptr = __errno_location();
-- main_thread->self = main_thread;
-- main_thread->tid = main_thread->pid =
-- __syscall(SYS_set_tid_address, &main_thread->tid);
-- if (!main_thread->dtv)
-- main_thread->dtv = (void *)dummy;
-- libc.main_thread = main_thread;
-- return 0;
--}
--
--pthread_t __pthread_self_def()
-+pthread_t pthread_self()
- {
-- static int init, failed;
-- if (!init) {
-- if (failed) return 0;
-- if (init_main_thread() < 0) failed = 1;
-- if (failed) return 0;
-- init = 1;
-- }
- return __pthread_self();
- }
--
--weak_alias(__pthread_self_def, pthread_self);
--weak_alias(__pthread_self_def, __pthread_self_init);
--
--void *__install_initial_tls(void *p)
--{
-- main_thread = p;
-- return __pthread_self_def();
--}
-diff --git a/src/thread/pthread_setcancelstate.c b/src/thread/pthread_setcancelstate.c
-index ba2b231..060bcdc 100644
---- a/src/thread/pthread_setcancelstate.c
-+++ b/src/thread/pthread_setcancelstate.c
-@@ -3,13 +3,9 @@
- int pthread_setcancelstate(int new, int *old)
- {
- if (new > 1U) return EINVAL;
-- if (libc.main_thread) {
-- struct pthread *self = __pthread_self();
-- if (old) *old = self->canceldisable;
-- self->canceldisable = new;
-- } else {
-- if (old) *old = libc.canceldisable;
-- libc.canceldisable = new;
-- }
-+ if (!libc.has_thread_pointer) return ENOSYS;
-+ struct pthread *self = __pthread_self();
-+ if (old) *old = self->canceldisable;
-+ self->canceldisable = new;
- return 0;
- }
diff --git a/main/musl/0002-2b74315d-to-b9b2db2f.patch b/main/musl/0002-2b74315d-to-b9b2db2f.patch
deleted file mode 100644
index 0d3a49c49e..0000000000
--- a/main/musl/0002-2b74315d-to-b9b2db2f.patch
+++ /dev/null
@@ -1,457 +0,0 @@
-git diff 2b74315d8a31ad8fbcd369116c82e055e0ec3fb7...b9b2db2f374bce907fa5015c9cf63205054f2356
-
-diff --git a/arch/microblaze/syscall_arch.h b/arch/microblaze/syscall_arch.h
-index 70217ff..cab4607 100644
---- a/arch/microblaze/syscall_arch.h
-+++ b/arch/microblaze/syscall_arch.h
-@@ -13,7 +13,7 @@ static __inline long __syscall0(long n)
- register unsigned long r3 __asm__("r3");
- __asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
- : "r"(r12)
-- : "memory");
-+ : "memory", "r4");
- return r3;
- }
-
-@@ -24,7 +24,7 @@ static inline long __syscall1(long n, long a)
- register unsigned long r5 __asm__("r5") = a;
- __asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
- : "r"(r12), "r"(r5)
-- : "memory");
-+ : "memory", "r4");
- return r3;
- }
-
-@@ -36,7 +36,7 @@ static inline long __syscall2(long n, long a, long b)
- register unsigned long r6 __asm__("r6") = b;
- __asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
- : "r"(r12), "r"(r5), "r"(r6)
-- : "memory");
-+ : "memory", "r4");
- return r3;
- }
-
-@@ -49,7 +49,7 @@ static inline long __syscall3(long n, long a, long b, long c)
- register unsigned long r7 __asm__("r7") = c;
- __asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
- : "r"(r12), "r"(r5), "r"(r6), "r"(r7)
-- : "memory");
-+ : "memory", "r4");
- return r3;
- }
-
-@@ -63,7 +63,7 @@ static inline long __syscall4(long n, long a, long b, long c, long d)
- register unsigned long r8 __asm__("r8") = d;
- __asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
- : "r"(r12), "r"(r5), "r"(r6), "r"(r7), "r"(r8)
-- : "memory");
-+ : "memory", "r4");
- return r3;
- }
-
-@@ -78,7 +78,7 @@ static inline long __syscall5(long n, long a, long b, long c, long d, long e)
- register unsigned long r9 __asm__("r9") = e;
- __asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
- : "r"(r12), "r"(r5), "r"(r6), "r"(r7), "r"(r8), "r"(r9)
-- : "memory");
-+ : "memory", "r4");
- return r3;
- }
-
-@@ -94,7 +94,7 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
- register unsigned long r10 __asm__("r10") = f;
- __asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
- : "r"(r12), "r"(r5), "r"(r6), "r"(r7), "r"(r8), "r"(r9), "r"(r10)
-- : "memory");
-+ : "memory", "r4");
- return r3;
- }
-
-diff --git a/include/search.h b/include/search.h
-index 27f6107..02e407e 100644
---- a/include/search.h
-+++ b/include/search.h
-@@ -22,6 +22,18 @@ int hcreate(size_t);
- void hdestroy(void);
- ENTRY *hsearch(ENTRY, ACTION);
-
-+#ifdef _GNU_SOURCE
-+struct hsearch_data {
-+ struct __tab *__tab;
-+ unsigned int __unused1;
-+ unsigned int __unused2;
-+};
-+
-+int hcreate_r(size_t, struct hsearch_data *);
-+void hdestroy_r(struct hsearch_data *);
-+int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *);
-+#endif
-+
- void insque(void *, void *);
- void remque(void *);
-
-diff --git a/src/malloc/malloc.c b/src/malloc/malloc.c
-index d6ad904..7932a97 100644
---- a/src/malloc/malloc.c
-+++ b/src/malloc/malloc.c
-@@ -37,6 +37,7 @@ static struct {
- struct bin bins[64];
- int brk_lock[2];
- int free_lock[2];
-+ unsigned mmap_step;
- } mal;
-
-
-@@ -162,7 +163,28 @@ static struct chunk *expand_heap(size_t n)
- new = mal.brk + n + SIZE_ALIGN + PAGE_SIZE - 1 & -PAGE_SIZE;
- n = new - mal.brk;
-
-- if (__brk(new) != new) goto fail;
-+ if (__brk(new) != new) {
-+ size_t min = (size_t)PAGE_SIZE << mal.mmap_step/2;
-+ n += -n & PAGE_SIZE-1;
-+ if (n < min) n = min;
-+ void *area = __mmap(0, n, PROT_READ|PROT_WRITE,
-+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
-+ if (area == MAP_FAILED) goto fail;
-+
-+ mal.mmap_step++;
-+ area = (char *)area + SIZE_ALIGN - OVERHEAD;
-+ w = area;
-+ n -= SIZE_ALIGN;
-+ w->psize = 0 | C_INUSE;
-+ w->csize = n | C_INUSE;
-+ w = NEXT_CHUNK(w);
-+ w->psize = n | C_INUSE;
-+ w->csize = 0 | C_INUSE;
-+
-+ unlock(mal.brk_lock);
-+
-+ return area;
-+ }
-
- w = MEM_TO_CHUNK(new);
- w->psize = n | C_INUSE;
-diff --git a/src/search/hsearch.c b/src/search/hsearch.c
-index 6fe5ced..5c89651 100644
---- a/src/search/hsearch.c
-+++ b/src/search/hsearch.c
-@@ -1,6 +1,8 @@
-+#define _GNU_SOURCE
- #include <stdlib.h>
- #include <string.h>
- #include <search.h>
-+#include "libc.h"
-
- /*
- open addressing hash table with 2^n table size
-@@ -14,14 +16,17 @@ with the posix api items cannot be iterated and length cannot be queried
- #define MINSIZE 8
- #define MAXSIZE ((size_t)-1/2 + 1)
-
--struct elem {
-- ENTRY item;
-- size_t hash;
-+struct __tab {
-+ ENTRY *entries;
-+ size_t mask;
-+ size_t used;
- };
-
--static size_t mask;
--static size_t used;
--static struct elem *tab;
-+static struct hsearch_data htab;
-+
-+int __hcreate_r(size_t, struct hsearch_data *);
-+void __hdestroy_r(struct hsearch_data *);
-+int __hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *);
-
- static size_t keyhash(char *k)
- {
-@@ -33,30 +38,30 @@ static size_t keyhash(char *k)
- return h;
- }
-
--static int resize(size_t nel)
-+static int resize(size_t nel, struct hsearch_data *htab)
- {
- size_t newsize;
- size_t i, j;
-- struct elem *e, *newe;
-- struct elem *oldtab = tab;
-- struct elem *oldend = tab + mask + 1;
-+ ENTRY *e, *newe;
-+ ENTRY *oldtab = htab->__tab->entries;
-+ ENTRY *oldend = htab->__tab->entries + htab->__tab->mask + 1;
-
- if (nel > MAXSIZE)
- nel = MAXSIZE;
- for (newsize = MINSIZE; newsize < nel; newsize *= 2);
-- tab = calloc(newsize, sizeof *tab);
-- if (!tab) {
-- tab = oldtab;
-+ htab->__tab->entries = calloc(newsize, sizeof *htab->__tab->entries);
-+ if (!htab->__tab->entries) {
-+ htab->__tab->entries = oldtab;
- return 0;
- }
-- mask = newsize - 1;
-+ htab->__tab->mask = newsize - 1;
- if (!oldtab)
- return 1;
- for (e = oldtab; e < oldend; e++)
-- if (e->item.key) {
-- for (i=e->hash,j=1; ; i+=j++) {
-- newe = tab + (i & mask);
-- if (!newe->item.key)
-+ if (e->key) {
-+ for (i=keyhash(e->key),j=1; ; i+=j++) {
-+ newe = htab->__tab->entries + (i & htab->__tab->mask);
-+ if (!newe->key)
- break;
- }
- *newe = *e;
-@@ -67,29 +72,22 @@ static int resize(size_t nel)
-
- int hcreate(size_t nel)
- {
-- mask = 0;
-- used = 0;
-- tab = 0;
-- return resize(nel);
-+ return __hcreate_r(nel, &htab);
- }
-
- void hdestroy(void)
- {
-- free(tab);
-- tab = 0;
-- mask = 0;
-- used = 0;
-+ __hdestroy_r(&htab);
- }
-
--static struct elem *lookup(char *key, size_t hash)
-+static ENTRY *lookup(char *key, size_t hash, struct hsearch_data *htab)
- {
- size_t i, j;
-- struct elem *e;
-+ ENTRY *e;
-
- for (i=hash,j=1; ; i+=j++) {
-- e = tab + (i & mask);
-- if (!e->item.key ||
-- (e->hash==hash && strcmp(e->item.key, key)==0))
-+ e = htab->__tab->entries + (i & htab->__tab->mask);
-+ if (!e->key || strcmp(e->key, key) == 0)
- break;
- }
- return e;
-@@ -97,22 +95,60 @@ static struct elem *lookup(char *key, size_t hash)
-
- ENTRY *hsearch(ENTRY item, ACTION action)
- {
-+ ENTRY *e;
-+
-+ __hsearch_r(item, action, &e, &htab);
-+ return e;
-+}
-+
-+int __hcreate_r(size_t nel, struct hsearch_data *htab)
-+{
-+ int r;
-+
-+ htab->__tab = calloc(1, sizeof *htab->__tab);
-+ if (!htab->__tab)
-+ return 0;
-+ r = resize(nel, htab);
-+ if (r == 0) {
-+ free(htab->__tab);
-+ htab->__tab = 0;
-+ }
-+ return r;
-+}
-+weak_alias(__hcreate_r, hcreate_r);
-+
-+void __hdestroy_r(struct hsearch_data *htab)
-+{
-+ if (htab->__tab) free(htab->__tab->entries);
-+ free(htab->__tab);
-+ htab->__tab = 0;
-+}
-+weak_alias(__hdestroy_r, hdestroy_r);
-+
-+int __hsearch_r(ENTRY item, ACTION action, ENTRY **retval, struct hsearch_data *htab)
-+{
- size_t hash = keyhash(item.key);
-- struct elem *e = lookup(item.key, hash);
-+ ENTRY *e = lookup(item.key, hash, htab);
-
-- if (e->item.key)
-- return &e->item;
-- if (action == FIND)
-+ if (e->key) {
-+ *retval = e;
-+ return 1;
-+ }
-+ if (action == FIND) {
-+ *retval = 0;
- return 0;
-- e->item = item;
-- e->hash = hash;
-- if (++used > mask - mask/4) {
-- if (!resize(2*used)) {
-- used--;
-- e->item.key = 0;
-+ }
-+ *e = item;
-+ if (++htab->__tab->used > htab->__tab->mask - htab->__tab->mask/4) {
-+ if (!resize(2*htab->__tab->used, htab)) {
-+ htab->__tab->used--;
-+ e->key = 0;
-+ *retval = 0;
- return 0;
- }
-- e = lookup(item.key, hash);
-+ e = lookup(item.key, hash, htab);
- }
-- return &e->item;
-+ *retval = e;
-+ return 1;
- }
-+weak_alias(__hsearch_r, hsearch_r);
-diff --git a/src/signal/arm/sigsetjmp.s b/src/signal/arm/sigsetjmp.s
-index acb0301..0e7bcd4 100644
---- a/src/signal/arm/sigsetjmp.s
-+++ b/src/signal/arm/sigsetjmp.s
-@@ -1,6 +1,9 @@
- .global sigsetjmp
-+.global __sigsetjmp
- .type sigsetjmp,%function
-+.type __sigsetjmp,%function
- sigsetjmp:
-+__sigsetjmp:
- str a2,[a1,#256]
- tst a2,a2
- beq setjmp
-diff --git a/src/signal/i386/sigsetjmp.s b/src/signal/i386/sigsetjmp.s
-index 06e0a61..91c8c04 100644
---- a/src/signal/i386/sigsetjmp.s
-+++ b/src/signal/i386/sigsetjmp.s
-@@ -1,6 +1,9 @@
- .global sigsetjmp
-+.global __sigsetjmp
- .type sigsetjmp,@function
-+.type __sigsetjmp,@function
- sigsetjmp:
-+__sigsetjmp:
- mov 4(%esp),%eax
- mov 8(%esp),%ecx
- mov %ecx,24(%eax)
-diff --git a/src/signal/microblaze/sigsetjmp.s b/src/signal/microblaze/sigsetjmp.s
-index be869d6..2a23d14 100644
---- a/src/signal/microblaze/sigsetjmp.s
-+++ b/src/signal/microblaze/sigsetjmp.s
-@@ -1,6 +1,9 @@
- .global sigsetjmp
-+.global __sigsetjmp
- .type sigsetjmp,@function
-+.type __sigsetjmp,@function
- sigsetjmp:
-+__sigsetjmp:
- swi r6, r5, 72
- beqi r6, setjmp@PLT
-
-diff --git a/src/signal/mips/sigsetjmp.s b/src/signal/mips/sigsetjmp.s
-index 502e079..133ca77 100644
---- a/src/signal/mips/sigsetjmp.s
-+++ b/src/signal/mips/sigsetjmp.s
-@@ -1,8 +1,11 @@
- .set noreorder
-
- .global sigsetjmp
-+.global __sigsetjmp
- .type sigsetjmp,@function
-+.type __sigsetjmp,@function
- sigsetjmp:
-+__sigsetjmp:
- lui $gp, %hi(_gp_disp)
- addiu $gp, %lo(_gp_disp)
- beq $5, $0, 1f
-diff --git a/src/signal/powerpc/sigsetjmp.s b/src/signal/powerpc/sigsetjmp.s
-index d7d1af3..461b737 100644
---- a/src/signal/powerpc/sigsetjmp.s
-+++ b/src/signal/powerpc/sigsetjmp.s
-@@ -1,6 +1,9 @@
- .global sigsetjmp
-+ .global __sigsetjmp
- .type sigsetjmp,%function
-+ .type __sigsetjmp,%function
- sigsetjmp:
-+__sigsetjmp:
- #int sigsetjmp(sigjmp_buf buf, int save)
- # r3 r4
- #0) store save into buf->__fl
-diff --git a/src/signal/sh/sigsetjmp.s b/src/signal/sh/sigsetjmp.s
-index f6cae80..7951f07 100644
---- a/src/signal/sh/sigsetjmp.s
-+++ b/src/signal/sh/sigsetjmp.s
-@@ -1,6 +1,9 @@
- .global sigsetjmp
--.type sigsetjmp, @function
-+.global __sigsetjmp
-+.type sigsetjmp,@function
-+.type __sigsetjmp,@function
- sigsetjmp:
-+__sigsetjmp:
- mov.l r5, @(36,r4)
- tst r5, r5
- bf 2f
-diff --git a/src/signal/sigsetjmp.c b/src/signal/sigsetjmp.c
-index cb2257f..1bbe1a0 100644
---- a/src/signal/sigsetjmp.c
-+++ b/src/signal/sigsetjmp.c
-@@ -1,5 +1,6 @@
- #include <setjmp.h>
- #include <signal.h>
-+#include "libc.h"
-
- /* !!! This function will not work unless the compiler performs
- * tail call optimization. Machine-specific asm versions should
-@@ -12,3 +13,5 @@ int sigsetjmp(sigjmp_buf buf, int save)
- pthread_sigmask(SIG_SETMASK, 0, (sigset_t *)buf->__ss);
- return setjmp(buf);
- }
-+
-+weak_alias(sigsetjmp, __sigsetjmp);
-diff --git a/src/signal/x32/sigsetjmp.s b/src/signal/x32/sigsetjmp.s
-index dc38f03..17436f0 100644
---- a/src/signal/x32/sigsetjmp.s
-+++ b/src/signal/x32/sigsetjmp.s
-@@ -1,7 +1,10 @@
- /* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
- .global sigsetjmp
-+.global __sigsetjmp
- .type sigsetjmp,@function
-+.type __sigsetjmp,@function
- sigsetjmp:
-+__sigsetjmp:
- andl %esi,%esi
- movq %rsi,64(%rdi)
- jz 1f
-diff --git a/src/signal/x86_64/sigsetjmp.s b/src/signal/x86_64/sigsetjmp.s
-index dc38f03..17436f0 100644
---- a/src/signal/x86_64/sigsetjmp.s
-+++ b/src/signal/x86_64/sigsetjmp.s
-@@ -1,7 +1,10 @@
- /* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
- .global sigsetjmp
-+.global __sigsetjmp
- .type sigsetjmp,@function
-+.type __sigsetjmp,@function
- sigsetjmp:
-+__sigsetjmp:
- andl %esi,%esi
- movq %rsi,64(%rdi)
- jz 1f
diff --git a/main/musl/0003-b9b2db2f-to-e94d0692.patch b/main/musl/0003-b9b2db2f-to-e94d0692.patch
deleted file mode 100644
index c13a5ffc8e..0000000000
--- a/main/musl/0003-b9b2db2f-to-e94d0692.patch
+++ /dev/null
@@ -1,166 +0,0 @@
-diff --git a/arch/arm/atomic.h b/arch/arm/atomic.h
-index 734d287..50ad947 100644
---- a/arch/arm/atomic.h
-+++ b/arch/arm/atomic.h
-@@ -22,7 +22,28 @@ static inline int a_ctz_64(uint64_t x)
- return a_ctz_l(y);
- }
-
-+#if __ARM_ARCH_6__ || __ARM_ARCH_6K__ || __ARM_ARCH_6ZK__ \
-+ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ \
-+ || __ARM_ARCH >= 7
-+static inline int __k_cas(int t, int s, volatile int *p)
-+{
-+ int ret;
-+ __asm__(
-+ " mcr p15,0,r0,c7,c10,5\n"
-+ "1: ldrex %0,%3\n"
-+ " subs %0,%0,%1\n"
-+ " strexeq %0,%2,%3\n"
-+ " teqeq %0,#1\n"
-+ " beq 1b\n"
-+ " mcr p15,0,r0,c7,c10,5\n"
-+ : "=&r"(ret)
-+ : "r"(t), "r"(s), "Q"(*p)
-+ : "memory", "cc" );
-+ return ret;
-+}
-+#else
- #define __k_cas ((int (*)(int, int, volatile int *))0xffff0fc0)
-+#endif
-
- static inline int a_cas(volatile int *p, int t, int s)
- {
-diff --git a/arch/arm/pthread_arch.h b/arch/arm/pthread_arch.h
-index 43a1c01..ec77a83 100644
---- a/arch/arm/pthread_arch.h
-+++ b/arch/arm/pthread_arch.h
-@@ -1,8 +1,22 @@
--typedef char *(*__ptr_func_t)(void) __attribute__((const));
-+#if __ARM_ARCH_6K__ || __ARM_ARCH_6ZK__ \
-+ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ \
-+ || __ARM_ARCH >= 7
-+
-+static inline __attribute__((const)) pthread_t __pthread_self()
-+{
-+ char *p;
-+ __asm__( "mrc p15,0,%0,c13,c0,3" : "=r"(p) );
-+ return (void *)(p+8-sizeof(struct pthread));
-+}
-+
-+#else
-
-+typedef char *(*__ptr_func_t)(void) __attribute__((const));
- #define __pthread_self() \
- ((pthread_t)(((__ptr_func_t)0xffff0fe0)()+8-sizeof(struct pthread)))
-
-+#endif
-+
- #define TLS_ABOVE_TP
- #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) - 8)
-
-diff --git a/include/sys/auxv.h b/include/sys/auxv.h
-new file mode 100644
-index 0000000..6dcf9ad
---- /dev/null
-+++ b/include/sys/auxv.h
-@@ -0,0 +1,16 @@
-+#ifndef _SYS_AUXV_H
-+#define _SYS_AUXV_H
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+#include <elf.h>
-+
-+unsigned long getauxval(unsigned long);
-+
-+#ifdef __cplusplus
-+}
-+#endif
-+
-+#endif
-diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c
-index 8ac0036..89d081e 100644
---- a/src/env/__init_tls.c
-+++ b/src/env/__init_tls.c
-@@ -64,16 +64,6 @@ void *__tls_get_addr(size_t *v)
- return (char *)__pthread_self()->dtv[1]+v[1];
- }
-
--static void *simple(void *p)
--{
-- *(void **)p = p;
-- return __set_thread_area(TP_ADJ(p)) ? 0 : p;
--}
--
--weak_alias(simple, __install_initial_tls);
--
--void *__mmap(void *, size_t, int, int, int, off_t);
--
- #if ULONG_MAX == 0xffffffff
- typedef Elf32_Phdr Phdr;
- #else
-diff --git a/src/env/__libc_start_main.c b/src/env/__libc_start_main.c
-index 73d4932..ac37492 100644
---- a/src/env/__libc_start_main.c
-+++ b/src/env/__libc_start_main.c
-@@ -3,7 +3,6 @@
-
- void __init_tls(size_t *);
- void __init_security(size_t *);
--void __init_ldso_ctors(void);
-
- #ifndef SHARED
- static void dummy() {}
-diff --git a/src/misc/getauxval.c b/src/misc/getauxval.c
-new file mode 100644
-index 0000000..5ac8b3d
---- /dev/null
-+++ b/src/misc/getauxval.c
-@@ -0,0 +1,12 @@
-+#include <sys/auxv.h>
-+#include <errno.h>
-+#include "libc.h"
-+
-+unsigned long getauxval(unsigned long item)
-+{
-+ size_t *auxv = libc.auxv;
-+ for (; *auxv; auxv+=2)
-+ if (*auxv==item) return auxv[1];
-+ errno = ENOENT;
-+ return 0;
-+}
-diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
-index 31c3d5d..f6e7f38 100644
---- a/src/stdio/vfprintf.c
-+++ b/src/stdio/vfprintf.c
-@@ -308,8 +308,8 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
- *d = x % 1000000000;
- carry = x / 1000000000;
- }
-- if (!z[-1] && z>a) z--;
- if (carry) *--a = carry;
-+ while (z>a && !z[-1]) z--;
- e2-=sh;
- }
- while (e2<0) {
-@@ -356,15 +356,15 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
- *d = *d + i;
- while (*d > 999999999) {
- *d--=0;
-+ if (d<a) *--a=0;
- (*d)++;
- }
-- if (d<a) a=d;
- for (i=10, e=9*(r-a); *a>=i; i*=10, e++);
- }
- }
- if (z>d+1) z=d+1;
-- for (; !z[-1] && z>a; z--);
- }
-+ for (; z>a && !z[-1]; z--);
-
- if ((t|32)=='g') {
- if (!p) p++;
diff --git a/main/musl/0004-e94d0692-to-83c98aac.patch b/main/musl/0004-e94d0692-to-83c98aac.patch
deleted file mode 100644
index 88cf625fc8..0000000000
--- a/main/musl/0004-e94d0692-to-83c98aac.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-diff --git a/src/internal/syscall.h b/src/internal/syscall.h
-index 88fc89c..dcfae00 100644
---- a/src/internal/syscall.h
-+++ b/src/internal/syscall.h
-@@ -10,7 +10,7 @@ typedef long syscall_arg_t;
- #endif
-
- #if defined(__PIC__) && (100*__GNUC__+__GNUC_MINOR__ >= 303)
--__attribute__((visibility("protected")))
-+__attribute__((visibility("hidden")))
- #endif
- long __syscall_ret(unsigned long), __syscall(syscall_arg_t, ...),
- __syscall_cp(syscall_arg_t, syscall_arg_t, syscall_arg_t, syscall_arg_t,
-diff --git a/src/math/modfl.c b/src/math/modfl.c
-index f736bba..4b03a4b 100644
---- a/src/math/modfl.c
-+++ b/src/math/modfl.c
-@@ -3,7 +3,12 @@
- #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
- long double modfl(long double x, long double *iptr)
- {
-- return modf(x, (double *)iptr);
-+ double d;
-+ long double r;
-+
-+ r = modf(x, &d);
-+ *iptr = d;
-+ return r;
- }
- #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
- #if LDBL_MANT_DIG == 64
-diff --git a/src/math/sincosl.c b/src/math/sincosl.c
-index 2c60080..d3ac1c4 100644
---- a/src/math/sincosl.c
-+++ b/src/math/sincosl.c
-@@ -4,7 +4,10 @@
- #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
- void sincosl(long double x, long double *sin, long double *cos)
- {
-- sincos(x, (double *)sin, (double *)cos);
-+ double sind, cosd;
-+ sincos(x, &sind, &cosd);
-+ *sin = sind;
-+ *cos = cosd;
- }
- #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
- void sincosl(long double x, long double *sin, long double *cos)
-diff --git a/src/string/memmem.c b/src/string/memmem.c
-index 5211d75..a5a249f 100644
---- a/src/string/memmem.c
-+++ b/src/string/memmem.c
-@@ -139,6 +139,7 @@ void *memmem(const void *h0, size_t k, const void *n0, size_t l)
- /* Use faster algorithms for short needles */
- h = memchr(h0, *n, k);
- if (!h || l==1) return (void *)h;
-+ k -= h - (const unsigned char *)h0;
- if (l==2) return twobyte_memmem(h, k, n);
- if (l==3) return threebyte_memmem(h, k, n);
- if (l==4) return fourbyte_memmem(h, k, n);
diff --git a/main/musl/APKBUILD b/main/musl/APKBUILD
index 6d3817af11..19810121ed 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.0.0
-pkgrel=11
+pkgver=1.1.0
+pkgrel=0
pkgdesc="the musl c library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
@@ -14,11 +14,6 @@ install=""
subpackages="$pkgname-dev $pkgname-utils"
[ "${CTARGET#*musl}" = "$CTARGET" ] && subpackages="$subpackages musl-gcc:crosstool"
source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz
- 0001-v1.0.0-to-2b74315d.patch
- 0002-2b74315d-to-b9b2db2f.patch
- 0003-b9b2db2f-to-e94d0692.patch
- 0004-e94d0692-to-83c98aac.patch
-
1001-add-basic-dns-record-parsing-functions.patch
1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
@@ -120,33 +115,21 @@ crosstool() {
find "$pkgdir" -type d -delete 2>/dev/null
}
-md5sums="e54664fdf211d27737e328c4462b545e musl-1.0.0.tar.gz
-d081fc3424229c639e636be2dd00d221 0001-v1.0.0-to-2b74315d.patch
-48fa02a48a33bbcb8149edf6540d02f9 0002-2b74315d-to-b9b2db2f.patch
-d0a6498cede60e70c468d9a44b968abe 0003-b9b2db2f-to-e94d0692.patch
-1bd1787e961189215e0a60e9ed863529 0004-e94d0692-to-83c98aac.patch
+md5sums="c2118c3b6afc77f46a0b23a38a8c3080 musl-1.1.0.tar.gz
a3810683ef61ac27e2f6ec9801280c81 1001-add-basic-dns-record-parsing-functions.patch
83c3bd2a50b1de5ef948704d3f4e0583 1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
61c6c1e84ed1df82abbe6d75e90cf21c getopt_long.c
0df687757221bbb0fc1aa67f1bd646f9 __stack_chk_fail_local.c
7b391300396e58fe9073866b5a80cfe8 getconf.c
2b941c4251cac44988a4abfc50e21267 getent.c"
-sha256sums="1ad7f45d2972daff19c9e6a92714e6d70f4aad003cd8c3d1e6113432114c1a32 musl-1.0.0.tar.gz
-aa632b635d472d5a6a49800899ce34cddc89a63a489690faa683d08622b9cd60 0001-v1.0.0-to-2b74315d.patch
-edc0cebaabd16f894d91c1860bfb70d3f2d9a70cf558c5455689610374447f7d 0002-2b74315d-to-b9b2db2f.patch
-8ee26d42062a4bc91a7fc95fe3f257b9ffcbef600a6344257f7681f358a4a012 0003-b9b2db2f-to-e94d0692.patch
-48a906fd2390b9d9015807c2d3d200c96fa4983faf229661d7158b62ae5dcfd2 0004-e94d0692-to-83c98aac.patch
+sha256sums="de1b43019e5361d7577e5e0213e9dde591853e9da5d4a7cd75e2e0d78bf60820 musl-1.1.0.tar.gz
758390768b1bc4159d56908ca332b9640cd0552ed3b4b2b8d4a6d499c54c11a1 1001-add-basic-dns-record-parsing-functions.patch
1c25880095e869b827f02997e864fdf4bf157a4e923e52d97dbd05e657aedb70 1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
d9b644ec20bc33e81a7c52b9fcf7973d835923a69faf50f03db45534b811bd96 getopt_long.c
299a7d75a09de3e2e11e7fb4acc3182e4a14e868093d2f30938fce9bfcff13da __stack_chk_fail_local.c
530ea449f93d53fafcb377fa0a23a7564f2961e49c07a8fdef6c960110317301 getconf.c
68373a55e89ce85c562d941ccf588337d6cc6c9c17689d695f65cd7607134bbe getent.c"
-sha512sums="c76cbfe60cbe9b1ceb1faedddf2dcce0f11c942c8f74e4f217efe63e8e1d7be70fcb6cf1182eeaee90441152c4493d678682cb247a0dbc7537d24f943a7bbdf8 musl-1.0.0.tar.gz
-e04f0f9de2859d18cb13aa8bfd839cc757aa9d835f133e46b48a760c7e689a92c641abe1e84dcaab6134c22500603e66d9a880f9b80b77e36a063348f5879878 0001-v1.0.0-to-2b74315d.patch
-19c09e09d61ba31caeece27ea4241be4f14f73ab958da7f37fc4f0c8391fcaa912a750a2b79c29b3fec24ad22995244c91d1f0372d9b8481c99411e2442c2d4e 0002-2b74315d-to-b9b2db2f.patch
-352b7c0693ebe6093e71d4e9cb704ff569e0e0ae2dcc576d3dc4883e7dddd1ffbc09d8365cceabbeec6b974496dddb9ed7bfacaa244c92c2735caf08c843593a 0003-b9b2db2f-to-e94d0692.patch
-13b22003bb8b40786e524df42ec9560d56f45265a531faf82e2285cc0c2e893937f4c32159ec75b99c7953dbeeef15b24c2e8dbe2145728e9b011ae8952a81f5 0004-e94d0692-to-83c98aac.patch
+sha512sums="72dab085fa56a2f02d407074b9a4c1d409624df74924ed385b174a767113aa0a4112bd22d3eaf465b31a14b8e60a15997d6042421994673977de306ee8738b3d musl-1.1.0.tar.gz
dad965258daf69371b844f76bfe5a914b0eca0ca76f3fc340b8fd7acf598b5f87bbe6d68b1f43ed0293ee0ed3bfd85d5173ccc169aa6265646248d5b8a906708 1001-add-basic-dns-record-parsing-functions.patch
72cf33738d2cf31f6ec02312bc494d754c17470b519172bb8bd7e2e29ac3b119023088a2b3fbc0dbc2fddd0078ccbae62096106cae361f8c31d6a9950043af25 1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
140f3f20d30bd95ebce8c41b8cc7f616c6cbedf4ea06c729c21014e74f6043796825cc40ebc5180620ea38173afdba23f09ebf6d8b11fa05440b14d23764fca9 getopt_long.c