From 716ca530e1c4515d8683c9d5be3d56b301758b66 Mon Sep 17 00:00:00 2001 From: James <> Date: Wed, 4 Nov 2015 11:49:21 +0000 Subject: trunk-47381 --- .../010-Add-PowerPC-soft-float-support.patch | 154 +++++++++++++++++++++ .../musl/patches/020-upstream_open_memstream.patch | 79 +++++++++++ toolchain/musl/patches/100-add_glob_onlydir.patch | 11 ++ .../musl/patches/110-read_timezone_from_fs.patch | 28 ++++ .../musl/patches/200-add_libssp_nonshared.patch | 50 +++++++ toolchain/musl/patches/300-relative.patch | 11 ++ toolchain/musl/patches/900-iconv_size_hack.patch | 68 +++++++++ toolchain/musl/patches/901-crypt_size_hack.patch | 60 ++++++++ 8 files changed, 461 insertions(+) create mode 100644 toolchain/musl/patches/010-Add-PowerPC-soft-float-support.patch create mode 100644 toolchain/musl/patches/020-upstream_open_memstream.patch create mode 100644 toolchain/musl/patches/100-add_glob_onlydir.patch create mode 100644 toolchain/musl/patches/110-read_timezone_from_fs.patch create mode 100644 toolchain/musl/patches/200-add_libssp_nonshared.patch create mode 100644 toolchain/musl/patches/300-relative.patch create mode 100644 toolchain/musl/patches/900-iconv_size_hack.patch create mode 100644 toolchain/musl/patches/901-crypt_size_hack.patch (limited to 'toolchain/musl/patches') diff --git a/toolchain/musl/patches/010-Add-PowerPC-soft-float-support.patch b/toolchain/musl/patches/010-Add-PowerPC-soft-float-support.patch new file mode 100644 index 0000000..195c933 --- /dev/null +++ b/toolchain/musl/patches/010-Add-PowerPC-soft-float-support.patch @@ -0,0 +1,154 @@ +From: Felix Fietkau +Date: Wed, 8 Jul 2015 13:56:37 +0200 +Subject: [PATCH] Add PowerPC soft-float support + +Some PowerPC CPUs (e.g. Freescale MPC85xx) have a completely different +instruction set for floating point operations (SPE). +Executing regular PowerPC floating point instructions results in +"Illegal instruction" errors. + +Make it possible to run these devices in soft-float mode. + +Signed-off-by: Felix Fietkau +--- + create mode 100644 src/fenv/powerpc-sf/fenv.sub + create mode 100644 src/setjmp/powerpc-sf/longjmp.s + create mode 100644 src/setjmp/powerpc-sf/longjmp.sub + create mode 100644 src/setjmp/powerpc-sf/setjmp.s + create mode 100644 src/setjmp/powerpc-sf/setjmp.sub + +--- a/arch/powerpc/reloc.h ++++ b/arch/powerpc/reloc.h +@@ -1,4 +1,10 @@ +-#define LDSO_ARCH "powerpc" ++#ifdef _SOFT_FLOAT ++#define FP_SUFFIX "-sf" ++#else ++#define FP_SUFFIX "" ++#endif ++ ++#define LDSO_ARCH "powerpc" FP_SUFFIX + + #define TPOFF_K (-0x7000) + +--- a/configure ++++ b/configure +@@ -538,6 +538,10 @@ trycppif "_MIPSEL || __MIPSEL || __MIPSE + trycppif __mips_soft_float "$t" && SUBARCH=${SUBARCH}-sf + fi + ++if test "$ARCH" = "powerpc" ; then ++trycppif _SOFT_FLOAT "$t" && SUBARCH=${SUBARCH}-sf ++fi ++ + test "$ARCH" = "microblaze" && trycppif __MICROBLAZEEL__ "$t" \ + && SUBARCH=${SUBARCH}el + +--- /dev/null ++++ b/src/fenv/powerpc-sf/fenv.sub +@@ -0,0 +1 @@ ++../fenv.c +--- /dev/null ++++ b/src/setjmp/powerpc-sf/longjmp.s +@@ -0,0 +1,47 @@ ++ .global _longjmp ++ .global longjmp ++ .type _longjmp,@function ++ .type longjmp,@function ++_longjmp: ++longjmp: ++# void longjmp(jmp_buf env, int val); ++# put val into return register and restore the env saved in setjmp ++# if val(r4) is 0, put 1 there. ++ # 0) move old return address into r0 ++ lwz 0, 0(3) ++ # 1) put it into link reg ++ mtlr 0 ++ #2 ) restore stack ptr ++ lwz 1, 4(3) ++ #3) restore control reg ++ lwz 0, 8(3) ++ mtcr 0 ++ #4) restore r14-r31 ++ lwz 14, 12(3) ++ lwz 15, 16(3) ++ lwz 16, 20(3) ++ lwz 17, 24(3) ++ lwz 18, 28(3) ++ lwz 19, 32(3) ++ lwz 20, 36(3) ++ lwz 21, 40(3) ++ lwz 22, 44(3) ++ lwz 23, 48(3) ++ lwz 24, 52(3) ++ lwz 25, 56(3) ++ lwz 26, 60(3) ++ lwz 27, 64(3) ++ lwz 28, 68(3) ++ lwz 29, 72(3) ++ lwz 30, 76(3) ++ lwz 31, 80(3) ++ #5) put val into return reg r3 ++ mr 3, 4 ++ ++ #6) check if return value is 0, make it 1 in that case ++ cmpwi cr7, 4, 0 ++ bne cr7, 1f ++ li 3, 1 ++1: ++ blr ++ +--- /dev/null ++++ b/src/setjmp/powerpc-sf/longjmp.sub +@@ -0,0 +1 @@ ++longjmp.s +--- /dev/null ++++ b/src/setjmp/powerpc-sf/setjmp.s +@@ -0,0 +1,43 @@ ++ .global ___setjmp ++ .hidden ___setjmp ++ .global __setjmp ++ .global _setjmp ++ .global setjmp ++ .type __setjmp,@function ++ .type _setjmp,@function ++ .type setjmp,@function ++___setjmp: ++__setjmp: ++_setjmp: ++setjmp: ++ # 0) store IP int 0, then into the jmpbuf pointed to by r3 (first arg) ++ mflr 0 ++ stw 0, 0(3) ++ # 1) store reg1 (SP) ++ stw 1, 4(3) ++ # 2) store cr ++ mfcr 0 ++ stw 0, 8(3) ++ # 3) store r14-31 ++ stw 14, 12(3) ++ stw 15, 16(3) ++ stw 16, 20(3) ++ stw 17, 24(3) ++ stw 18, 28(3) ++ stw 19, 32(3) ++ stw 20, 36(3) ++ stw 21, 40(3) ++ stw 22, 44(3) ++ stw 23, 48(3) ++ stw 24, 52(3) ++ stw 25, 56(3) ++ stw 26, 60(3) ++ stw 27, 64(3) ++ stw 28, 68(3) ++ stw 29, 72(3) ++ stw 30, 76(3) ++ stw 31, 80(3) ++ # 4) set return value to 0 ++ li 3, 0 ++ # 5) return ++ blr +--- /dev/null ++++ b/src/setjmp/powerpc-sf/setjmp.sub +@@ -0,0 +1 @@ ++setjmp.s diff --git a/toolchain/musl/patches/020-upstream_open_memstream.patch b/toolchain/musl/patches/020-upstream_open_memstream.patch new file mode 100644 index 0000000..3d14404 --- /dev/null +++ b/toolchain/musl/patches/020-upstream_open_memstream.patch @@ -0,0 +1,79 @@ +From 7b9f57f207b51132f188f750161953b7baf32154 Mon Sep 17 00:00:00 2001 +From: Rich Felker +Date: Thu, 8 Oct 2015 22:03:53 +0000 +Subject: fix open_[w]memstream behavior when no writes take place + +the specification for these functions requires that the buffer/size +exposed to the caller be valid after any successful call to fflush or +fclose on the stream. the implementation's approach is to update them +only at flush time, but that misses the case where fflush or fclose is +called without any writes having taken place, in which case the write +flushing callback will not be called. + +to fix both the observable bug and the desired invariant, setup empty +buffers at open time and fail the open operation if no memory is +available. +--- + src/stdio/open_memstream.c | 11 +++++++++-- + src/stdio/open_wmemstream.c | 11 +++++++++-- + 2 files changed, 18 insertions(+), 4 deletions(-) + +diff --git a/src/stdio/open_memstream.c b/src/stdio/open_memstream.c +index 58504c9..eab024d 100644 +--- a/src/stdio/open_memstream.c ++++ b/src/stdio/open_memstream.c +@@ -59,14 +59,21 @@ FILE *open_memstream(char **bufp, size_t *sizep) + { + FILE *f; + struct cookie *c; ++ char *buf; ++ + if (!(f=malloc(sizeof *f + sizeof *c + BUFSIZ))) return 0; ++ if (!(buf=malloc(sizeof *buf))) { ++ free(f); ++ return 0; ++ } + memset(f, 0, sizeof *f + sizeof *c); + f->cookie = c = (void *)(f+1); + + c->bufp = bufp; + c->sizep = sizep; +- c->pos = c->len = c->space = 0; +- c->buf = 0; ++ c->pos = c->len = c->space = *sizep = 0; ++ c->buf = *bufp = buf; ++ *buf = 0; + + f->flags = F_NORD; + f->fd = -1; +diff --git a/src/stdio/open_wmemstream.c b/src/stdio/open_wmemstream.c +index 7ab2c64..4d90cd9 100644 +--- a/src/stdio/open_wmemstream.c ++++ b/src/stdio/open_wmemstream.c +@@ -61,14 +61,21 @@ FILE *open_wmemstream(wchar_t **bufp, size_t *sizep) + { + FILE *f; + struct cookie *c; ++ wchar_t *buf; ++ + if (!(f=malloc(sizeof *f + sizeof *c))) return 0; ++ if (!(buf=malloc(sizeof *buf))) { ++ free(f); ++ return 0; ++ } + memset(f, 0, sizeof *f + sizeof *c); + f->cookie = c = (void *)(f+1); + + c->bufp = bufp; + c->sizep = sizep; +- c->pos = c->len = c->space = 0; +- c->buf = 0; ++ c->pos = c->len = c->space = *sizep = 0; ++ c->buf = *bufp = buf; ++ *buf = 0; + + f->flags = F_NORD; + f->fd = -1; +-- +cgit v0.11.2 + diff --git a/toolchain/musl/patches/100-add_glob_onlydir.patch b/toolchain/musl/patches/100-add_glob_onlydir.patch new file mode 100644 index 0000000..db0bc22 --- /dev/null +++ b/toolchain/musl/patches/100-add_glob_onlydir.patch @@ -0,0 +1,11 @@ +--- a/include/glob.h ++++ b/include/glob.h +@@ -31,6 +31,8 @@ void globfree(glob_t *); + #define GLOB_NOESCAPE 0x40 + #define GLOB_PERIOD 0x80 + ++#define GLOB_ONLYDIR 0x100 ++ + #define GLOB_NOSPACE 1 + #define GLOB_ABORTED 2 + #define GLOB_NOMATCH 3 diff --git a/toolchain/musl/patches/110-read_timezone_from_fs.patch b/toolchain/musl/patches/110-read_timezone_from_fs.patch new file mode 100644 index 0000000..b4349e7 --- /dev/null +++ b/toolchain/musl/patches/110-read_timezone_from_fs.patch @@ -0,0 +1,28 @@ +--- a/src/time/__tz.c ++++ b/src/time/__tz.c +@@ -23,6 +23,9 @@ static int r0[5], r1[5]; + static const unsigned char *zi, *trans, *index, *types, *abbrevs, *abbrevs_end; + static size_t map_size; + ++static const char *tzfile; ++static size_t tzfile_size; ++ + static char old_tz_buf[32]; + static char *old_tz = old_tz_buf; + static size_t old_tz_size = sizeof old_tz_buf; +@@ -125,6 +128,15 @@ static void do_tzset() + "/usr/share/zoneinfo/\0/share/zoneinfo/\0/etc/zoneinfo/\0"; + + s = getenv("TZ"); ++ ++ /* if TZ is empty try to read it from /etc/TZ */ ++ if (!s || !*s) { ++ if (tzfile) ++ __munmap((void*)tzfile, tzfile_size); ++ ++ s = tzfile = (void *)__map_file("/etc/TZ", &tzfile_size); ++ } ++ + if (!s) s = "/etc/localtime"; + if (!*s) s = __gmt; + diff --git a/toolchain/musl/patches/200-add_libssp_nonshared.patch b/toolchain/musl/patches/200-add_libssp_nonshared.patch new file mode 100644 index 0000000..d0bf845 --- /dev/null +++ b/toolchain/musl/patches/200-add_libssp_nonshared.patch @@ -0,0 +1,50 @@ +From 7ec87fbbc3cac99b4173d082dd6195f47c9a32e7 Mon Sep 17 00:00:00 2001 +From: Steven Barth +Date: Mon, 22 Jun 2015 11:01:56 +0200 +Subject: [PATCH] Add libssp_nonshared.a so GCC's is not needed + +Signed-off-by: Steven Barth +--- + Makefile | 10 ++++++++-- + libssp_nonshared/__stack_chk_fail_local.c | 2 ++ + 2 files changed, 10 insertions(+), 2 deletions(-) + create mode 100644 libssp_nonshared/__stack_chk_fail_local.c + +--- a/Makefile ++++ b/Makefile +@@ -48,7 +48,7 @@ CRT_LIBS = lib/crt1.o lib/Scrt1.o lib/rc + STATIC_LIBS = lib/libc.a + SHARED_LIBS = lib/libc.so + TOOL_LIBS = lib/musl-gcc.specs +-ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS) ++ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS) lib/libssp_nonshared.a + ALL_TOOLS = tools/musl-gcc + + WRAPCC_GCC = gcc +@@ -106,7 +106,8 @@ NOSSP_SRCS = $(wildcard crt/*.c) \ + src/env/__libc_start_main.c src/env/__init_tls.c \ + src/thread/__set_thread_area.c src/env/__stack_chk_fail.c \ + src/string/memset.c src/string/memcpy.c \ +- src/ldso/dlstart.c src/ldso/dynlink.c ++ src/ldso/dlstart.c src/ldso/dynlink.c \ ++ libssp_nonshared/__stack_chk_fail_local.c + $(NOSSP_SRCS:%.c=%.o) $(NOSSP_SRCS:%.c=%.lo): CFLAGS += $(CFLAGS_NOSSP) + + $(CRT_LIBS:lib/%=crt/%): CFLAGS += -DCRT +@@ -155,6 +156,11 @@ lib/libc.a: $(OBJS) + $(AR) rc $@ $(OBJS) + $(RANLIB) $@ + ++lib/libssp_nonshared.a: libssp_nonshared/__stack_chk_fail_local.o ++ rm -f $@ ++ $(AR) rc $@ $< ++ $(RANLIB) $@ ++ + $(EMPTY_LIBS): + rm -f $@ + $(AR) rc $@ +--- /dev/null ++++ b/libssp_nonshared/__stack_chk_fail_local.c +@@ -0,0 +1,2 @@ ++#include "atomic.h" ++void __attribute__((visibility ("hidden"))) __stack_chk_fail_local(void) { a_crash(); } diff --git a/toolchain/musl/patches/300-relative.patch b/toolchain/musl/patches/300-relative.patch new file mode 100644 index 0000000..e2c22ba --- /dev/null +++ b/toolchain/musl/patches/300-relative.patch @@ -0,0 +1,11 @@ +--- a/Makefile ++++ b/Makefile +@@ -195,7 +195,7 @@ $(DESTDIR)$(includedir)/%: include/% + $(INSTALL) -D -m 644 $< $@ + + $(DESTDIR)$(LDSO_PATHNAME): $(DESTDIR)$(libdir)/libc.so +- $(INSTALL) -D -l $(libdir)/libc.so $@ || true ++ $(INSTALL) -D -l libc.so $@ || true + + install-libs: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(if $(SHARED_LIBS),$(DESTDIR)$(LDSO_PATHNAME),) + diff --git a/toolchain/musl/patches/900-iconv_size_hack.patch b/toolchain/musl/patches/900-iconv_size_hack.patch new file mode 100644 index 0000000..343915f --- /dev/null +++ b/toolchain/musl/patches/900-iconv_size_hack.patch @@ -0,0 +1,68 @@ +--- a/src/locale/iconv.c ++++ b/src/locale/iconv.c +@@ -39,6 +39,7 @@ static const unsigned char charmaps[] = + "ucs4\0ucs4be\0utf32\0utf32be\0\0\300" + "ucs4le\0utf32le\0\0\303" + "ascii\0usascii\0iso646\0iso646us\0\0\307" ++#ifdef FULL_ICONV + "eucjp\0\0\320" + "shiftjis\0sjis\0\0\321" + "gb18030\0\0\330" +@@ -46,6 +47,7 @@ static const unsigned char charmaps[] = + "gb2312\0\0\332" + "big5\0bigfive\0cp950\0big5hkscs\0\0\340" + "euckr\0ksc5601\0ksx1001\0cp949\0\0\350" ++#endif + #include "codepages.h" + ; + +@@ -53,6 +55,7 @@ static const unsigned short legacy_chars + #include "legacychars.h" + }; + ++#ifdef FULL_ICONV + static const unsigned short jis0208[84][94] = { + #include "jis0208.h" + }; +@@ -72,6 +75,7 @@ static const unsigned short hkscs[] = { + static const unsigned short ksc[93][94] = { + #include "ksc.h" + }; ++#endif + + static int fuzzycmp(const unsigned char *a, const unsigned char *b) + { +@@ -216,6 +220,7 @@ size_t iconv(iconv_t cd0, char **restric + c = ((c-0xd7c0)<<10) + (d-0xdc00); + } + break; ++#ifdef FULL_ICONV + case SHIFT_JIS: + if (c-0xa1 <= 0xdf-0xa1) { + c += 0xff61-0xa1; +@@ -362,6 +367,7 @@ size_t iconv(iconv_t cd0, char **restric + c = ksc[c][d]; + if (!c) goto ilseq; + break; ++#endif + default: + if (c < 128+type) break; + c -= 128+type; +--- a/src/locale/codepages.h ++++ b/src/locale/codepages.h +@@ -118,6 +118,7 @@ + "\0\0\0\100\15\0\344\0\0\0\0\0\0\0\0\0\0\0\0\0\103\270\1\0\0\0\340\1\200\40" + "\230\0\0\0\0\0\44\341\12\0" + ++#ifdef FULL_ICONV + "cp1250\0" + "windows1250\0" + "\0\0" +@@ -214,6 +215,7 @@ + "\0\0\0\0\0\0\0\0\0\15\0\0\0\0\0\0\0\0\0\0\266\0\0\0\0\102\0\220\13\0" + "\0\234\2\0\0\0\0\0\0\0\0\244\202\13\0\0\0\0\100\15\0\0\0\0\0\0\0\0\0\0" + "\267\0\0\0\0\103\0\240\13\0\0\240\2\0\0\0\0\0\0\0\0\250\62\45\0" ++#endif + + "koi8r\0" + "\0\0" diff --git a/toolchain/musl/patches/901-crypt_size_hack.patch b/toolchain/musl/patches/901-crypt_size_hack.patch new file mode 100644 index 0000000..8cd7b19 --- /dev/null +++ b/toolchain/musl/patches/901-crypt_size_hack.patch @@ -0,0 +1,60 @@ +--- a/src/crypt/crypt_r.c ++++ b/src/crypt/crypt_r.c +@@ -19,12 +19,6 @@ char *__crypt_r(const char *key, const c + if (salt[0] == '$' && salt[1] && salt[2]) { + if (salt[1] == '1' && salt[2] == '$') + return __crypt_md5(key, salt, output); +- if (salt[1] == '2' && salt[3] == '$') +- return __crypt_blowfish(key, salt, output); +- if (salt[1] == '5' && salt[2] == '$') +- return __crypt_sha256(key, salt, output); +- if (salt[1] == '6' && salt[2] == '$') +- return __crypt_sha512(key, salt, output); + } + return __crypt_des(key, salt, output); + } +--- a/src/crypt/crypt_sha512.c ++++ b/src/crypt/crypt_sha512.c +@@ -12,6 +12,7 @@ + #include + #include + #include ++#if 0 + + /* public domain sha512 implementation based on fips180-3 */ + /* >=2^64 bits messages are not supported (about 2000 peta bytes) */ +@@ -369,3 +370,4 @@ char *__crypt_sha512(const char *key, co + return "*"; + return p; + } ++#endif +--- a/src/crypt/crypt_blowfish.c ++++ b/src/crypt/crypt_blowfish.c +@@ -50,6 +50,7 @@ + #include + #include + ++#if 0 + typedef uint32_t BF_word; + typedef int32_t BF_word_signed; + +@@ -796,3 +797,4 @@ char *__crypt_blowfish(const char *key, + + return "*"; + } ++#endif +--- a/src/crypt/crypt_sha256.c ++++ b/src/crypt/crypt_sha256.c +@@ -13,6 +13,7 @@ + #include + #include + ++#if 0 + /* public domain sha256 implementation based on fips180-3 */ + + struct sha256 { +@@ -320,3 +321,4 @@ char *__crypt_sha256(const char *key, co + return "*"; + return p; + } ++#endif -- cgit v1.2.3