Commit 76c03af6 authored by Jan Čermák's avatar Jan Čermák

toolchain/musl: enable musl and sync sync with r46986

This is another hacky commit that should be reverted before
merging upstream (the DD release).
parent b8494be2
......@@ -226,11 +226,11 @@ menu "Global build settings"
bool "None"
config PKG_CC_STACKPROTECTOR_REGULAR
bool "Regular"
select SSP_SUPPORT
select SSP_SUPPORT if !USE_MUSL
depends on KERNEL_CC_STACKPROTECTOR_REGULAR
config PKG_CC_STACKPROTECTOR_STRONG
bool "Strong"
select SSP_SUPPORT
select SSP_SUPPORT if !USE_MUSL
depends on GCC_VERSION_4_9_LINARO
depends on KERNEL_CC_STACKPROTECTOR_STRONG
endchoice
......
......@@ -41,7 +41,7 @@ ifdef CONFIG_USE_MKLIBS
--sysroot $(STAGING_DIR_ROOT) \
`cat $(TMP_DIR)/mklibs-libs | sed 's:/*[^/]\+/*$$::' | uniq | sed 's:^$(STAGING_DIR_ROOT):-L :'` \
--ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
$(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so, \
$(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so ld-musl-*.so.*, \
$(STAGING_DIR_ROOT)/lib/$(name) \
)))) \
--target $(REAL_GNU_TARGET_NAME) \
......
......@@ -228,7 +228,6 @@ choice
config LIBC_USE_MUSL
select USE_MUSL
bool "Use musl"
depends on BROKEN
depends on !(mips64 || mips64el)
endchoice
......
......@@ -18,6 +18,7 @@ choice
config GCC_USE_VERSION_4_9_LINARO
select GCC_VERSION_4_9_LINARO
bool "gcc 4.9.x with Linaro enhancements"
depends on BROKEN
endchoice
......
......@@ -17,7 +17,7 @@
#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc%{msoft-float:-sf}.so.1"
+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
#if DEFAULT_LIBC == LIBC_UCLIBC
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
......@@ -72,7 +72,7 @@
#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc%{msoft-float:-sf}.so.1"
#if DEFAULT_LIBC == LIBC_UCLIBC
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
......
--- gcc-4.8.1/gcc/gcc.c.orig 2013-09-24 06:27:32.133894539 +0000
+++ gcc-4.8.1/gcc/gcc.c 2013-09-24 06:29:35.790562854 +0000
@@ -656,7 +656,9 @@
#endif
#ifndef LINK_SSP_SPEC
-#ifdef TARGET_LIBC_PROVIDES_SSP
+#if DEFAULT_LIBC == LIBC_MUSL
+#define LINK_SSP_SPEC "-lssp_nonshared"
+#elif defined(TARGET_LIBC_PROVIDES_SSP)
#define LINK_SSP_SPEC "%{fstack-protector:}"
#else
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp}"
......@@ -17,7 +17,7 @@
#endif
#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc%{msoft-float:-sf}.so.1"
+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
#if DEFAULT_LIBC == LIBC_UCLIBC
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
......@@ -72,7 +72,7 @@
#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc%{msoft-float:-sf}.so.1"
#if DEFAULT_LIBC == LIBC_UCLIBC
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
......
......@@ -3,6 +3,6 @@ if USE_MUSL
config MUSL_VERSION
string
depends on USE_MUSL
default "1.1.9"
default "1.1.11"
endif
......@@ -11,7 +11,7 @@ PKG_NAME:=musl
PKG_VERSION:=$(call qstrip,$(CONFIG_MUSL_VERSION))
PKG_RELEASE=1
PKG_MD5SUM:=14e8c5ac74f887d53256b3dcaf9b4aaa
PKG_MD5SUM:=48be0777e32f374d387e9cf85e36ec4d
PKG_SOURCE_URL:=http://www.musl-libc.org/releases
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
......
This diff is collapsed.
From: Felix Fietkau <nbd@openwrt.org>
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 <nbd@openwrt.org>
---
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
--- 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;
From 7ec87fbbc3cac99b4173d082dd6195f47c9a32e7 Mon Sep 17 00:00:00 2001
From: Steven Barth <steven@midlink.org>
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 <steven@midlink.org>
---
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(); }
--- 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),)
--- a/src/locale/iconv.c
+++ b/src/locale/iconv.c
@@ -38,6 +38,7 @@ static const unsigned char charmaps[] =
@@ -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"
......@@ -8,7 +8,7 @@
"eucjp\0\0\320"
"shiftjis\0sjis\0\0\321"
"gb18030\0\0\330"
@@ -45,6 +46,7 @@ static const unsigned char charmaps[] =
@@ -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"
......@@ -16,7 +16,7 @@
#include "codepages.h"
;
@@ -52,6 +54,7 @@ static const unsigned short legacy_chars
@@ -53,6 +55,7 @@ static const unsigned short legacy_chars
#include "legacychars.h"
};
......@@ -24,7 +24,7 @@
static const unsigned short jis0208[84][94] = {
#include "jis0208.h"
};
@@ -71,6 +74,7 @@ static const unsigned short hkscs[] = {
@@ -72,6 +75,7 @@ static const unsigned short hkscs[] = {
static const unsigned short ksc[93][94] = {
#include "ksc.h"
};
......@@ -32,7 +32,7 @@
static int fuzzycmp(const unsigned char *a, const unsigned char *b)
{
@@ -212,6 +216,7 @@ size_t iconv(iconv_t cd0, char **restric
@@ -216,6 +220,7 @@ size_t iconv(iconv_t cd0, char **restric
c = ((c-0xd7c0)<<10) + (d-0xdc00);
}
break;
......@@ -40,7 +40,7 @@
case SHIFT_JIS:
if (c-0xa1 <= 0xdf-0xa1) {
c += 0xff61-0xa1;
@@ -358,6 +363,7 @@ size_t iconv(iconv_t cd0, char **restric
@@ -362,6 +367,7 @@ size_t iconv(iconv_t cd0, char **restric
c = ksc[c][d];
if (!c) goto ilseq;
break;
......
--- a/src/crypt/crypt_r.c
+++ b/src/crypt/crypt_r.c
@@ -16,17 +16,7 @@ char *__crypt_r(const char *key, const c
* use the structure to store any internal state, and treats
* it purely as a char buffer for storing the result. */
char *output = (char *)data;
- 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);
+ return __crypt_md5(key, salt, output);
}
weak_alias(__crypt_r, crypt_r);
--- a/src/crypt/crypt_sha512.c
+++ b/src/crypt/crypt_sha512.c
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <string.h>
#include <stdint.h>
+#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 <string.h>
#include <stdint.h>
+#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_des.c
+++ b/src/crypt/crypt_des.c
@@ -56,6 +56,7 @@
#include <stdint.h>
#include <string.h>
+#if 0
struct expanded_key {
uint32_t l[16], r[16];
};
@@ -1016,3 +1017,4 @@ char *__crypt_des(const char *key, const
return (setting[0]=='*') ? "x" : "*";
}
+#endif
--- a/src/crypt/encrypt.c
+++ b/src/crypt/encrypt.c
@@ -16,6 +16,7 @@ static struct expanded_key __encrypt_key
void setkey(const char *key)
{
+#if 0
unsigned char bkey[8];
int i, j;
@@ -26,10 +27,12 @@ void setkey(const char *key)
}
__des_setkey(bkey, &__encrypt_key);
+#endif
}
void encrypt(char *block, int edflag)
{
+#if 0
struct expanded_key decrypt_key, *key;
uint32_t b[2];
int i, j;
@@ -57,4 +60,5 @@ void encrypt(char *block, int edflag)
for (i = 0; i < 2; i++)
for (j = 31; j >= 0; j--)
*p++ = b[i]>>j & 1;
+#endif
}
--- a/src/crypt/crypt_sha256.c
+++ b/src/crypt/crypt_sha256.c
@@ -13,6 +13,7 @@
#include <string.h>
#include <stdint.h>
+#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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment