aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2017-07-05 13:04:48 +0300
committerTimo Teräs <timo.teras@iki.fi>2017-07-05 13:06:40 +0300
commit50c197239c89545dd072af45f8e644c92fb706a5 (patch)
tree269117c2bc4f3577f66718accc9d70c66b52bd06
parenta0e0ebc0d01600ae0a82f6a1a788324d1b5e09c5 (diff)
main/musl: cherry-pick upstream fixes
including regression fix for promoting RTLD_LOCAL to RTLD_GLOBAL
-rw-r--r--main/musl/0050-fix-regression-in-getspnam-_r-error-code-for-insuffi.patch28
-rw-r--r--main/musl/0051-fix-arm-run-time-abi-string-functions.patch177
-rw-r--r--main/musl/0052-ldso-avoid-spurious-possible-erroneous-work-for-libs.patch84
-rw-r--r--main/musl/0053-fix-regression-in-dlopen-promotion-from-RTLD_LOCAL-t.patch46
-rw-r--r--main/musl/0054-allow-specifying-argv-0-when-invoking-a-program-via-.patch48
-rw-r--r--main/musl/0055-reapply-va_arg-hacks-removal-to-wprintf.patch89
-rw-r--r--main/musl/0056-fix-undefined-behavior-in-free.patch34
-rw-r--r--main/musl/0057-fix-missing-volatile-qualifier-on-lock-in-__get_loca.patch25
-rw-r--r--main/musl/APKBUILD18
9 files changed, 548 insertions, 1 deletions
diff --git a/main/musl/0050-fix-regression-in-getspnam-_r-error-code-for-insuffi.patch b/main/musl/0050-fix-regression-in-getspnam-_r-error-code-for-insuffi.patch
new file mode 100644
index 00000000000..cc11a81ce1d
--- /dev/null
+++ b/main/musl/0050-fix-regression-in-getspnam-_r-error-code-for-insuffi.patch
@@ -0,0 +1,28 @@
+From 91d34c4533e6bf6eacad7a9f001f28f9e5ebc656 Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Wed, 21 Jun 2017 19:06:45 -0400
+Subject: [PATCH 50/50] fix regression in getspnam[_r] error code for
+ insufficient buffer size
+
+commit 2d7d05f031e014068a61d3076c6178513395d2ae wrongly changed ERANGE
+to EINVAL, likely as the result of copy-and-paste error.
+---
+ src/passwd/getspnam_r.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/passwd/getspnam_r.c b/src/passwd/getspnam_r.c
+index e488b67f..541206fa 100644
+--- a/src/passwd/getspnam_r.c
++++ b/src/passwd/getspnam_r.c
+@@ -76,7 +76,7 @@ int getspnam_r(const char *name, struct spwd *sp, char *buf, size_t size, struct
+
+ /* Buffer size must at least be able to hold name, plus some.. */
+ if (size < l+100)
+- return errno = EINVAL;
++ return errno = ERANGE;
+
+ /* Protect against truncation */
+ if (snprintf(path, sizeof path, "/etc/tcb/%s/shadow", name) >= sizeof path)
+--
+2.13.1
+
diff --git a/main/musl/0051-fix-arm-run-time-abi-string-functions.patch b/main/musl/0051-fix-arm-run-time-abi-string-functions.patch
new file mode 100644
index 00000000000..a5327410e08
--- /dev/null
+++ b/main/musl/0051-fix-arm-run-time-abi-string-functions.patch
@@ -0,0 +1,177 @@
+From e6def544358afd5648a428d2e02c147a1f901048 Mon Sep 17 00:00:00 2001
+From: Szabolcs Nagy <nsz@port70.net>
+Date: Tue, 21 Feb 2017 00:07:34 +0000
+Subject: [PATCH 51/51] fix arm run-time abi string functions
+
+in arm rtabi these __aeabi_* functions have special abi (they are
+only allowed to clobber r0,r1,r2,r3,ip,lr,cpsr), so they cannot
+be simple wrappers around normal string functions (which may
+clobber other registers), the safest solution is to write them in
+asm, a minimalistic implementation works because these are not
+supposed to be emitted by compilers or used in general.
+---
+ src/string/arm/__aeabi_memclr.c | 9 --------
+ src/string/arm/__aeabi_memcpy.c | 9 --------
+ src/string/arm/__aeabi_memcpy.s | 45 ++++++++++++++++++++++++++++++++++++++++
+ src/string/arm/__aeabi_memmove.c | 9 --------
+ src/string/arm/__aeabi_memset.c | 9 --------
+ src/string/arm/__aeabi_memset.s | 31 +++++++++++++++++++++++++++
+ 6 files changed, 76 insertions(+), 36 deletions(-)
+ delete mode 100644 src/string/arm/__aeabi_memclr.c
+ delete mode 100644 src/string/arm/__aeabi_memcpy.c
+ create mode 100644 src/string/arm/__aeabi_memcpy.s
+ delete mode 100644 src/string/arm/__aeabi_memmove.c
+ delete mode 100644 src/string/arm/__aeabi_memset.c
+ create mode 100644 src/string/arm/__aeabi_memset.s
+
+diff --git a/src/string/arm/__aeabi_memclr.c b/src/string/arm/__aeabi_memclr.c
+deleted file mode 100644
+index a25306d7..00000000
+--- a/src/string/arm/__aeabi_memclr.c
++++ /dev/null
+@@ -1,9 +0,0 @@
+-#include <string.h>
+-#include "libc.h"
+-
+-void __aeabi_memclr(void *dest, size_t n)
+-{
+- memset(dest, 0, n);
+-}
+-weak_alias(__aeabi_memclr, __aeabi_memclr4);
+-weak_alias(__aeabi_memclr, __aeabi_memclr8);
+diff --git a/src/string/arm/__aeabi_memcpy.c b/src/string/arm/__aeabi_memcpy.c
+deleted file mode 100644
+index 4ae5c777..00000000
+--- a/src/string/arm/__aeabi_memcpy.c
++++ /dev/null
+@@ -1,9 +0,0 @@
+-#include <string.h>
+-#include "libc.h"
+-
+-void __aeabi_memcpy(void *restrict dest, const void *restrict src, size_t n)
+-{
+- memcpy(dest, src, n);
+-}
+-weak_alias(__aeabi_memcpy, __aeabi_memcpy4);
+-weak_alias(__aeabi_memcpy, __aeabi_memcpy8);
+diff --git a/src/string/arm/__aeabi_memcpy.s b/src/string/arm/__aeabi_memcpy.s
+new file mode 100644
+index 00000000..3a527e41
+--- /dev/null
++++ b/src/string/arm/__aeabi_memcpy.s
+@@ -0,0 +1,45 @@
++.syntax unified
++
++.global __aeabi_memcpy8
++.global __aeabi_memcpy4
++.global __aeabi_memcpy
++.global __aeabi_memmove8
++.global __aeabi_memmove4
++.global __aeabi_memmove
++
++.type __aeabi_memcpy8,%function
++.type __aeabi_memcpy4,%function
++.type __aeabi_memcpy,%function
++.type __aeabi_memmove8,%function
++.type __aeabi_memmove4,%function
++.type __aeabi_memmove,%function
++
++__aeabi_memmove8:
++__aeabi_memmove4:
++__aeabi_memmove:
++ cmp r0, r1
++ bls 3f
++ cmp r2, #0
++ beq 2f
++ adds r0, r0, r2
++ adds r2, r1, r2
++1: subs r2, r2, #1
++ ldrb r3, [r2]
++ subs r0, r0, #1
++ strb r3, [r0]
++ cmp r1, r2
++ bne 1b
++2: bx lr
++__aeabi_memcpy8:
++__aeabi_memcpy4:
++__aeabi_memcpy:
++3: cmp r2, #0
++ beq 2f
++ adds r2, r1, r2
++1: ldrb r3, [r1]
++ adds r1, r1, #1
++ strb r3, [r0]
++ adds r0, r0, #1
++ cmp r1, r2
++ bne 1b
++2: bx lr
+diff --git a/src/string/arm/__aeabi_memmove.c b/src/string/arm/__aeabi_memmove.c
+deleted file mode 100644
+index 951e7d39..00000000
+--- a/src/string/arm/__aeabi_memmove.c
++++ /dev/null
+@@ -1,9 +0,0 @@
+-#include <string.h>
+-#include "libc.h"
+-
+-void __aeabi_memmove(void *dest, const void *src, size_t n)
+-{
+- memmove(dest, src, n);
+-}
+-weak_alias(__aeabi_memmove, __aeabi_memmove4);
+-weak_alias(__aeabi_memmove, __aeabi_memmove8);
+diff --git a/src/string/arm/__aeabi_memset.c b/src/string/arm/__aeabi_memset.c
+deleted file mode 100644
+index 89299757..00000000
+--- a/src/string/arm/__aeabi_memset.c
++++ /dev/null
+@@ -1,9 +0,0 @@
+-#include <string.h>
+-#include "libc.h"
+-
+-void __aeabi_memset(void *dest, size_t n, int c)
+-{
+- memset(dest, c, n);
+-}
+-weak_alias(__aeabi_memset, __aeabi_memset4);
+-weak_alias(__aeabi_memset, __aeabi_memset8);
+diff --git a/src/string/arm/__aeabi_memset.s b/src/string/arm/__aeabi_memset.s
+new file mode 100644
+index 00000000..f9f60583
+--- /dev/null
++++ b/src/string/arm/__aeabi_memset.s
+@@ -0,0 +1,31 @@
++.syntax unified
++
++.global __aeabi_memclr8
++.global __aeabi_memclr4
++.global __aeabi_memclr
++.global __aeabi_memset8
++.global __aeabi_memset4
++.global __aeabi_memset
++
++.type __aeabi_memclr8,%function
++.type __aeabi_memclr4,%function
++.type __aeabi_memclr,%function
++.type __aeabi_memset8,%function
++.type __aeabi_memset4,%function
++.type __aeabi_memset,%function
++
++__aeabi_memclr8:
++__aeabi_memclr4:
++__aeabi_memclr:
++ movs r2, #0
++__aeabi_memset8:
++__aeabi_memset4:
++__aeabi_memset:
++ cmp r1, #0
++ beq 2f
++ adds r1, r0, r1
++1: strb r2, [r0]
++ adds r0, r0, #1
++ cmp r1, r0
++ bne 1b
++2: bx lr
+--
+2.13.1
+
diff --git a/main/musl/0052-ldso-avoid-spurious-possible-erroneous-work-for-libs.patch b/main/musl/0052-ldso-avoid-spurious-possible-erroneous-work-for-libs.patch
new file mode 100644
index 00000000000..86ca7ea9e9d
--- /dev/null
+++ b/main/musl/0052-ldso-avoid-spurious-possible-erroneous-work-for-libs.patch
@@ -0,0 +1,84 @@
+From 66b53cfa8876342f7e7d7907d30c719c38cd5a1b Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Tue, 4 Jul 2017 10:58:13 -0400
+Subject: [PATCH 52/52] ldso: avoid spurious & possible erroneous work for libs
+ with no deps
+
+a null pointer for a library's deps list was ambiguous: it could
+indicate either no dependencies or that the dependency list had not
+yet been populated. inability to distinguish could lead to spurious
+work when dlopen is called multiple times on a library with no deps,
+and due to related bugs, could actually cause other libraries to
+falsely appear as dependencies, translating into false positives for
+dlsym.
+
+avoid the problem by always initializing the deps pointer, pointing to
+an empty list if there are no deps. rather than wasting memory and
+introducing another failure path by allocating an empty list per
+library, simply share a global dummy list.
+
+further fixes will be needed for related bugs, and much of this code
+may end up being replaced.
+---
+ ldso/dynlink.c | 11 +++++++----
+ 1 file changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/ldso/dynlink.c b/ldso/dynlink.c
+index d20dbd87..239007ff 100644
+--- a/ldso/dynlink.c
++++ b/ldso/dynlink.c
+@@ -129,6 +129,7 @@ static size_t static_tls_cnt;
+ static pthread_mutex_t init_fini_lock = { ._m_type = PTHREAD_MUTEX_RECURSIVE };
+ static struct fdpic_loadmap *app_loadmap;
+ static struct fdpic_dummy_loadmap app_dummy_loadmap;
++static struct dso *const nodeps_dummy;
+
+ struct debug *_dl_debug_addr = &debug;
+
+@@ -1125,6 +1126,7 @@ static void load_deps(struct dso *p)
+ }
+ }
+ }
++ if (!*deps) *deps = (struct dso **)&nodeps_dummy;
+ }
+
+ static void load_preload(char *s)
+@@ -1742,7 +1744,8 @@ void *dlopen(const char *file, int mode)
+ free(p->funcdescs);
+ if (p->rpath != p->rpath_orig)
+ free(p->rpath);
+- free(p->deps);
++ if (p->deps != &nodeps_dummy)
++ free(p->deps);
+ unmap_library(p);
+ free(p);
+ }
+@@ -1772,14 +1775,14 @@ void *dlopen(const char *file, int mode)
+ load_deps(p);
+ if (!p->relocated && (mode & RTLD_LAZY)) {
+ prepare_lazy(p);
+- if (p->deps) for (i=0; p->deps[i]; i++)
++ for (i=0; p->deps[i]; i++)
+ if (!p->deps[i]->relocated)
+ prepare_lazy(p->deps[i]);
+ }
+ /* Make new symbols global, at least temporarily, so we can do
+ * relocations. If not RTLD_GLOBAL, this is reverted below. */
+ add_syms(p);
+- if (p->deps) for (i=0; p->deps[i]; i++)
++ for (i=0; p->deps[i]; i++)
+ add_syms(p->deps[i]);
+ reloc_all(p);
+ }
+@@ -1878,7 +1881,7 @@ static void *do_dlsym(struct dso *p, const char *s, void *ra)
+ return p->funcdescs + (sym - p->syms);
+ if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES))
+ return laddr(p, sym->st_value);
+- if (p->deps) for (i=0; p->deps[i]; i++) {
++ for (i=0; p->deps[i]; i++) {
+ if ((ght = p->deps[i]->ghashtab)) {
+ if (!gh) gh = gnu_hash(s);
+ sym = gnu_lookup(gh, ght, p->deps[i], s);
+--
+2.13.1
+
diff --git a/main/musl/0053-fix-regression-in-dlopen-promotion-from-RTLD_LOCAL-t.patch b/main/musl/0053-fix-regression-in-dlopen-promotion-from-RTLD_LOCAL-t.patch
new file mode 100644
index 00000000000..b5ba7cc87d9
--- /dev/null
+++ b/main/musl/0053-fix-regression-in-dlopen-promotion-from-RTLD_LOCAL-t.patch
@@ -0,0 +1,46 @@
+From 43c423af5b8453afde86e4ba81e0fcc663ae7c22 Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Tue, 4 Jul 2017 11:34:39 -0400
+Subject: [PATCH 53/53] fix regression in dlopen promotion from RTLD_LOCAL to
+ RTLD_GLOBAL
+
+commit 4ff234f6cba96403b5de6d29d48a59fd73252040 inadvertently removed
+the logic to do this when changing the representation of global
+status.
+---
+ ldso/dynlink.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/ldso/dynlink.c b/ldso/dynlink.c
+index 239007ff..fc6a68b8 100644
+--- a/ldso/dynlink.c
++++ b/ldso/dynlink.c
+@@ -1771,7 +1771,8 @@ void *dlopen(const char *file, int mode)
+ }
+
+ /* First load handling */
+- if (!p->deps) {
++ int first_load = !p->deps;
++ if (first_load) {
+ load_deps(p);
+ if (!p->relocated && (mode & RTLD_LAZY)) {
+ prepare_lazy(p);
+@@ -1779,11 +1780,15 @@ void *dlopen(const char *file, int mode)
+ if (!p->deps[i]->relocated)
+ prepare_lazy(p->deps[i]);
+ }
++ }
++ if (first_load || (mode & RTLD_GLOBAL)) {
+ /* Make new symbols global, at least temporarily, so we can do
+ * relocations. If not RTLD_GLOBAL, this is reverted below. */
+ add_syms(p);
+ for (i=0; p->deps[i]; i++)
+ add_syms(p->deps[i]);
++ }
++ if (first_load) {
+ reloc_all(p);
+ }
+
+--
+2.13.1
+
diff --git a/main/musl/0054-allow-specifying-argv-0-when-invoking-a-program-via-.patch b/main/musl/0054-allow-specifying-argv-0-when-invoking-a-program-via-.patch
new file mode 100644
index 00000000000..9855ac7778d
--- /dev/null
+++ b/main/musl/0054-allow-specifying-argv-0-when-invoking-a-program-via-.patch
@@ -0,0 +1,48 @@
+From f3055e0163aad1cebb0867078643b36643c5d95f Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Tue, 4 Jul 2017 16:58:28 -0400
+Subject: [PATCH 54/54] allow specifying argv[0] when invoking a program via
+ ldso command
+
+previously, the pathname used to load the program was always used as
+argv[0]. the default remains the same, but a new --argv0 option can be
+used to provide a different value.
+---
+ ldso/dynlink.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/ldso/dynlink.c b/ldso/dynlink.c
+index fc6a68b8..35a90aef 100644
+--- a/ldso/dynlink.c
++++ b/ldso/dynlink.c
+@@ -1437,6 +1437,7 @@ _Noreturn void __dls3(size_t *sp)
+ size_t aux[AUX_CNT], *auxv;
+ size_t i;
+ char *env_preload=0;
++ char *replace_argv0=0;
+ size_t vdso_base;
+ int argc = *sp;
+ char **argv = (void *)(sp+1);
+@@ -1521,6 +1522,10 @@ _Noreturn void __dls3(size_t *sp)
+ if (opt[7]=='=') env_preload = opt+8;
+ else if (opt[7]) *argv = 0;
+ else if (*argv) env_preload = *argv++;
++ } else if (!memcmp(opt, "argv0", 5)) {
++ if (opt[5]=='=') replace_argv0 = opt+6;
++ else if (opt[5]) *argv = 0;
++ else if (*argv) replace_argv0 = *argv++;
+ } else {
+ argv[0] = 0;
+ }
+@@ -1677,6 +1682,8 @@ _Noreturn void __dls3(size_t *sp)
+ debug.state = 0;
+ _dl_debug_state();
+
++ if (replace_argv0) argv[0] = replace_argv0;
++
+ errno = 0;
+
+ CRTJMP((void *)aux[AT_ENTRY], argv-1);
+--
+2.13.1
+
diff --git a/main/musl/0055-reapply-va_arg-hacks-removal-to-wprintf.patch b/main/musl/0055-reapply-va_arg-hacks-removal-to-wprintf.patch
new file mode 100644
index 00000000000..944f5253b4c
--- /dev/null
+++ b/main/musl/0055-reapply-va_arg-hacks-removal-to-wprintf.patch
@@ -0,0 +1,89 @@
+From f6888840613a510c99915ba7732df8ec54d52637 Mon Sep 17 00:00:00 2001
+From: Alexander Monakov <amonakov@ispras.ru>
+Date: Tue, 4 Jul 2017 22:59:06 +0300
+Subject: [PATCH 55/55] reapply va_arg hacks removal to wprintf
+
+commit 58e2396a9aa23c132faf4198ca4d779c84955b38 missed that the same
+code was duplicated in implementation of vfwprintf.
+---
+ src/stdio/vfwprintf.c | 27 +--------------------------
+ 1 file changed, 1 insertion(+), 26 deletions(-)
+
+diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c
+index b8fff208..1e6e47cc 100644
+--- a/src/stdio/vfwprintf.c
++++ b/src/stdio/vfwprintf.c
+@@ -4,6 +4,7 @@
+ #include <limits.h>
+ #include <string.h>
+ #include <stdarg.h>
++#include <stddef.h>
+ #include <wchar.h>
+ #include <inttypes.h>
+
+@@ -19,14 +20,6 @@
+
+ #define FLAGMASK (ALT_FORM|ZERO_PAD|LEFT_ADJ|PAD_POS|MARK_POS|GROUPED)
+
+-#if UINT_MAX == ULONG_MAX
+-#define LONG_IS_INT
+-#endif
+-
+-#if SIZE_MAX != ULONG_MAX || UINTMAX_MAX != ULLONG_MAX
+-#define ODD_TYPES
+-#endif
+-
+ /* State machine to accept length modifiers + conversion specifiers.
+ * Result is 0 on failure, or an argument type to pop on success. */
+
+@@ -35,23 +28,9 @@ enum {
+ ZTPRE, JPRE,
+ STOP,
+ PTR, INT, UINT, ULLONG,
+-#ifndef LONG_IS_INT
+ LONG, ULONG,
+-#else
+-#define LONG INT
+-#define ULONG UINT
+-#endif
+ SHORT, USHORT, CHAR, UCHAR,
+-#ifdef ODD_TYPES
+ LLONG, SIZET, IMAX, UMAX, PDIFF, UIPTR,
+-#else
+-#define LLONG ULLONG
+-#define SIZET ULONG
+-#define IMAX LLONG
+-#define UMAX ULLONG
+-#define PDIFF LONG
+-#define UIPTR ULONG
+-#endif
+ DBL, LDBL,
+ NOARG,
+ MAXSTATE
+@@ -125,23 +104,19 @@ static void pop_arg(union arg *arg, int type, va_list *ap)
+ case PTR: arg->p = va_arg(*ap, void *);
+ break; case INT: arg->i = va_arg(*ap, int);
+ break; case UINT: arg->i = va_arg(*ap, unsigned int);
+-#ifndef LONG_IS_INT
+ break; case LONG: arg->i = va_arg(*ap, long);
+ break; case ULONG: arg->i = va_arg(*ap, unsigned long);
+-#endif
+ break; case ULLONG: arg->i = va_arg(*ap, unsigned long long);
+ break; case SHORT: arg->i = (short)va_arg(*ap, int);
+ break; case USHORT: arg->i = (unsigned short)va_arg(*ap, int);
+ break; case CHAR: arg->i = (signed char)va_arg(*ap, int);
+ break; case UCHAR: arg->i = (unsigned char)va_arg(*ap, int);
+-#ifdef ODD_TYPES
+ break; case LLONG: arg->i = va_arg(*ap, long long);
+ break; case SIZET: arg->i = va_arg(*ap, size_t);
+ break; case IMAX: arg->i = va_arg(*ap, intmax_t);
+ break; case UMAX: arg->i = va_arg(*ap, uintmax_t);
+ break; case PDIFF: arg->i = va_arg(*ap, ptrdiff_t);
+ break; case UIPTR: arg->i = (uintptr_t)va_arg(*ap, void *);
+-#endif
+ break; case DBL: arg->f = va_arg(*ap, double);
+ break; case LDBL: arg->f = va_arg(*ap, long double);
+ }
+--
+2.13.1
+
diff --git a/main/musl/0056-fix-undefined-behavior-in-free.patch b/main/musl/0056-fix-undefined-behavior-in-free.patch
new file mode 100644
index 00000000000..cccf2db4c0a
--- /dev/null
+++ b/main/musl/0056-fix-undefined-behavior-in-free.patch
@@ -0,0 +1,34 @@
+From 60ab365cae24063b0f21821860ca16fb63e81f81 Mon Sep 17 00:00:00 2001
+From: Alexander Monakov <amonakov@ispras.ru>
+Date: Tue, 27 Jun 2017 20:58:47 +0300
+Subject: [PATCH 56/56] fix undefined behavior in free
+
+---
+ src/malloc/malloc.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/src/malloc/malloc.c b/src/malloc/malloc.c
+index d5ee4280..9e05e1d6 100644
+--- a/src/malloc/malloc.c
++++ b/src/malloc/malloc.c
+@@ -450,14 +450,15 @@ copy_realloc:
+
+ void free(void *p)
+ {
+- struct chunk *self = MEM_TO_CHUNK(p);
+- struct chunk *next;
++ struct chunk *self, *next;
+ size_t final_size, new_size, size;
+ int reclaim=0;
+ int i;
+
+ if (!p) return;
+
++ self = MEM_TO_CHUNK(p);
++
+ if (IS_MMAPPED(self)) {
+ size_t extra = self->psize;
+ char *base = (char *)self - extra;
+--
+2.13.1
+
diff --git a/main/musl/0057-fix-missing-volatile-qualifier-on-lock-in-__get_loca.patch b/main/musl/0057-fix-missing-volatile-qualifier-on-lock-in-__get_loca.patch
new file mode 100644
index 00000000000..d8e6e8adde9
--- /dev/null
+++ b/main/musl/0057-fix-missing-volatile-qualifier-on-lock-in-__get_loca.patch
@@ -0,0 +1,25 @@
+From a08910fc2cc739f631b75b2d09b8d72a0d64d285 Mon Sep 17 00:00:00 2001
+From: Jens Gustedt <Jens.Gustedt@inria.fr>
+Date: Sat, 24 Jun 2017 11:54:25 +0200
+Subject: [PATCH 57/57] fix missing volatile qualifier on lock in __get_locale
+
+---
+ src/locale/locale_map.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/locale/locale_map.c b/src/locale/locale_map.c
+index c3e59174..188fcf39 100644
+--- a/src/locale/locale_map.c
++++ b/src/locale/locale_map.c
+@@ -26,7 +26,7 @@ static const char envvars[][12] = {
+
+ const struct __locale_map *__get_locale(int cat, const char *val)
+ {
+- static int lock[2];
++ static volatile int lock[2];
+ static void *volatile loc_head;
+ const struct __locale_map *p;
+ struct __locale_map *new = 0;
+--
+2.13.1
+
diff --git a/main/musl/APKBUILD b/main/musl/APKBUILD
index 004ef01b651..6d51712f2f4 100644
--- a/main/musl/APKBUILD
+++ b/main/musl/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
pkgver=1.1.16
-pkgrel=14
+pkgrel=15
pkgdesc="the musl c library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
@@ -66,6 +66,14 @@ source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz
0047-set-errno-when-getpw-_r-getgr-_r-and-getspnam_r-fail.patch
0048-handle-errors-from-localtime_r-in-ctime_r.patch
0049-fix-iconv-conversions-for-iso88592-iso885916.patch
+ 0050-fix-regression-in-getspnam-_r-error-code-for-insuffi.patch
+ 0051-fix-arm-run-time-abi-string-functions.patch
+ 0052-ldso-avoid-spurious-possible-erroneous-work-for-libs.patch
+ 0053-fix-regression-in-dlopen-promotion-from-RTLD_LOCAL-t.patch
+ 0054-allow-specifying-argv-0-when-invoking-a-program-via-.patch
+ 0055-reapply-va_arg-hacks-removal-to-wprintf.patch
+ 0056-fix-undefined-behavior-in-free.patch
+ 0057-fix-missing-volatile-qualifier-on-lock-in-__get_loca.patch
1000-implement-strftime-GNU-extension-padding-specifiers-.patch
2000-pthread-internals-increase-DEFAULT_GUARD_SIZE-to-2-p.patch
@@ -240,6 +248,14 @@ c6c97ccc7b5a88a6e32ab8bb0cd35ae4689c144fd8b0f40e880061d374e5a71365066f89263d181a
b3e00f1d83314736d2c7b4bee59bc1055fdbc2bb4ce75b62a293c99abeb372afc1c5e73c4d878bf1d865964daf93e2e413890c60e0be6c72982c257d067c4b73 0047-set-errno-when-getpw-_r-getgr-_r-and-getspnam_r-fail.patch
fc2c08156e755a9e178ede1642673b1f1ba06be467ff607fc3f9ea9052ddb2fa8d0ff425fd764aa7f4fc9bbd6ae0db86ad95c128e4f0da0a901980b449efa659 0048-handle-errors-from-localtime_r-in-ctime_r.patch
053f5a09494dc117ae83ff801241fa71f1401303c53587bb01c2e7367a8149912c74dbe52373fc19f82eef9df41091e33faab5728598f99d7c9bb655701e331c 0049-fix-iconv-conversions-for-iso88592-iso885916.patch
+0fb668eb4df132bd779d534b86ff3858914261352af2fa4e2b04c83eca88bed5cd440648ce6b245196cbe2446a427618615756c61281d998a4a04713c09d7806 0050-fix-regression-in-getspnam-_r-error-code-for-insuffi.patch
+a53c952ab63e5aae56a152de489cf3eb65ab0a1abf466960d7b9d091e665c6f7e705859e61fc16c6c05b2720d75bc6e094c8407e56e98fbf25c8e1cf11369870 0051-fix-arm-run-time-abi-string-functions.patch
+a2af359d64cff4eb37b35a1d4f4c20f4e80132b3f3c844335ab7f971cfb2f2e160dd8c16a9098cfc5cf69cf5b224f9ae1688a84f7e3870ba6956f5062e595b14 0052-ldso-avoid-spurious-possible-erroneous-work-for-libs.patch
+a42d23a218683eaf5b2bf8d7badbc8e0d146b4a4ac06c9f71cd516071b22e3b0055239912ed02bc1207aa4205a3c25c170164aa1cc1f8ac2ba0b821324a42745 0053-fix-regression-in-dlopen-promotion-from-RTLD_LOCAL-t.patch
+8ac7bd79a341a1a436c2c1ccffdad376f489105503fe02cce14834cd389e1a6669cb299532b05b47b7ce3cd515eb808c8fc98a6b2894b522a7c6d82eaa93511c 0054-allow-specifying-argv-0-when-invoking-a-program-via-.patch
+ea68e0c88430b65b5a61e4cbc6e6f477b383d34de89f21d59da50a05912f11a07b55de48b75cf4de1b278b8b25afacbc105ab4748525f2c91b6219364f453f09 0055-reapply-va_arg-hacks-removal-to-wprintf.patch
+dde4bb6c877d4fdf976e3ffea5d0a4a48f365708c488ceeaa4dcc29296820517aebbfa3b0527d74ddb64bf6cdbac04624ba9043b884ac4cd770a848f4d0e1f88 0056-fix-undefined-behavior-in-free.patch
+6e0a65d4023b4d2b0a971f1dbb5017fe7aedf7c663c0f9971841a4739758826c323cd0856a1591cfd874df35e8b96f1248eda029a9cd56987c36178a32b1f0ee 0057-fix-missing-volatile-qualifier-on-lock-in-__get_loca.patch
7e4c703e57a3564cd3ee1d5334b806cbe654355179ba55d4d25361dfc555eb4a7d081d80d64fdaff8476949afd04558d278b124d1fb108080beaa5ba2f8ce2b9 1000-implement-strftime-GNU-extension-padding-specifiers-.patch
2c8e1dde1834238097b2ee8a7bfb53471a0d9cff4a5e38b55f048b567deff1cdd47c170d0578a67b1a039f95a6c5fbb8cff369c75b6a3e4d7ed171e8e86ebb8c 2000-pthread-internals-increase-DEFAULT_GUARD_SIZE-to-2-p.patch
8d3a2d5315fc56fee7da9abb8b89bb38c6046c33d154c10d168fb35bfde6b0cf9f13042a3bceee34daf091bc409d699223735dcf19f382eeee1f6be34154f26f ldconfig