aboutsummaryrefslogtreecommitdiffstats
path: root/toolchain
diff options
context:
space:
mode:
authorJames <>2015-09-26 12:29:31 +0100
committerJames <>2015-09-26 12:29:31 +0100
commit626d9efa74685720020e816f3a917b7591d3cf7a (patch)
treed22eef73ae82287b30a1140decb4fc806d39d621 /toolchain
downloadtrunk-47048-626d9efa74685720020e816f3a917b7591d3cf7a.tar.gz
trunk-47048-626d9efa74685720020e816f3a917b7591d3cf7a.tar.bz2
trunk-47048-626d9efa74685720020e816f3a917b7591d3cf7a.zip
trunk-47048
Diffstat (limited to 'toolchain')
-rw-r--r--toolchain/Config.in306
-rw-r--r--toolchain/Makefile82
-rw-r--r--toolchain/binutils/Config.in29
-rw-r--r--toolchain/binutils/Makefile102
-rw-r--r--toolchain/binutils/patches/2.25.1/300-001_ld_makefile_patch.patch22
-rw-r--r--toolchain/binutils/patches/2.25.1/300-012_check_ldrunpath_length.patch20
-rw-r--r--toolchain/binutils/patches/2.25.1/400-mips_no_dynamic_linking_sym.patch18
-rw-r--r--toolchain/binutils/patches/2.25.1/500-Change-default-emulation-for-mips64-linux.patch37
-rw-r--r--toolchain/binutils/patches/linaro/300-001_ld_makefile_patch.patch22
-rw-r--r--toolchain/binutils/patches/linaro/300-012_check_ldrunpath_length.patch20
-rw-r--r--toolchain/binutils/patches/linaro/400-mips_no_dynamic_linking_sym.patch18
-rw-r--r--toolchain/binutils/patches/linaro/500-Change-default-emulation-for-mips64-linux.patch37
-rw-r--r--toolchain/fortify-headers/Makefile28
-rw-r--r--toolchain/gcc/Config.in71
-rw-r--r--toolchain/gcc/Config.version25
-rw-r--r--toolchain/gcc/common.mk196
-rw-r--r--toolchain/gcc/files/alternate-arch-cc.in3
-rw-r--r--toolchain/gcc/final/Makefile82
-rw-r--r--toolchain/gcc/initial/Makefile36
-rw-r--r--toolchain/gcc/minimal/Makefile46
-rw-r--r--toolchain/gcc/patches/4.6-linaro/010-documentation.patch23
-rw-r--r--toolchain/gcc/patches/4.6-linaro/020-gcc_bug_54295.patch70
-rw-r--r--toolchain/gcc/patches/4.6-linaro/030-gcc_bug_48403.patch16
-rw-r--r--toolchain/gcc/patches/4.6-linaro/040-gcc_bug_49696.patch65
-rw-r--r--toolchain/gcc/patches/4.6-linaro/100-uclibc-conf.patch33
-rw-r--r--toolchain/gcc/patches/4.6-linaro/200-musl.patch240
-rw-r--r--toolchain/gcc/patches/4.6-linaro/301-missing-execinfo_h.patch11
-rw-r--r--toolchain/gcc/patches/4.6-linaro/302-c99-snprintf.patch11
-rw-r--r--toolchain/gcc/patches/4.6-linaro/305-libmudflap-susv3-legacy.patch47
-rw-r--r--toolchain/gcc/patches/4.6-linaro/800-arm_v5te_no_ldrd_strd.patch11
-rw-r--r--toolchain/gcc/patches/4.6-linaro/810-arm-softfloat-libgcc.patch26
-rw-r--r--toolchain/gcc/patches/4.6-linaro/820-libgcc_pic.patch36
-rw-r--r--toolchain/gcc/patches/4.6-linaro/830-arm_unbreak_armv4t.patch13
-rw-r--r--toolchain/gcc/patches/4.6-linaro/840-armv4_pass_fix-v4bx_to_ld.patch19
-rw-r--r--toolchain/gcc/patches/4.6-linaro/850-use_shared_libgcc.patch86
-rw-r--r--toolchain/gcc/patches/4.6-linaro/860-uclibc_use_eh_frame.patch29
-rw-r--r--toolchain/gcc/patches/4.6-linaro/870-ppc_no_crtsavres.patch20
-rw-r--r--toolchain/gcc/patches/4.6-linaro/880-no_java_section.patch11
-rw-r--r--toolchain/gcc/patches/4.6-linaro/900-bad-mips16-crt9
-rw-r--r--toolchain/gcc/patches/4.6-linaro/910-mbsd_multi.patch253
-rw-r--r--toolchain/gcc/patches/4.6-linaro/920-specs_nonfatal_getenv.patch14
-rw-r--r--toolchain/gcc/patches/4.6-linaro/940-no-clobber-stamp-bits.patch11
-rw-r--r--toolchain/gcc/patches/4.6-linaro/999-coldfire.patch11
-rw-r--r--toolchain/gcc/patches/4.6-linaro/999-gcc5-gcc_cp_cfns_h.patch21
-rw-r--r--toolchain/gcc/patches/4.8-linaro/001-revert_register_mode_search.patch65
-rw-r--r--toolchain/gcc/patches/4.8-linaro/002-weak_data_fix.patch42
-rw-r--r--toolchain/gcc/patches/4.8-linaro/003-universal_initializer.patch94
-rw-r--r--toolchain/gcc/patches/4.8-linaro/004-case_insensitive.patch14
-rw-r--r--toolchain/gcc/patches/4.8-linaro/010-documentation.patch23
-rw-r--r--toolchain/gcc/patches/4.8-linaro/020-no-plt-backport.patch28
-rw-r--r--toolchain/gcc/patches/4.8-linaro/100-uclibc-conf.patch33
-rw-r--r--toolchain/gcc/patches/4.8-linaro/200-musl_config.patch204
-rw-r--r--toolchain/gcc/patches/4.8-linaro/201-musl_arm.patch40
-rw-r--r--toolchain/gcc/patches/4.8-linaro/202-musl_mips.patch13
-rw-r--r--toolchain/gcc/patches/4.8-linaro/203-musl_powerpc.patch100
-rw-r--r--toolchain/gcc/patches/4.8-linaro/204-musl_sh.patch17
-rw-r--r--toolchain/gcc/patches/4.8-linaro/205-musl_x86.patch48
-rw-r--r--toolchain/gcc/patches/4.8-linaro/206-musl_aarch64.patch14
-rw-r--r--toolchain/gcc/patches/4.8-linaro/207-musl_fixincludes.patch12
-rw-r--r--toolchain/gcc/patches/4.8-linaro/208-musl_gomp.patch11
-rw-r--r--toolchain/gcc/patches/4.8-linaro/209-musl_libstdc++.patch26
-rw-r--r--toolchain/gcc/patches/4.8-linaro/210-disable_libsanitizer_off_t_check.patch11
-rw-r--r--toolchain/gcc/patches/4.8-linaro/220-musl_mips_softfloat.patch8
-rw-r--r--toolchain/gcc/patches/4.8-linaro/221-musl_mips64.patch22
-rw-r--r--toolchain/gcc/patches/4.8-linaro/230-musl_libssp.patch13
-rw-r--r--toolchain/gcc/patches/4.8-linaro/800-arm_v5te_no_ldrd_strd.patch11
-rw-r--r--toolchain/gcc/patches/4.8-linaro/810-arm-softfloat-libgcc.patch25
-rw-r--r--toolchain/gcc/patches/4.8-linaro/820-libgcc_pic.patch36
-rw-r--r--toolchain/gcc/patches/4.8-linaro/830-arm_unbreak_armv4t.patch13
-rw-r--r--toolchain/gcc/patches/4.8-linaro/840-armv4_pass_fix-v4bx_to_ld.patch19
-rw-r--r--toolchain/gcc/patches/4.8-linaro/850-use_shared_libgcc.patch47
-rw-r--r--toolchain/gcc/patches/4.8-linaro/851-libgcc_no_compat.patch12
-rw-r--r--toolchain/gcc/patches/4.8-linaro/860-use_eh_frame.patch42
-rw-r--r--toolchain/gcc/patches/4.8-linaro/870-ppc_no_crtsavres.patch11
-rw-r--r--toolchain/gcc/patches/4.8-linaro/880-no_java_section.patch11
-rw-r--r--toolchain/gcc/patches/4.8-linaro/900-bad-mips16-crt.patch9
-rw-r--r--toolchain/gcc/patches/4.8-linaro/910-mbsd_multi.patch253
-rw-r--r--toolchain/gcc/patches/4.8-linaro/920-specs_nonfatal_getenv.patch14
-rw-r--r--toolchain/gcc/patches/4.8-linaro/930-fix-mips-noexecstack.patch111
-rw-r--r--toolchain/gcc/patches/4.8-linaro/940-no-clobber-stamp-bits.patch11
-rw-r--r--toolchain/gcc/patches/4.8-linaro/951-arm_bug_58595.patch117
-rw-r--r--toolchain/gcc/patches/5.2.0/001-revert_register_mode_search.patch65
-rw-r--r--toolchain/gcc/patches/5.2.0/002-case_insensitive.patch14
-rw-r--r--toolchain/gcc/patches/5.2.0/010-documentation.patch23
-rw-r--r--toolchain/gcc/patches/5.2.0/020-no-plt-backport.patch28
-rw-r--r--toolchain/gcc/patches/5.2.0/030-fix-arm-codegen-PR-65932.patch21
-rw-r--r--toolchain/gcc/patches/5.2.0/100-uclibc-conf.patch33
-rw-r--r--toolchain/gcc/patches/5.2.0/200-musl_config.patch309
-rw-r--r--toolchain/gcc/patches/5.2.0/201-musl_arm.patch43
-rw-r--r--toolchain/gcc/patches/5.2.0/202-musl_mips.patch35
-rw-r--r--toolchain/gcc/patches/5.2.0/203-musl_powerpc.patch209
-rw-r--r--toolchain/gcc/patches/5.2.0/204-musl_sh.patch39
-rw-r--r--toolchain/gcc/patches/5.2.0/205-musl_x86.patch41
-rw-r--r--toolchain/gcc/patches/5.2.0/206-musl_aarch64.patch31
-rw-r--r--toolchain/gcc/patches/5.2.0/207-musl_fixincludes.patch30
-rw-r--r--toolchain/gcc/patches/5.2.0/209-musl_libstdc++.patch72
-rw-r--r--toolchain/gcc/patches/5.2.0/230-musl_libssp.patch13
-rw-r--r--toolchain/gcc/patches/5.2.0/240-musl-libitm-fixes.patch61
-rw-r--r--toolchain/gcc/patches/5.2.0/250-add-musl.patch120
-rw-r--r--toolchain/gcc/patches/5.2.0/260-musl-add-unwind-fix.patch34
-rw-r--r--toolchain/gcc/patches/5.2.0/270-musl-add-powerpc-softfloat-fix.patch24
-rw-r--r--toolchain/gcc/patches/5.2.0/800-arm_v5te_no_ldrd_strd.patch11
-rw-r--r--toolchain/gcc/patches/5.2.0/810-arm-softfloat-libgcc.patch25
-rw-r--r--toolchain/gcc/patches/5.2.0/820-libgcc_pic.patch36
-rw-r--r--toolchain/gcc/patches/5.2.0/830-arm_unbreak_armv4t.patch13
-rw-r--r--toolchain/gcc/patches/5.2.0/840-armv4_pass_fix-v4bx_to_ld.patch19
-rw-r--r--toolchain/gcc/patches/5.2.0/850-use_shared_libgcc.patch47
-rw-r--r--toolchain/gcc/patches/5.2.0/851-libgcc_no_compat.patch12
-rw-r--r--toolchain/gcc/patches/5.2.0/870-ppc_no_crtsavres.patch11
-rw-r--r--toolchain/gcc/patches/5.2.0/880-no_java_section.patch11
-rw-r--r--toolchain/gcc/patches/5.2.0/900-bad-mips16-crt.patch9
-rw-r--r--toolchain/gcc/patches/5.2.0/910-mbsd_multi.patch222
-rw-r--r--toolchain/gcc/patches/5.2.0/920-specs_nonfatal_getenv.patch15
-rw-r--r--toolchain/gcc/patches/5.2.0/930-fix-mips-noexecstack.patch111
-rw-r--r--toolchain/gcc/patches/5.2.0/940-no-clobber-stamp-bits.patch11
-rw-r--r--toolchain/gdb/Makefile49
-rw-r--r--toolchain/gdb/patches/100-no_extern_inline.patch32
-rw-r--r--toolchain/gdb/patches/110-no_testsuite.patch21
-rw-r--r--toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch11
-rw-r--r--toolchain/glibc/Config.in21
-rw-r--r--toolchain/glibc/Config.version26
-rw-r--r--toolchain/glibc/Makefile31
-rw-r--r--toolchain/glibc/common.mk109
-rw-r--r--toolchain/glibc/config/Config.in903
-rw-r--r--toolchain/glibc/headers/Makefile27
-rw-r--r--toolchain/glibc/include/libintl.h6
-rw-r--r--toolchain/glibc/patches/2.15/001-fix_autoconf_macro.patch48
-rw-r--r--toolchain/glibc/patches/2.15/005-versions.patch11
-rw-r--r--toolchain/glibc/patches/2.15/050-all_glibc-2.14-leak-revert-crash.patch110
-rw-r--r--toolchain/glibc/patches/2.15/100-fix_cross_rpcgen.patch71
-rw-r--r--toolchain/glibc/patches/2.15/110-fix_cross_zic.patch27
-rw-r--r--toolchain/glibc/patches/2.15/120-use_host_cflags.patch22
-rw-r--r--toolchain/glibc/patches/2.15/200-add-dl-search-paths.patch14
-rw-r--r--toolchain/glibc/patches/2.19/100-fix_cross_rpcgen.patch52
-rw-r--r--toolchain/glibc/patches/2.19/200-add-dl-search-paths.patch14
-rw-r--r--toolchain/glibc/patches/2.19/300-require-autoconf-2.69.patch13
-rw-r--r--toolchain/glibc/patches/2.21/100-fix_cross_rpcgen.patch52
-rw-r--r--toolchain/glibc/patches/2.21/200-add-dl-search-paths.patch14
-rw-r--r--toolchain/info.mk6
-rw-r--r--toolchain/insight/Makefile54
-rw-r--r--toolchain/insight/patches/600-fix-compile-flag-mismatch.patch31
-rw-r--r--toolchain/kernel-headers/Makefile100
-rw-r--r--toolchain/musl/Config.in6
-rw-r--r--toolchain/musl/Config.version8
-rw-r--r--toolchain/musl/Makefile31
-rw-r--r--toolchain/musl/common.mk69
-rw-r--r--toolchain/musl/headers/Makefile16
-rw-r--r--toolchain/musl/include/bits/wordsize.h1
-rw-r--r--toolchain/musl/include/features.h48
-rw-r--r--toolchain/musl/include/sgidefs.h73
-rw-r--r--toolchain/musl/include/sys/cdefs.h378
-rw-r--r--toolchain/musl/include/sys/glibc-types.h35
-rw-r--r--toolchain/musl/include/sys/queue.h574
-rw-r--r--toolchain/musl/patches/010-Add-PowerPC-soft-float-support.patch154
-rw-r--r--toolchain/musl/patches/100-add_glob_onlydir.patch11
-rw-r--r--toolchain/musl/patches/110-read_timezone_from_fs.patch28
-rw-r--r--toolchain/musl/patches/200-add_libssp_nonshared.patch50
-rw-r--r--toolchain/musl/patches/300-relative.patch11
-rw-r--r--toolchain/musl/patches/900-iconv_size_hack.patch68
-rw-r--r--toolchain/musl/patches/901-crypt_size_hack.patch110
-rw-r--r--toolchain/uClibc/Config.in21
-rw-r--r--toolchain/uClibc/Config.version9
-rw-r--r--toolchain/uClibc/Makefile41
-rw-r--r--toolchain/uClibc/common.mk96
-rw-r--r--toolchain/uClibc/config-0.9.33.2/arm7
-rw-r--r--toolchain/uClibc/config-0.9.33.2/armeb7
-rw-r--r--toolchain/uClibc/config-0.9.33.2/common214
-rw-r--r--toolchain/uClibc/config-0.9.33.2/debug6
-rw-r--r--toolchain/uClibc/config-0.9.33.2/i38621
-rw-r--r--toolchain/uClibc/config-0.9.33.2/i68621
-rw-r--r--toolchain/uClibc/config-0.9.33.2/m68k6
-rw-r--r--toolchain/uClibc/config-0.9.33.2/mips17
-rw-r--r--toolchain/uClibc/config-0.9.33.2/mips6417
-rw-r--r--toolchain/uClibc/config-0.9.33.2/mips64.3218
-rw-r--r--toolchain/uClibc/config-0.9.33.2/mips64.6418
-rw-r--r--toolchain/uClibc/config-0.9.33.2/mips64.n3218
-rw-r--r--toolchain/uClibc/config-0.9.33.2/mips64el17
-rw-r--r--toolchain/uClibc/config-0.9.33.2/mips64el.3218
-rw-r--r--toolchain/uClibc/config-0.9.33.2/mips64el.6418
-rw-r--r--toolchain/uClibc/config-0.9.33.2/mips64el.n3218
-rw-r--r--toolchain/uClibc/config-0.9.33.2/mipsel17
-rw-r--r--toolchain/uClibc/config-0.9.33.2/mipsel.cobalt17
-rw-r--r--toolchain/uClibc/config-0.9.33.2/powerpc6
-rw-r--r--toolchain/uClibc/config-0.9.33.2/powerpc.e5006
-rw-r--r--toolchain/uClibc/config-0.9.33.2/sparc8
-rw-r--r--toolchain/uClibc/config-0.9.33.2/sparc.leon8
-rw-r--r--toolchain/uClibc/config-0.9.33.2/x86_646
-rw-r--r--toolchain/uClibc/headers/Makefile26
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/009_backport_mount.h-update.patch91
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/010-backport_sscanf_alloc.patch184
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/011-dlsym_rtld_next_fix.patch25
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/012-elf-Add-STT_GNU_IFUNC-from-glibc.patch37
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/020-endian.h-add-some-handy-macros-to-be-used-in-syscall.patch28
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/021-add-posix_madvise.c.patch48
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/022-libc-add-posix_fallocate.patch301
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/023-libc-add-fallocate-and-fallocate64.patch447
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/024-i386-bits-syscalls.h-allow-immediate-values-as-6th-s.patch25
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/025-libc-sync_file_range.patch57
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/100-fix_unifdef.patch11
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/110-compat_macros.patch51
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/120-adjtimex.patch14
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/131-inet-fix-__read_etc_hosts_r-segfault.patch10
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/132-inet_fix_res_init.patch15
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/133-inet6-scoped-getnameinfo.patch26
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/135-inet_fix_threaded_use_of_res_functions.patch126
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/136-inet_make_res_init_thread_safe.patch53
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/137-inet_fix_threaded_res_init.patch10
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/150-vasprintf_size_reduce.patch37
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/170-math_finite.patch23
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/180-pthread_cleanup_fix.patch45
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/190-nptl_use_arch_default_stack_limit.patch13
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/200-no_forced_unwind.patch10
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/210-mips_use_pic_crt1.patch11
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/350-use-fputs_unlocked.patch19
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/410-llvm_workaround.patch11
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/450-powerpc_copysignl.patch103
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/460-powerpc_ptrace_h.patch96
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/470-powerpc_syscall6.patch10
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/480-powerpc_rel24_support.patch26
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/500-eventfd.patch53
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/600-mips64_abi_selection.patch48
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/610-mips64_syscall_fix.patch285
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/611-mips_syscall_error_argument.patch99
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/612-mips64_relocation_fix.patch29
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/613-mips64_more_relocation_fixes.patch20
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/614-mips64_fix_setjmp_longjmp.patch99
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/615-mips_fix_sigev_pad_size.patch58
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/616-mips_fix_stat_time.patch123
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/617-mips_fix_setjmp_ptrsize.patch58
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/618-mips64_fix_syscall_error.patch36
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/619-mips64_fix_sysdep_cancel.patch195
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/960-remove_eabi_oabi_selection.patch32
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/970-add___kernel_long_and___kernel_ulong.patch320
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/981-fix_setting_arch_native_bit.patch28
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/990-no-stack-cache.patch11
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/991-gen_wctype.patch183
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/995-add-sigsys-to-siginfo_t-union.patch145
-rw-r--r--toolchain/uClibc/patches-0.9.33.2/999-eventfd_use_bits_scheme.patch248
-rw-r--r--toolchain/uClibc/utils/Makefile24
-rw-r--r--toolchain/wrapper/Makefile62
240 files changed, 14031 insertions, 0 deletions
diff --git a/toolchain/Config.in b/toolchain/Config.in
new file mode 100644
index 0000000..1e94602
--- /dev/null
+++ b/toolchain/Config.in
@@ -0,0 +1,306 @@
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+menuconfig TARGET_OPTIONS
+ bool "Target Options" if DEVEL
+
+ config TARGET_OPTIMIZATION
+ string "Target Optimizations" if TARGET_OPTIONS
+ default DEFAULT_TARGET_OPTIMIZATION
+ help
+ Optimizations to use when building for the target host.
+
+ config SOFT_FLOAT
+ bool "Use software floating point by default" if TARGET_OPTIONS
+ default y if !HAS_FPU
+ depends on arm || armeb || powerpc || mipsel || mips || mips64el || mips64
+ help
+ If your target CPU does not have a Floating Point Unit (FPU) or a
+ kernel FPU emulator, but you still wish to support floating point
+ functions, then everything will need to be compiled with soft floating
+ point support (-msoft-float).
+
+ Most people will answer N.
+
+ config USE_MIPS16
+ bool "Build packages with MIPS16 instructions" if TARGET_OPTIONS
+ depends on HAS_MIPS16
+ depends on !GCC_VERSION_4_6
+ default y
+ help
+ If your target CPU does support the MIPS16 instruction set
+ and you want to use it for packages, enable this option.
+ MIPS16 produces smaller binaries thus reducing pressure on
+ caches and TLB.
+
+ Most people will answer N.
+
+
+menuconfig EXTERNAL_TOOLCHAIN
+ bool
+ prompt "Use external toolchain" if DEVEL
+ help
+ If enabled, OpenWrt will compile using an existing toolchain instead of
+ compiling one.
+
+ config NATIVE_TOOLCHAIN
+ bool
+ prompt "Use host's toolchain" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN
+ select NO_STRIP
+ help
+ If enabled, OpenWrt will compile using the native toolchain for your
+ host instead of compiling one.
+
+ config TARGET_NAME
+ string
+ prompt "Target name" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "aarch64-unknown-linux-gnu" if aarch64
+ default "aarch64_be-unknown-linux-gnu" if aarch64_be
+ default "arm-unknown-linux-gnu" if arm
+ default "armeb-unknown-linux-gnu" if armeb
+ default "i486-unknown-linux-gnu" if i386
+ default "mips-unknown-linux-gnu" if mips
+ default "mipsel-unknown-linux-gnu" if mipsel
+ default "powerpc-unknown-linux-gnu" if powerpc
+ default "x86_64-unknown-linux-gnu" if x86_64
+
+ config TOOLCHAIN_PREFIX
+ string
+ prompt "Toolchain prefix" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "aarch64-unknown-linux-gnu" if aarch64
+ default "aarch64_be-unknown-linux-gnu" if aarch64_be
+ default "arm-unknown-linux-gnu-" if arm
+ default "armeb-unknown-linux-gnu-" if armeb
+ default "i486-unknown-linux-gnu-" if i386
+ default "mips-unknown-linux-gnu-" if mips
+ default "mipsel-unknown-linux-gnu-" if mipsel
+ default "powerpc-unknown-linux-gnu-" if powerpc
+ default "x86_64-unknown-linux-gnu-" if x86_64
+
+ config TOOLCHAIN_ROOT
+ string
+ prompt "Toolchain root" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "/opt/cross/aarch64-unknown-linux-gnu" if aarch64
+ default "/opt/cross/aarch64_be-unknown-linux-gnu" if aarch64_be
+ default "/opt/cross/arm-unknown-linux-gnu" if arm
+ default "/opt/cross/armeb-unknown-linux-gnu" if armeb
+ default "/opt/cross/i486-unknown-linux-gnu" if i386
+ default "/opt/cross/mips-unknown-linux-gnu" if mips
+ default "/opt/cross/mipsel-unknown-linux-gnu" if mipsel
+ default "/opt/cross/powerpc-unknown-linux-gnu" if powerpc
+ default "/opt/cross/x86_64-unknown-linux-gnu" if x86_64
+
+ config TOOLCHAIN_LIBC
+ string
+ prompt "Toolchain libc" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "uclibc"
+ help
+ Specify the libc type used by the external toolchain. The given value
+ is passed as -m flag to all gcc and g++ invocations. This is mainly
+ intended for multilib toolchains which support glibc and uclibc at
+ the same time. If no value is specified, no -m flag is passed.
+
+ config TOOLCHAIN_BIN_PATH
+ string
+ prompt "Toolchain program path" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "./usr/bin ./bin"
+ help
+ Specify additional directories searched for toolchain binaries
+ (override PATH). Use ./DIR for directories relative to the root above.
+
+ config TOOLCHAIN_INC_PATH
+ string
+ prompt "Toolchain include path" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "./usr/include ./include"
+ help
+ Specify additional directories searched for header files (override
+ CPPFLAGS). Use ./DIR for directories relative to the root above.
+
+ config TOOLCHAIN_LIB_PATH
+ string
+ prompt "Toolchain library path" if DEVEL
+ depends on EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+ default "./usr/lib ./lib"
+ help
+ Specify additional directories searched for libraries (override LDFLAGS).
+ Use ./DIR for directories relative to the root above.
+
+config NEED_TOOLCHAIN
+ bool
+ depends on DEVEL
+ default y if !EXTERNAL_TOOLCHAIN
+
+menuconfig TOOLCHAINOPTS
+ bool "Toolchain Options" if DEVEL
+ depends on NEED_TOOLCHAIN
+
+menuconfig EXTRA_TARGET_ARCH
+ bool
+ prompt "Enable an extra toolchain target architecture" if TOOLCHAINOPTS
+ depends on !sparc
+ default y if powerpc64
+ default n
+ help
+ Some builds may require a 'biarch' toolchain. This option
+ allows you to specify an additional target arch.
+
+ Most people will answer N here.
+
+ config EXTRA_TARGET_ARCH_NAME
+ string
+ default "powerpc64" if powerpc64
+ prompt "Extra architecture name" if EXTRA_TARGET_ARCH
+ help
+ Specify the cpu name (eg powerpc64 or x86_64) of the
+ additional target architecture.
+
+ config EXTRA_TARGET_ARCH_OPTS
+ string
+ default "-m64" if powerpc64
+ prompt "Extra architecture compiler options" if EXTRA_TARGET_ARCH
+ help
+ If you're specifying an addition target architecture,
+ you'll probably need to also provide options to make
+ the compiler use this alternate arch.
+
+ For example, if you're building a compiler that can build
+ both powerpc and powerpc64 binaries, you'll need to
+ specify -m64 here.
+
+
+ choice
+ prompt "MIPS64 user-land ABI" if TOOLCHAINOPTS && (mips64 || mips64el)
+ default MIPS64_ABI_N64
+ help
+ MIPS64 supports 3 different user-land ABIs: o32 (legacy),
+ n32 and n64.
+
+ config MIPS64_ABI_N64
+ bool "n64"
+
+ config MIPS64_ABI_N32
+ bool "n32"
+
+ config MIPS64_ABI_O32
+ bool "o32"
+
+ endchoice
+
+comment "Binary tools"
+ depends on TOOLCHAINOPTS
+
+source "toolchain/binutils/Config.in"
+
+comment "Compiler"
+ depends on TOOLCHAINOPTS
+
+source "toolchain/gcc/Config.in"
+
+comment "C Library"
+ depends on TOOLCHAINOPTS
+
+choice
+ prompt "C Library implementation" if TOOLCHAINOPTS
+ default LIBC_USE_UCLIBC if mips64 || mips64el
+ default LIBC_USE_MUSL
+ help
+ Select the C library implementation.
+
+ config LIBC_USE_GLIBC
+ bool "Use (e)glibc"
+ select USE_GLIBC
+
+ config LIBC_USE_UCLIBC
+ select USE_UCLIBC
+ bool "Use uClibc"
+ depends on !(aarch64 || aarch64_be)
+
+ config LIBC_USE_MUSL
+ select USE_MUSL
+ bool "Use musl"
+ depends on !(mips64 || mips64el)
+
+endchoice
+
+source "toolchain/glibc/Config.in"
+source "toolchain/uClibc/Config.in"
+source "toolchain/musl/Config.in"
+
+comment "Debuggers"
+ depends on TOOLCHAINOPTS
+
+config GDB
+ bool
+ depends on !(aarch64 || aarch64_be)
+ prompt "Build gdb" if TOOLCHAINOPTS
+ default y if !EXTERNAL_TOOLCHAIN
+ help
+ Enable if you want to build the gdb.
+
+config INSIGHT
+ bool
+ prompt "Build insight-gdb" if TOOLCHAINOPTS
+ select GDB
+ default n
+ help
+ Enable if you want to build insight-gdb.
+
+config USE_GLIBC
+ bool
+
+config USE_UCLIBC
+ default y if !TOOLCHAINOPTS && !EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN && (mips64 || mips64el)
+ bool
+
+config USE_MUSL
+ default y if !TOOLCHAINOPTS && !EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN && !(mips64 || mips64el)
+ bool
+
+config USE_EXTERNAL_LIBC
+ bool
+ default y if EXTERNAL_TOOLCHAIN || NATIVE_TOOLCHAIN
+
+source "toolchain/gcc/Config.version"
+
+source "toolchain/glibc/Config.version"
+source "toolchain/uClibc/Config.version"
+source "toolchain/musl/Config.version"
+
+config LIBC
+ string
+ default "glibc" if USE_GLIBC
+ default "uClibc" if USE_UCLIBC
+ default "musl" if USE_MUSL
+
+config LIBC_VERSION
+ string
+ default GLIBC_VERSION if USE_GLIBC
+ default UCLIBC_VERSION if USE_UCLIBC
+ default MUSL_VERSION if USE_MUSL
+
+config TARGET_SUFFIX
+ string
+ default "gnueabi" if USE_GLIBC && (arm || armeb)
+ default "gnu" if USE_GLIBC && !(arm || armeb)
+ default "uclibcgnueabi" if USE_UCLIBC && (arm || armeb)
+ default "uclibc" if USE_UCLIBC && !(arm || armeb)
+ default "muslgnueabi" if USE_MUSL && (arm || armeb)
+ default "musl" if USE_MUSL && !(arm || armeb)
+
+config MIPS64_ABI
+ depends on mips64 || mips64el
+ string
+ default "64" if MIPS64_ABI_N64
+ default "n32" if MIPS64_ABI_N32
+ default "32" if MIPS64_ABI_O32
+ default "64"
diff --git a/toolchain/Makefile b/toolchain/Makefile
new file mode 100644
index 0000000..cd5399e
--- /dev/null
+++ b/toolchain/Makefile
@@ -0,0 +1,82 @@
+#
+# Copyright (C) 2007-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# Main makefile for the toolchain
+#
+# Steps:
+# 1) toolchain/binutils/install
+# build & install binutils
+# 2) toolchain/gcc/minimal/install
+# build & install a minimal gcc, needed for steps 3 & 4
+# 3) toolchain/kernel-headers/install
+# install kernel headers, needed for step 4
+# 4) toolchain/libc/headers/install
+# build & install libc headers & support files, needed for step 5
+# 5) toolchain/gcc/initial/install
+# build & install an initial gcc, needed for step 6
+# 6) toolchain/libc/install
+# build & install the final libc
+# 7) toolchain/gcc/final/install
+# build & install the final gcc
+# 8) toolchain/libc/utils/install
+# build & install libc utilities
+#
+
+curdir:=toolchain
+
+# subdirectories to descend into
+$(curdir)/builddirs := $(if $(CONFIG_GDB),gdb) $(if $(CONFIG_INSIGHT),insight) $(if $(CONFIG_EXTERNAL_TOOLCHAIN),wrapper,kernel-headers binutils gcc/minimal gcc/initial gcc/final $(LIBC)/headers $(LIBC) fortify-headers)
+ifdef CONFIG_USE_UCLIBC
+ $(curdir)/builddirs += $(LIBC)/utils
+endif
+$(curdir)/builddirs-compile:=$($(curdir)/builddirs-prepare)
+$(curdir)/builddirs-install:=$($(curdir)/builddirs-compile)
+
+# builddir dependencies
+ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
+ $(curdir)/gcc/minimal/compile:=$(curdir)/binutils/install
+ $(curdir)/kernel-headers/install:=$(curdir)/gcc/minimal/install
+ $(curdir)/gcc/initial/prepare:=$(curdir)/gcc/minimal/prepare
+ $(curdir)/gcc/final/prepare:=$(curdir)/gcc/initial/prepare
+
+ $(curdir)/$(LIBC)/headers/compile:=$(curdir)/kernel-headers/install
+ $(curdir)/gcc/initial/compile:=$(curdir)/$(LIBC)/headers/install
+ $(curdir)/$(LIBC)/compile:=$(curdir)/gcc/initial/install
+ $(curdir)/gcc/final/compile:=$(curdir)/$(LIBC)/install
+ $(curdir)/$(LIBC)/utils/compile:=$(curdir)/gcc/final/install
+ $(curdir)/$(LIBC)/prepare:=$(curdir)/$(LIBC)/headers/prepare
+ $(curdir)/$(LIBC)/utils/prepare:=$(curdir)/$(LIBC)/headers/prepare
+endif
+
+ifndef DUMP_TARGET_DB
+ifneq ($(ARCH),)
+ $(TOOLCHAIN_DIR)/info.mk: .config
+ @for dir in $(TOOLCHAIN_DIR); do ( \
+ $(if $(QUIET),,set -x;) \
+ mkdir -p "$$dir"; \
+ cd "$$dir"; \
+ ln -nsf lib lib64; \
+ ln -nsf lib lib32; \
+ mkdir -p stamp lib usr/include usr/lib ; \
+ ); done
+ @grep GCC_VERSION $@ >/dev/null 2>&1 || $(INSTALL_DATA) $(TOPDIR)/toolchain/info.mk $@
+ @touch $@
+endif
+endif
+
+# prerequisites for the individual targets
+$(curdir)/ := .config prereq
+$(curdir)//prepare = $(STAGING_DIR)/.prepared $(TOOLCHAIN_DIR)/info.mk $(tools/stamp-install)
+$(curdir)//compile = $(1)/prepare
+$(curdir)//install = $(1)/compile
+
+ifndef DUMP_TARGET_DB
+$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed:
+endif
+
+$(eval $(call stampfile,$(curdir),toolchain,install,$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed,,$(TOOLCHAIN_DIR)))
+$(eval $(call subdir,$(curdir)))
+
diff --git a/toolchain/binutils/Config.in b/toolchain/binutils/Config.in
new file mode 100644
index 0000000..27b2ffa
--- /dev/null
+++ b/toolchain/binutils/Config.in
@@ -0,0 +1,29 @@
+# Choose binutils version.
+
+choice
+ prompt "Binutils Version" if TOOLCHAINOPTS
+ default BINUTILS_VERSION_LINARO
+ help
+ Select the version of binutils you wish to use.
+
+ config BINUTILS_VERSION_LINARO
+ bool "Linaro binutils 2.24"
+
+ config BINUTILS_VERSION_2_25_1
+ bool "Binutils 2.25.1"
+
+endchoice
+
+config EXTRA_BINUTILS_CONFIG_OPTIONS
+ string
+ prompt "Additional binutils configure options" if TOOLCHAINOPTS
+ default ""
+ help
+ Any additional binutils options you may want to include....
+
+config BINUTILS_VERSION
+ string
+ prompt "Binutils Version" if (TOOLCHAINOPTS && NULL)
+ default "linaro" if BINUTILS_VERSION_LINARO
+ default "2.25.1" if BINUTILS_VERSION_2_25_1
+ default "linaro"
diff --git a/toolchain/binutils/Makefile b/toolchain/binutils/Makefile
new file mode 100644
index 0000000..0028a02
--- /dev/null
+++ b/toolchain/binutils/Makefile
@@ -0,0 +1,102 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=binutils
+PKG_VERSION:=$(call qstrip,$(CONFIG_BINUTILS_VERSION))
+BIN_VERSION:=$(PKG_VERSION)
+
+ifeq ($(findstring linaro, $(CONFIG_BINUTILS_VERSION)),linaro)
+ PKG_SOURCE_URL:=https://releases.linaro.org/14.09/components/toolchain/binutils-linaro/
+ PKG_REV:=2.24.0-2014.09
+ PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.xz
+ PKG_MD5SUM:=8f9b2b2e049d59b1b86ce9657802a353
+ BINUTILS_DIR:=$(PKG_NAME)-linaro-$(PKG_REV)
+ HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(BINUTILS_DIR)
+else
+ PKG_SOURCE_URL:=@GNU/binutils/
+ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+
+ ifeq ($(PKG_VERSION),2.25.1)
+ PKG_MD5SUM:=ac493a78de4fee895961d025b7905be4
+ endif
+endif
+
+HOST_BUILD_PARALLEL:=1
+
+PATCH_DIR:=./patches/$(PKG_VERSION)
+
+REAL_STAGING_DIR_HOST:=$(STAGING_DIR_HOST)
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+BINUTILS_CONFIGURE:= \
+ ./configure \
+ --prefix=$(TOOLCHAIN_DIR) \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --with-sysroot=$(TOOLCHAIN_DIR) \
+ --enable-deterministic-archives \
+ --enable-plugins \
+ --disable-multilib \
+ --disable-werror \
+ --disable-nls \
+ $(GRAPHITE_CONFIGURE) \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(call qstrip,$(CONFIG_EXTRA_BINUTILS_CONFIG_OPTIONS))
+
+ifneq ($(CONFIG_SSP_SUPPORT),)
+ BINUTILS_CONFIGURE+= \
+ --enable-libssp
+else
+ BINUTILS_CONFIGURE+= \
+ --disable-libssp
+endif
+
+ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
+ BINUTILS_CONFIGURE+= \
+ --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
+endif
+
+define Host/Prepare
+ $(call Host/Prepare/Default)
+ ln -snf $(notdir $(HOST_BUILD_DIR)) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+ $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/
+ $(SED) 's, " Linaro.*,,' $(HOST_BUILD_DIR)/bfd/version.h
+endef
+
+define Host/Configure
+ (cd $(HOST_BUILD_DIR); \
+ $(BINUTILS_CONFIGURE) \
+ );
+endef
+
+define Host/Compile
+ +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) all
+endef
+
+define Host/Install
+ mkdir -p $(TOOLCHAIN_DIR)/initial
+ $(MAKE) -C $(HOST_BUILD_DIR) \
+ prefix=$(TOOLCHAIN_DIR)/initial \
+ install
+ $(MAKE) -C $(HOST_BUILD_DIR) \
+ prefix=$(TOOLCHAIN_DIR) \
+ install
+ $(call FixupLibdir,$(TOOLCHAIN_DIR)/initial)
+ $(RM) $(TOOLCHAIN_DIR)/initial/lib/libiberty.a
+ $(CP) $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-readelf $(REAL_STAGING_DIR_HOST)/bin/readelf
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/binutils/patches/2.25.1/300-001_ld_makefile_patch.patch b/toolchain/binutils/patches/2.25.1/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000..c51fc00
--- /dev/null
+++ b/toolchain/binutils/patches/2.25.1/300-001_ld_makefile_patch.patch
@@ -0,0 +1,22 @@
+--- a/ld/Makefile.am
++++ b/ld/Makefile.am
+@@ -54,7 +54,7 @@ endif
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- a/ld/Makefile.in
++++ b/ld/Makefile.in
+@@ -388,7 +388,7 @@ AM_CFLAGS = $(WARN_CFLAGS)
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/toolchain/binutils/patches/2.25.1/300-012_check_ldrunpath_length.patch b/toolchain/binutils/patches/2.25.1/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000..2e24b38
--- /dev/null
+++ b/toolchain/binutils/patches/2.25.1/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,20 @@
+--- a/ld/emultempl/elf32.em
++++ b/ld/emultempl/elf32.em
+@@ -1198,6 +1198,8 @@ fragment <<EOF
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -1461,6 +1463,8 @@ gld${EMULATION_NAME}_before_allocation (
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+
+ for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
diff --git a/toolchain/binutils/patches/2.25.1/400-mips_no_dynamic_linking_sym.patch b/toolchain/binutils/patches/2.25.1/400-mips_no_dynamic_linking_sym.patch
new file mode 100644
index 0000000..a63203d
--- /dev/null
+++ b/toolchain/binutils/patches/2.25.1/400-mips_no_dynamic_linking_sym.patch
@@ -0,0 +1,18 @@
+--- a/bfd/elfxx-mips.c
++++ b/bfd/elfxx-mips.c
+@@ -7689,6 +7689,7 @@ _bfd_mips_elf_create_dynamic_sections (b
+
+ name = SGI_COMPAT (abfd) ? "_DYNAMIC_LINK" : "_DYNAMIC_LINKING";
+ bh = NULL;
++ if (0) {
+ if (!(_bfd_generic_link_add_one_symbol
+ (info, abfd, name, BSF_GLOBAL, bfd_abs_section_ptr, 0,
+ NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
+@@ -7701,6 +7702,7 @@ _bfd_mips_elf_create_dynamic_sections (b
+
+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
+ return FALSE;
++ }
+
+ if (! mips_elf_hash_table (info)->use_rld_obj_head)
+ {
diff --git a/toolchain/binutils/patches/2.25.1/500-Change-default-emulation-for-mips64-linux.patch b/toolchain/binutils/patches/2.25.1/500-Change-default-emulation-for-mips64-linux.patch
new file mode 100644
index 0000000..3343a85
--- /dev/null
+++ b/toolchain/binutils/patches/2.25.1/500-Change-default-emulation-for-mips64-linux.patch
@@ -0,0 +1,37 @@
+--- a/bfd/config.bfd
++++ b/bfd/config.bfd
+@@ -1062,12 +1062,12 @@ case "${targ}" in
+ targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec mips_ecoff_be_vec mips_ecoff_le_vec"
+ ;;
+ mips64*el-*-linux*)
+- targ_defvec=mips_elf32_ntrad_le_vec
+- targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec"
++ targ_defvec=mips_elf64_trad_le_vec
++ targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec mips_elf64_trad_be_vec"
+ ;;
+ mips64*-*-linux*)
+- targ_defvec=mips_elf32_ntrad_be_vec
+- targ_selvecs="mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec"
++ targ_defvec=mips_elf64_trad_be_vec
++ targ_selvecs="mips_elf32_ntrad_be_vec mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec mips_elf64_trad_le_vec"
+ ;;
+ mips*el-*-linux*)
+ targ_defvec=mips_elf32_trad_le_vec
+--- a/ld/configure.tgt
++++ b/ld/configure.tgt
+@@ -476,11 +476,11 @@ mips*el-*-vxworks*) targ_emul=elf32elmip
+ mips*-*-vxworks*) targ_emul=elf32ebmipvxworks
+ targ_extra_emuls="elf32elmipvxworks" ;;
+ mips*-*-windiss) targ_emul=elf32mipswindiss ;;
+-mips64*el-*-linux-*) targ_emul=elf32ltsmipn32
+- targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip"
++mips64*el-*-linux-*) targ_emul=elf64ltsmip
++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32ltsmip elf32btsmip elf64btsmip"
+ targ_extra_libpath=$targ_extra_emuls ;;
+-mips64*-*-linux-*) targ_emul=elf32btsmipn32
+- targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip"
++mips64*-*-linux-*) targ_emul=elf64btsmip
++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip elf64ltsmip"
+ targ_extra_libpath=$targ_extra_emuls ;;
+ mips*el-*-linux-*) targ_emul=elf32ltsmip
+ targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
diff --git a/toolchain/binutils/patches/linaro/300-001_ld_makefile_patch.patch b/toolchain/binutils/patches/linaro/300-001_ld_makefile_patch.patch
new file mode 100644
index 0000000..0efcd18
--- /dev/null
+++ b/toolchain/binutils/patches/linaro/300-001_ld_makefile_patch.patch
@@ -0,0 +1,22 @@
+--- a/ld/Makefile.am
++++ b/ld/Makefile.am
+@@ -54,7 +54,7 @@ endif
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+
+ EMUL = @EMUL@
+ EMULATION_OFILES = @EMULATION_OFILES@
+--- a/ld/Makefile.in
++++ b/ld/Makefile.in
+@@ -386,7 +386,7 @@ AM_CFLAGS = $(WARN_CFLAGS)
+ # We put the scripts in the directory $(scriptdir)/ldscripts.
+ # We can't put the scripts in $(datadir) because the SEARCH_DIR
+ # directives need to be different for native and cross linkers.
+-scriptdir = $(tooldir)/lib
++scriptdir = $(libdir)
+ BASEDIR = $(srcdir)/..
+ BFDDIR = $(BASEDIR)/bfd
+ INCDIR = $(BASEDIR)/include
diff --git a/toolchain/binutils/patches/linaro/300-012_check_ldrunpath_length.patch b/toolchain/binutils/patches/linaro/300-012_check_ldrunpath_length.patch
new file mode 100644
index 0000000..37752b7
--- /dev/null
+++ b/toolchain/binutils/patches/linaro/300-012_check_ldrunpath_length.patch
@@ -0,0 +1,20 @@
+--- a/ld/emultempl/elf32.em
++++ b/ld/emultempl/elf32.em
+@@ -1267,6 +1267,8 @@ fragment <<EOF
+ && command_line.rpath == NULL)
+ {
+ lib_path = (const char *) getenv ("LD_RUN_PATH");
++ if ((lib_path) && (strlen (lib_path) == 0))
++ lib_path = NULL;
+ if (gld${EMULATION_NAME}_search_needed (lib_path, &n,
+ force))
+ break;
+@@ -1518,6 +1520,8 @@ gld${EMULATION_NAME}_before_allocation (
+ rpath = command_line.rpath;
+ if (rpath == NULL)
+ rpath = (const char *) getenv ("LD_RUN_PATH");
++ if ((rpath) && (strlen (rpath) == 0))
++ rpath = NULL;
+
+ for (abfd = link_info.input_bfds; abfd; abfd = abfd->link_next)
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
diff --git a/toolchain/binutils/patches/linaro/400-mips_no_dynamic_linking_sym.patch b/toolchain/binutils/patches/linaro/400-mips_no_dynamic_linking_sym.patch
new file mode 100644
index 0000000..251134f
--- /dev/null
+++ b/toolchain/binutils/patches/linaro/400-mips_no_dynamic_linking_sym.patch
@@ -0,0 +1,18 @@
+--- a/bfd/elfxx-mips.c
++++ b/bfd/elfxx-mips.c
+@@ -7450,6 +7450,7 @@ _bfd_mips_elf_create_dynamic_sections (b
+
+ name = SGI_COMPAT (abfd) ? "_DYNAMIC_LINK" : "_DYNAMIC_LINKING";
+ bh = NULL;
++ if (0) {
+ if (!(_bfd_generic_link_add_one_symbol
+ (info, abfd, name, BSF_GLOBAL, bfd_abs_section_ptr, 0,
+ NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
+@@ -7462,6 +7463,7 @@ _bfd_mips_elf_create_dynamic_sections (b
+
+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
+ return FALSE;
++ }
+
+ if (! mips_elf_hash_table (info)->use_rld_obj_head)
+ {
diff --git a/toolchain/binutils/patches/linaro/500-Change-default-emulation-for-mips64-linux.patch b/toolchain/binutils/patches/linaro/500-Change-default-emulation-for-mips64-linux.patch
new file mode 100644
index 0000000..cd036be
--- /dev/null
+++ b/toolchain/binutils/patches/linaro/500-Change-default-emulation-for-mips64-linux.patch
@@ -0,0 +1,37 @@
+--- a/bfd/config.bfd
++++ b/bfd/config.bfd
+@@ -1053,12 +1053,12 @@ case "${targ}" in
+ targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec ecoff_big_vec ecoff_little_vec"
+ ;;
+ mips64*el-*-linux*)
+- targ_defvec=bfd_elf32_ntradlittlemips_vec
+- targ_selvecs="bfd_elf32_ntradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf64_tradlittlemips_vec bfd_elf64_tradbigmips_vec"
++ targ_defvec=bfd_elf64_tradlittlemips_vec
++ targ_selvecs="bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf32_tradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf64_tradbigmips_vec"
+ ;;
+ mips64*-*-linux*)
+- targ_defvec=bfd_elf32_ntradbigmips_vec
+- targ_selvecs="bfd_elf32_ntradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec"
++ targ_defvec=bfd_elf64_tradbigmips_vec
++ targ_selvecs="bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf64_tradlittlemips_vec"
+ ;;
+ mips*el-*-linux*)
+ targ_defvec=bfd_elf32_tradlittlemips_vec
+--- a/ld/configure.tgt
++++ b/ld/configure.tgt
+@@ -472,11 +472,11 @@ mips*el-*-vxworks*) targ_emul=elf32elmip
+ mips*-*-vxworks*) targ_emul=elf32ebmipvxworks
+ targ_extra_emuls="elf32elmipvxworks" ;;
+ mips*-*-windiss) targ_emul=elf32mipswindiss ;;
+-mips64*el-*-linux-*) targ_emul=elf32ltsmipn32
+- targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip"
++mips64*el-*-linux-*) targ_emul=elf64ltsmip
++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32ltsmip elf32btsmip elf64btsmip"
+ targ_extra_libpath=$targ_extra_emuls ;;
+-mips64*-*-linux-*) targ_emul=elf32btsmipn32
+- targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip"
++mips64*-*-linux-*) targ_emul=elf64btsmip
++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip elf64ltsmip"
+ targ_extra_libpath=$targ_extra_emuls ;;
+ mips*el-*-linux-*) targ_emul=elf32ltsmip
+ targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
diff --git a/toolchain/fortify-headers/Makefile b/toolchain/fortify-headers/Makefile
new file mode 100644
index 0000000..8d952c5
--- /dev/null
+++ b/toolchain/fortify-headers/Makefile
@@ -0,0 +1,28 @@
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/target.mk
+
+PKG_NAME:=fortify-headers
+PKG_VERSION:=0.7
+PKG_RELEASE=1
+
+PKG_SOURCE_URL:=http://dl.2f30.org/releases
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_MD5SUM:=3f7c36daa0be000987e8ad8c0a202b42
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+define Host/Compile
+ true
+endef
+
+define Host/Install
+ $(MAKE) -C $(HOST_BUILD_DIR) PREFIX="" DESTDIR="$(TOOLCHAIN_DIR)" install
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/gcc/Config.in b/toolchain/gcc/Config.in
new file mode 100644
index 0000000..2d4400a
--- /dev/null
+++ b/toolchain/gcc/Config.in
@@ -0,0 +1,71 @@
+# Choose gcc version.
+
+choice
+ prompt "GCC compiler Version" if TOOLCHAINOPTS
+ default GCC_USE_VERSION_4_6_LINARO if TARGET_octeon
+ default GCC_USE_VERSION_4_8_LINARO
+ help
+ Select the version of gcc you wish to use.
+
+ config GCC_USE_VERSION_4_6_LINARO
+ select GCC_VERSION_4_6_LINARO
+ bool "gcc 4.6.x with Linaro enhancements"
+
+ config GCC_USE_VERSION_4_8_LINARO
+ select GCC_VERSION_4_8_LINARO
+ bool "gcc 4.8.x with Linaro enhancements"
+
+ config GCC_USE_VERSION_5
+ select GCC_VERSION_5
+ bool "gcc 5.x"
+
+endchoice
+
+config GCC_USE_GRAPHITE
+ bool
+ prompt "Compile in support for the new Graphite framework in GCC 4.4+" if TOOLCHAINOPTS
+
+config GCC_USE_SYSTEM_PPL_CLOOG
+ bool
+ prompt "Use the system versions of PPL and CLooG"
+ depends on GCC_USE_GRAPHITE
+ default n
+
+config EXTRA_GCC_CONFIG_OPTIONS
+ string
+ prompt "Additional gcc configure options" if TOOLCHAINOPTS
+ default ""
+ help
+ Any additional gcc options you may want to include....
+
+config SSP_SUPPORT
+ bool
+ prompt "Enable Stack-Smashing Protection support" if TOOLCHAINOPTS
+ depends on !USE_MUSL
+ default y if !USE_MUSL
+ help
+ Enable Stack-Smashing Protection support
+
+config SJLJ_EXCEPTIONS
+ bool
+ prompt "Use setjump()/longjump() exceptions" if TOOLCHAINOPTS
+ default n
+ help
+ Use old setjump()/longjump() exceptions instead of the newer
+ frame unwinding exceptions handling routines. Warning: increases
+ code size and runtime memory usage.
+
+config INSTALL_LIBGCJ
+ bool
+ prompt "Build/install java compiler and GNU classpath ?" if TOOLCHAINOPTS
+ default n
+ help
+ Build/install java compiler and GNU classpath ?
+
+
+config INSTALL_GFORTRAN
+ bool
+ prompt "Build/install fortran compiler?" if TOOLCHAINOPTS
+ default n
+ help
+ Build/install GNU fortran compiler ?
diff --git a/toolchain/gcc/Config.version b/toolchain/gcc/Config.version
new file mode 100644
index 0000000..9636fca
--- /dev/null
+++ b/toolchain/gcc/Config.version
@@ -0,0 +1,25 @@
+config GCC_VERSION_4_6_LINARO
+ default y if (!TOOLCHAINOPTS && TARGET_octeon)
+ bool
+
+config GCC_VERSION_4_8_LINARO
+ default y if (!TOOLCHAINOPTS && !TARGET_octeon)
+ bool
+
+config GCC_VERSION
+ string
+ default "5.2.0" if GCC_VERSION_5
+ default "4.6-linaro" if GCC_VERSION_4_6_LINARO
+ default "4.8-linaro" if GCC_VERSION_4_8_LINARO
+ default "4.6-linaro"
+
+config GCC_VERSION_4_6
+ bool
+ default y if GCC_VERSION_4_6_LINARO
+
+config GCC_VERSION_4_8
+ bool
+ default y if GCC_VERSION_4_8_LINARO
+
+config GCC_VERSION_5
+ bool
diff --git a/toolchain/gcc/common.mk b/toolchain/gcc/common.mk
new file mode 100644
index 0000000..b33769c
--- /dev/null
+++ b/toolchain/gcc/common.mk
@@ -0,0 +1,196 @@
+#
+# Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
+# Copyright (C) 2005-2006 Felix Fietkau <nbd@openwrt.org>
+# Copyright (C) 2006-2014 OpenWrt.org
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gcc
+GCC_VERSION:=$(call qstrip,$(CONFIG_GCC_VERSION))
+PKG_VERSION:=$(firstword $(subst +, ,$(GCC_VERSION)))
+GCC_DIR:=$(PKG_NAME)-$(PKG_VERSION)
+
+ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
+ LINARO_RELEASE:=
+ ifeq ($(CONFIG_GCC_VERSION),"4.6-linaro")
+ PKG_REV:=4.6-2013.05
+ PKG_VERSION:=4.6.4
+ PKG_VERSION_MAJOR:=4.6
+ PKG_MD5SUM:=26b48802ae1203cd99415026fbf56ed7
+ PKG_COMP:=bz2
+ endif
+ ifeq ($(CONFIG_GCC_VERSION),"4.8-linaro")
+ PKG_REV:=4.8-2014.04
+ PKG_VERSION:=4.8.3
+ PKG_VERSION_MAJOR:=4.8
+ PKG_MD5SUM:=5ba2f3a449b1658ccc09d27cc7ab3c03
+ PKG_COMP:=xz
+ endif
+ ifneq ($(LINARO_RELEASE),)
+ PKG_SOURCE_URL:=http://releases.linaro.org/$(LINARO_RELEASE)/components/toolchain/gcc-linaro/$(PKG_VERSION_MAJOR)
+ else
+ PKG_SOURCE_URL:=http://launchpad.net/gcc-linaro/$(PKG_VERSION_MAJOR)/$(PKG_REV)/+download/
+ endif
+ PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.$(PKG_COMP)
+ GCC_DIR:=gcc-linaro-$(PKG_REV)
+ HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GCC_DIR)
+else
+ PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
+ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+
+ ifeq ($(PKG_VERSION),4.8.0)
+ PKG_MD5SUM:=e6040024eb9e761c3bea348d1fa5abb0
+ endif
+ ifeq ($(PKG_VERSION),5.2.0)
+ PKG_MD5SUM:=a51bcfeb3da7dd4c623e27207ed43467
+ endif
+endif
+
+PATCH_DIR=../patches/$(GCC_VERSION)
+
+BUGURL=https://dev.openwrt.org/
+ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
+ PKGVERSION=OpenWrt/Linaro GCC $(PKG_REV) $(REVISION)
+else
+ PKGVERSION=OpenWrt GCC $(PKG_VERSION) $(REVISION)
+endif
+
+HOST_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+HOST_SOURCE_DIR:=$(HOST_BUILD_DIR)
+ifeq ($(GCC_VARIANT),minimal)
+ GCC_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
+else
+ HOST_BUILD_DIR:=$(HOST_BUILD_DIR)-$(GCC_VARIANT)
+ GCC_BUILD_DIR:=$(HOST_BUILD_DIR)
+endif
+
+HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
+HOST_STAMP_BUILT:=$(GCC_BUILD_DIR)/.built
+HOST_STAMP_CONFIGURED:=$(GCC_BUILD_DIR)/.configured
+HOST_STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.gcc_$(GCC_VARIANT)_installed
+
+SEP:=,
+TARGET_LANGUAGES:="c,c++$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)$(if $(CONFIG_INSTALL_GFORTRAN),$(SEP)fortran)"
+
+export libgcc_cv_fixed_point=no
+ifdef CONFIG_USE_UCLIBC
+ export glibcxx_cv_c99_math_tr1=no
+endif
+
+GCC_CONFIGURE:= \
+ SHELL="$(BASH)" \
+ $(if $(shell gcc --version 2>&1 | grep LLVM), \
+ CFLAGS="-O2 -fbracket-depth=512 -pipe" \
+ CXXFLAGS="-O2 -fbracket-depth=512 -pipe" \
+ ) \
+ $(HOST_SOURCE_DIR)/configure \
+ --with-bugurl=$(BUGURL) \
+ --with-pkgversion="$(PKGVERSION)" \
+ --prefix=$(TOOLCHAIN_DIR) \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --with-gnu-ld \
+ --enable-target-optspace \
+ --disable-libgomp \
+ --disable-libmudflap \
+ --disable-multilib \
+ --disable-nls \
+ $(GRAPHITE_CONFIGURE) \
+ --with-host-libstdcxx=-lstdc++ \
+ $(SOFT_FLOAT_CONFIG_OPTION) \
+ $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
+ $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 \
+ --with-abi=$(call qstrip,$(CONFIG_MIPS64_ABI))) \
+ --with-gmp=$(TOPDIR)/staging_dir/host \
+ --with-mpfr=$(TOPDIR)/staging_dir/host \
+ --with-mpc=$(TOPDIR)/staging_dir/host \
+ --disable-decimal-float
+ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
+ GCC_CONFIGURE += --with-mips-plt
+endif
+
+ifneq ($(CONFIG_SSP_SUPPORT),)
+ GCC_CONFIGURE+= \
+ --enable-libssp
+else
+ GCC_CONFIGURE+= \
+ --disable-libssp
+endif
+
+ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
+ GCC_CONFIGURE+= \
+ --enable-biarch \
+ --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
+endif
+
+ifdef CONFIG_sparc
+ GCC_CONFIGURE+= \
+ --enable-targets=all \
+ --with-long-double-128
+endif
+
+ifeq ($(LIBC),uClibc)
+ GCC_CONFIGURE+= \
+ --disable-__cxa_atexit
+else
+ GCC_CONFIGURE+= \
+ --enable-__cxa_atexit
+endif
+
+ifneq ($(GCC_ARCH),)
+ GCC_CONFIGURE+= --with-arch=$(GCC_ARCH)
+endif
+
+ifneq ($(CONFIG_SOFT_FLOAT),y)
+ ifeq ($(CONFIG_arm),y)
+ GCC_CONFIGURE+= \
+ --with-float=hard
+ endif
+endif
+
+GCC_MAKE:= \
+ export SHELL="$(BASH)"; \
+ $(MAKE) \
+ CFLAGS="$(HOST_CFLAGS)" \
+ CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
+ CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
+
+define Host/Prepare
+ mkdir -p $(GCC_BUILD_DIR)
+endef
+
+define Host/Configure
+ (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
+ $(GCC_CONFIGURE) \
+ );
+endef
+
+define Host/Clean
+ rm -rf \
+ $(STAGING_DIR_HOST)/stamp/.gcc_* \
+ $(STAGING_DIR_HOST)/stamp/.binutils_* \
+ $(GCC_BUILD_DIR) \
+ $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
+ $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
+ $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
+ $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
+endef
diff --git a/toolchain/gcc/files/alternate-arch-cc.in b/toolchain/gcc/files/alternate-arch-cc.in
new file mode 100644
index 0000000..e169951
--- /dev/null
+++ b/toolchain/gcc/files/alternate-arch-cc.in
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec @CC_BASE@ @EXTRA_ARCH_OPTS@ "$@"
diff --git a/toolchain/gcc/final/Makefile b/toolchain/gcc/final/Makefile
new file mode 100644
index 0000000..1212d14
--- /dev/null
+++ b/toolchain/gcc/final/Makefile
@@ -0,0 +1,82 @@
+GCC_VARIANT:=final
+
+include ../common.mk
+
+GCC_CONFIGURE += \
+ --with-headers=$(TOOLCHAIN_DIR)/include \
+ --disable-libsanitizer \
+ --enable-languages=$(TARGET_LANGUAGES) \
+ --enable-shared \
+ --enable-threads \
+ --with-slibdir=$(TOOLCHAIN_DIR)/lib
+
+ifneq ($(CONFIG_GCC_VERSION_4_5)$(CONFIG_GCC_VERSION_4_6),)
+ GCC_CONFIGURE += \
+ --enable-lto \
+ --with-libelf=$(TOPDIR)/staging_dir/host
+endif
+
+ifdef CONFIG_USE_MUSL
+ GCC_MAKE += gcc_cv_libc_provides_ssp=yes
+endif
+
+ifneq ($(CONFIG_SJLJ_EXCEPTIONS),)
+ GCC_CONFIGURE += \
+ --enable-sjlj-exceptions
+endif
+
+define CleanupToolchain
+ $(INSTALL_DIR) $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)
+ # Important! Required for limits.h to be fixed.
+ rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
+ ln -sf ../include $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
+ rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
+ ln -sf ../lib $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
+ $(if $(CONFIG_ARCH_64BIT),ln -sf ../lib64 $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib64)
+endef
+
+define Host/Configure
+ $(CleanupToolchain)
+ mkdir -p $(GCC_BUILD_DIR)
+ (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
+ $(GCC_CONFIGURE) \
+ );
+endef
+
+define Host/Compile
+ +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) all
+endef
+
+define SetupExtraArch
+ for app in $(TOOLCHAIN_DIR)/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
+ [ -e $$$$app ] || continue; \
+ old_base=$$$$(basename $$$$app); \
+ new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
+ sed -e "s/@CC_BASE@/$$$$old_base/" \
+ -e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
+ ../files/alternate-arch-cc.in > \
+ $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
+ chmod a+x $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
+ done
+endef
+
+define Host/Install
+ $(CleanupToolchain)
+ $(_SINGLE)$(GCC_MAKE) -C $(GCC_BUILD_DIR) install
+ # Set up the symlinks to enable lying about target name.
+ set -e; \
+ (cd $(TOOLCHAIN_DIR); \
+ ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
+ cd bin; \
+ for app in $(REAL_GNU_TARGET_NAME)-* ; do \
+ ln -sf $$$${app} \
+ $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
+ done; \
+ );
+ $(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
+ $(RM) $(TOOLCHAIN_DIR)/lib/libiberty.a
+ $(SCRIPT_DIR)/patch-specs.sh "$(TOOLCHAIN_DIR)"
+endef
+
+$(eval $(call HostBuild))
+
diff --git a/toolchain/gcc/initial/Makefile b/toolchain/gcc/initial/Makefile
new file mode 100644
index 0000000..f0c65b5
--- /dev/null
+++ b/toolchain/gcc/initial/Makefile
@@ -0,0 +1,36 @@
+GCC_VARIANT:=initial
+
+include ../common.mk
+
+GCC_CONFIGURE += \
+ --with-newlib \
+ --with-sysroot=$(TOOLCHAIN_DIR) \
+ --enable-languages=c \
+ --disable-shared \
+ --disable-threads \
+
+define Host/Compile
+ $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/
+ +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) \
+ all-build-libiberty \
+ all-gcc \
+ all-target-libgcc
+endef
+
+define Host/Install
+ $(GCC_MAKE) -C $(GCC_BUILD_DIR) \
+ prefix="$(TOOLCHAIN_DIR)/initial" \
+ install-gcc \
+ install-target-libgcc
+
+ # XXX: glibc insists on linking against libgcc_eh
+ ( cd $(TOOLCHAIN_DIR)/initial/lib/gcc/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION) ; \
+ [ -e libgcc_eh.a ] || ln -sf libgcc.a libgcc_eh.a ; \
+ cp libgcc.a libgcc_initial.a; \
+ )
+
+ $(call FixupLibdir,$(TOOLCHAIN_DIR)/initial)
+ $$(call file_copy,$(TOOLCHAIN_DIR)/initial/.,$(TOOLCHAIN_DIR)/)
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/gcc/minimal/Makefile b/toolchain/gcc/minimal/Makefile
new file mode 100644
index 0000000..0344e1a
--- /dev/null
+++ b/toolchain/gcc/minimal/Makefile
@@ -0,0 +1,46 @@
+GCC_VARIANT:=minimal
+
+include ../common.mk
+
+GCC_CONFIGURE += \
+ --with-newlib \
+ --without-headers \
+ --enable-languages=c \
+ --disable-libsanitizer \
+ --disable-libssp \
+ --disable-shared \
+ --disable-threads
+
+define Host/SetToolchainInfo
+ $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+endef
+
+define Host/Prepare
+ $(call Host/SetToolchainInfo)
+ $(call Host/Prepare/Default)
+ ln -snf $(GCC_DIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+ $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/
+ $(SED) 's,^MULTILIB_OSDIRNAMES,# MULTILIB_OSDIRNAMES,' $(HOST_BUILD_DIR)/gcc/config/*/t-*
+ $(SED) 'd' $(HOST_BUILD_DIR)/gcc/DEV-PHASE
+ $(SED) 's, DATESTAMP,,' $(HOST_BUILD_DIR)/gcc/version.c
+ #(cd $(HOST_BUILD_DIR)/libstdc++-v3; autoconf;);
+ $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(HOST_BUILD_DIR)/libstdc++-v3/configure
+ mkdir -p $(GCC_BUILD_DIR)
+endef
+
+define Host/Compile
+ +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) all-gcc all-target-libgcc
+endef
+
+define Host/Install
+ $(GCC_MAKE) -C $(GCC_BUILD_DIR) install-gcc install-target-libgcc
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(GCC_BUILD_DIR)
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/gcc/patches/4.6-linaro/010-documentation.patch b/toolchain/gcc/patches/4.6-linaro/010-documentation.patch
new file mode 100644
index 0000000..46178da
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/010-documentation.patch
@@ -0,0 +1,23 @@
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -4267,18 +4267,10 @@ doc/gcc.info: $(TEXI_GCC_FILES)
+ doc/gccint.info: $(TEXI_GCCINT_FILES)
+ doc/cppinternals.info: $(TEXI_CPPINT_FILES)
+
+-doc/%.info: %.texi
+- if [ x$(BUILD_INFO) = xinfo ]; then \
+- $(MAKEINFO) $(MAKEINFOFLAGS) -I . -I $(gcc_docdir) \
+- -I $(gcc_docdir)/include -o $@ $<; \
+- fi
++doc/%.info:
+
+ # Duplicate entry to handle renaming of gccinstall.info
+-doc/gccinstall.info: $(TEXI_GCCINSTALL_FILES)
+- if [ x$(BUILD_INFO) = xinfo ]; then \
+- $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
+- -I $(gcc_docdir)/include -o $@ $<; \
+- fi
++doc/gccinstall.info:
+
+ doc/cpp.dvi: $(TEXI_CPP_FILES)
+ doc/gcc.dvi: $(TEXI_GCC_FILES)
diff --git a/toolchain/gcc/patches/4.6-linaro/020-gcc_bug_54295.patch b/toolchain/gcc/patches/4.6-linaro/020-gcc_bug_54295.patch
new file mode 100644
index 0000000..5bef9ea
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/020-gcc_bug_54295.patch
@@ -0,0 +1,70 @@
+diff -urN a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
+--- a/gcc/tree-ssa-math-opts.c 2012-12-12 18:05:23.000000000 +0100
++++ b/gcc/tree-ssa-math-opts.c 2013-04-29 15:54:00.051998936 +0200
+@@ -1280,6 +1280,47 @@
+ return result;
+ }
+
++/* Return true if stmt is a type conversion operation that can be stripped
++ when used in a widening multiply operation. */
++static bool
++widening_mult_conversion_strippable_p (tree result_type, gimple stmt)
++{
++ enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
++
++ if (TREE_CODE (result_type) == INTEGER_TYPE)
++ {
++ tree op_type;
++ tree inner_op_type;
++
++ if (!CONVERT_EXPR_CODE_P (rhs_code))
++ return false;
++
++ op_type = TREE_TYPE (gimple_assign_lhs (stmt));
++
++ /* If the type of OP has the same precision as the result, then
++ we can strip this conversion. The multiply operation will be
++ selected to create the correct extension as a by-product. */
++ if (TYPE_PRECISION (result_type) == TYPE_PRECISION (op_type))
++ return true;
++
++ /* We can also strip a conversion if it preserves the signed-ness of
++ the operation and doesn't narrow the range. */
++ inner_op_type = TREE_TYPE (gimple_assign_rhs1 (stmt));
++
++ /* If the inner-most type is unsigned, then we can strip any
++ intermediate widening operation. If it's signed, then the
++ intermediate widening operation must also be signed. */
++ if ((TYPE_UNSIGNED (inner_op_type)
++ || TYPE_UNSIGNED (op_type) == TYPE_UNSIGNED (inner_op_type))
++ && TYPE_PRECISION (op_type) > TYPE_PRECISION (inner_op_type))
++ return true;
++
++ return false;
++ }
++
++ return rhs_code == FIXED_CONVERT_EXPR;
++}
++
+ /* Return true if RHS is a suitable operand for a widening multiplication,
+ assuming a target type of TYPE.
+ There are two cases:
+@@ -1296,17 +1337,13 @@
+ {
+ gimple stmt;
+ tree type1, rhs1;
+- enum tree_code rhs_code;
+
+ if (TREE_CODE (rhs) == SSA_NAME)
+ {
+ stmt = SSA_NAME_DEF_STMT (rhs);
+ if (is_gimple_assign (stmt))
+ {
+- rhs_code = gimple_assign_rhs_code (stmt);
+- if (TREE_CODE (type) == INTEGER_TYPE
+- ? !CONVERT_EXPR_CODE_P (rhs_code)
+- : rhs_code != FIXED_CONVERT_EXPR)
++ if (! widening_mult_conversion_strippable_p (type, stmt))
+ rhs1 = rhs;
+ else
+ {
diff --git a/toolchain/gcc/patches/4.6-linaro/030-gcc_bug_48403.patch b/toolchain/gcc/patches/4.6-linaro/030-gcc_bug_48403.patch
new file mode 100644
index 0000000..69569de
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/030-gcc_bug_48403.patch
@@ -0,0 +1,16 @@
+--- a/gcc/haifa-sched.c
++++ b/gcc/haifa-sched.c
+@@ -4654,10 +4654,12 @@ schedule_block (basic_block *target_bb)
+
+ if (recog_memoized (insn) >= 0)
+ {
++ memcpy (temp_state, curr_state, dfa_state_size);
+ cost = state_transition (curr_state, insn);
+ if (sched_pressure != SCHED_PRESSURE_WEIGHTED)
+ gcc_assert (cost < 0);
+- cycle_issued_insns++;
++ if (memcmp (temp_state, curr_state, dfa_state_size) != 0)
++ cycle_issued_insns++;
+ asm_p = false;
+ }
+ else
diff --git a/toolchain/gcc/patches/4.6-linaro/040-gcc_bug_49696.patch b/toolchain/gcc/patches/4.6-linaro/040-gcc_bug_49696.patch
new file mode 100644
index 0000000..74b9a86
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/040-gcc_bug_49696.patch
@@ -0,0 +1,65 @@
+--- a/gcc/config/mips/sync.md
++++ b/gcc/config/mips/sync.md
+@@ -136,7 +136,7 @@
+ [(match_operand:SI 1 "register_operand" "d")
+ (match_operand:SI 2 "register_operand" "d")
+ (atomic_hiqi_op:SI (match_dup 0)
+- (match_operand:SI 3 "register_operand" "dJ"))]
++ (match_operand:SI 3 "reg_or_0_operand" "dJ"))]
+ UNSPEC_SYNC_OLD_OP_12))
+ (clobber (match_scratch:SI 4 "=&d"))]
+ "GENERATE_LL_SC"
+@@ -177,7 +177,7 @@
+ [(match_operand:SI 2 "register_operand" "d")
+ (match_operand:SI 3 "register_operand" "d")
+ (atomic_hiqi_op:SI (match_dup 0)
+- (match_operand:SI 4 "register_operand" "dJ"))]
++ (match_operand:SI 4 "reg_or_0_operand" "dJ"))]
+ UNSPEC_SYNC_OLD_OP_12))
+ (clobber (match_scratch:SI 5 "=&d"))]
+ "GENERATE_LL_SC"
+@@ -218,7 +218,7 @@
+ (match_operand:SI 2 "register_operand" "d")
+ (match_operand:SI 3 "register_operand" "d")
+ (atomic_hiqi_op:SI (match_dup 0)
+- (match_operand:SI 4 "register_operand" "dJ"))]
++ (match_operand:SI 4 "reg_or_0_operand" "dJ"))]
+ UNSPEC_SYNC_NEW_OP_12))
+ (set (match_dup 1)
+ (unspec_volatile:SI
+@@ -259,7 +259,7 @@
+ [(match_operand:SI 1 "register_operand" "d")
+ (match_operand:SI 2 "register_operand" "d")
+ (match_dup 0)
+- (match_operand:SI 3 "register_operand" "dJ")]
++ (match_operand:SI 3 "reg_or_0_operand" "dJ")]
+ UNSPEC_SYNC_OLD_OP_12))
+ (clobber (match_scratch:SI 4 "=&d"))]
+ "GENERATE_LL_SC"
+@@ -298,7 +298,7 @@
+ (unspec_volatile:SI
+ [(match_operand:SI 2 "register_operand" "d")
+ (match_operand:SI 3 "register_operand" "d")
+- (match_operand:SI 4 "register_operand" "dJ")]
++ (match_operand:SI 4 "reg_or_0_operand" "dJ")]
+ UNSPEC_SYNC_OLD_OP_12))
+ (clobber (match_scratch:SI 5 "=&d"))]
+ "GENERATE_LL_SC"
+@@ -337,7 +337,7 @@
+ [(match_operand:SI 1 "memory_operand" "+R")
+ (match_operand:SI 2 "register_operand" "d")
+ (match_operand:SI 3 "register_operand" "d")
+- (match_operand:SI 4 "register_operand" "dJ")]
++ (match_operand:SI 4 "reg_or_0_operand" "dJ")]
+ UNSPEC_SYNC_NEW_OP_12))
+ (set (match_dup 1)
+ (unspec_volatile:SI
+@@ -546,7 +546,7 @@
+ (set (match_dup 1)
+ (unspec_volatile:SI [(match_operand:SI 2 "register_operand" "d")
+ (match_operand:SI 3 "register_operand" "d")
+- (match_operand:SI 4 "arith_operand" "dJ")]
++ (match_operand:SI 4 "reg_or_0_operand" "dJ")]
+ UNSPEC_SYNC_EXCHANGE_12))]
+ "GENERATE_LL_SC"
+ { return mips_output_sync_loop (insn, operands); }
diff --git a/toolchain/gcc/patches/4.6-linaro/100-uclibc-conf.patch b/toolchain/gcc/patches/4.6-linaro/100-uclibc-conf.patch
new file mode 100644
index 0000000..ff9ad94
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/100-uclibc-conf.patch
@@ -0,0 +1,33 @@
+--- a/contrib/regression/objs-gcc.sh
++++ b/contrib/regression/objs-gcc.sh
+@@ -106,6 +106,10 @@ if [ $H_REAL_TARGET = $H_REAL_HOST -a $H
+ then
+ make all-gdb all-dejagnu all-ld || exit 1
+ make install-gdb install-dejagnu install-ld || exit 1
++elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
++ then
++ make all-gdb all-dejagnu all-ld || exit 1
++ make install-gdb install-dejagnu install-ld || exit 1
+ elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
+ make bootstrap || exit 1
+ make install || exit 1
+--- a/libjava/classpath/ltconfig
++++ b/libjava/classpath/ltconfig
+@@ -603,7 +603,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1247,7 +1247,7 @@ linux-gnuoldld* | linux-gnuaout* | linux
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
diff --git a/toolchain/gcc/patches/4.6-linaro/200-musl.patch b/toolchain/gcc/patches/4.6-linaro/200-musl.patch
new file mode 100644
index 0000000..1cc5756
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/200-musl.patch
@@ -0,0 +1,240 @@
+--- a/config.sub
++++ b/config.sub
+@@ -125,6 +125,7 @@ esac
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
++ linux-musl* | \
+ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -485,7 +485,7 @@ case ${target} in
+ esac
+
+ # Common C libraries.
+-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
++tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
+
+ # Common parts for widely ported systems.
+ case ${target} in
+@@ -598,6 +598,9 @@ case ${target} in
+ *-*-*uclibc*)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
+ ;;
++ *-*-*musl*)
++ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
++ ;;
+ *)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
+ ;;
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -78,6 +78,10 @@
+ %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
+ %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
+
++/* musl has no "classic" (i.e. broken) mode */
++#undef MUSL_DYNAMIC_LINKER
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
+--- a/gcc/config/i386/linux.h
++++ b/gcc/config/i386/linux.h
+@@ -93,6 +93,7 @@ along with GCC; see the file COPYING3.
+ /* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */
+ #define LINK_EMULATION "elf_i386"
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
+
+ #undef ASM_SPEC
+ #define ASM_SPEC \
+--- a/gcc/config/i386/linux64.h
++++ b/gcc/config/i386/linux64.h
+@@ -65,6 +65,9 @@ see the files COPYING3 and COPYING.RUNTI
+ #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
+ #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
+
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
++
+ #if TARGET_64BIT_DEFAULT
+ #define SPEC_32 "m32"
+ #define SPEC_64 "!m32"
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -33,10 +33,12 @@ see the files COPYING3 and COPYING.RUNTI
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ #define LINUX_TARGET_OS_CPP_BUILTINS() \
+@@ -54,18 +56,21 @@ see the files COPYING3 and COPYING.RUNTI
+ uClibc or Bionic is the default C library and whether
+ -muclibc or -mglibc or -mbionic has been passed to change the default. */
+
+-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
+- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
++#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
++ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
+
+ #if DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
+ #elif DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
+ #elif DEFAULT_LIBC == LIBC_BIONIC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif /* DEFAULT_LIBC */
+@@ -83,13 +88,13 @@ see the files COPYING3 and COPYING.RUNTI
+
+ #define LINUX_DYNAMIC_LINKER \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
+- BIONIC_DYNAMIC_LINKER)
++ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+ #define LINUX_DYNAMIC_LINKER32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
+- BIONIC_DYNAMIC_LINKER32)
++ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define LINUX_DYNAMIC_LINKER64 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
+- BIONIC_DYNAMIC_LINKER64)
++ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+
+ /* Determine whether the entire c99 runtime
+ is present in the runtime library. */
+--- a/gcc/config/linux.opt
++++ b/gcc/config/linux.opt
+@@ -30,3 +30,7 @@ Use GNU C library
+ muclibc
+ Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
+ Use uClibc C library
++
++mmusl
++Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
++Use musl C library
+--- a/gcc/config/mips/linux.h
++++ b/gcc/config/mips/linux.h
+@@ -63,6 +63,8 @@ along with GCC; see the file COPYING3.
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
++
+ /* Borrowed from sparc/linux.h */
+ #undef LINK_SPEC
+ #define LINK_SPEC \
+--- a/gcc/ginclude/stddef.h
++++ b/gcc/ginclude/stddef.h
+@@ -184,6 +184,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
+ #ifndef _GCC_SIZE_T
+ #ifndef _SIZET_
+ #ifndef __size_t
++#ifndef __DEFINED_size_t /* musl */
+ #define __size_t__ /* BeOS */
+ #define __SIZE_T__ /* Cray Unicos/Mk */
+ #define _SIZE_T
+@@ -200,6 +201,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
+ #define ___int_size_t_h
+ #define _GCC_SIZE_T
+ #define _SIZET_
++#define __DEFINED_size_t /* musl */
+ #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
+ /* __size_t is a typedef on FreeBSD 5!, must not trash it. */
+ #else
+@@ -214,6 +216,7 @@ typedef __SIZE_TYPE__ size_t;
+ typedef long ssize_t;
+ #endif /* __BEOS__ */
+ #endif /* !(defined (__GNUG__) && defined (size_t)) */
++#endif /* __DEFINED_size_t */
+ #endif /* __size_t */
+ #endif /* _SIZET_ */
+ #endif /* _GCC_SIZE_T */
+--- a/libgomp/config/posix/time.c
++++ b/libgomp/config/posix/time.c
+@@ -28,6 +28,8 @@
+ The following implementation uses the most simple POSIX routines.
+ If present, POSIX 4 clocks should be used instead. */
+
++#define _POSIX_C_SOURCE 199309L /* for clocks */
++
+ #include "libgomp.h"
+ #include <unistd.h>
+ #if TIME_WITH_SYS_TIME
+--- a/libstdc++-v3/configure.host
++++ b/libstdc++-v3/configure.host
+@@ -237,6 +237,13 @@ case "${host_os}" in
+ os_include_dir="os/bsd/freebsd"
+ ;;
+ gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
++ # check for musl by target
++ case "${host_os}" in
++ *-musl*)
++ os_include_dir="os/generic"
++ ;;
++ *)
++
+ if [ "$uclibc" = "yes" ]; then
+ os_include_dir="os/uclibc"
+ elif [ "$bionic" = "yes" ]; then
+@@ -245,6 +252,9 @@ case "${host_os}" in
+ os_include_dir="os/gnu-linux"
+ fi
+ ;;
++
++ esac
++ ;;
+ hpux*)
+ os_include_dir="os/hpux"
+ ;;
+--- a/gcc/config/mips/linux64.h
++++ b/gcc/config/mips/linux64.h
+@@ -40,9 +40,12 @@ along with GCC; see the file COPYING3.
+ #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
+ #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
+ #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
++#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mips.so.1"
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips.so.1"
+ #define LINUX_DYNAMIC_LINKERN32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
+- BIONIC_DYNAMIC_LINKERN32)
++ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
+
+ #undef LINK_SPEC
+ #define LINK_SPEC "\
+--- a/gcc/config/sparc/linux64.h 2013-09-10 10:02:45.663973856 +0100
++++ b/gcc/config/sparc/linux64.h 2013-09-10 10:03:17.871972435 +0100
+@@ -104,6 +104,9 @@
+ #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
+ #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
+
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-sparc.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-sparc.so.1"
++
+ #ifdef SPARC_BI_ARCH
+
+ #undef SUBTARGET_EXTRA_SPECS
diff --git a/toolchain/gcc/patches/4.6-linaro/301-missing-execinfo_h.patch b/toolchain/gcc/patches/4.6-linaro/301-missing-execinfo_h.patch
new file mode 100644
index 0000000..b3f1e68
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/301-missing-execinfo_h.patch
@@ -0,0 +1,11 @@
+--- a/boehm-gc/include/gc.h
++++ b/boehm-gc/include/gc.h
+@@ -503,7 +503,7 @@ GC_API GC_PTR GC_malloc_atomic_ignore_of
+ #if defined(__linux__) || defined(__GLIBC__)
+ # include <features.h>
+ # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
+- && !defined(__ia64__)
++ && !defined(__ia64__) && !defined(__UCLIBC__)
+ # ifndef GC_HAVE_BUILTIN_BACKTRACE
+ # define GC_HAVE_BUILTIN_BACKTRACE
+ # endif
diff --git a/toolchain/gcc/patches/4.6-linaro/302-c99-snprintf.patch b/toolchain/gcc/patches/4.6-linaro/302-c99-snprintf.patch
new file mode 100644
index 0000000..eda1854
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/302-c99-snprintf.patch
@@ -0,0 +1,11 @@
+--- a/libstdc++-v3/include/c_global/cstdio
++++ b/libstdc++-v3/include/c_global/cstdio
+@@ -137,7 +137,7 @@ namespace std
+ using ::vsprintf;
+ } // namespace
+
+-#if _GLIBCXX_USE_C99
++#if _GLIBCXX_USE_C99 || defined __UCLIBC__
+
+ #undef snprintf
+ #undef vfscanf
diff --git a/toolchain/gcc/patches/4.6-linaro/305-libmudflap-susv3-legacy.patch b/toolchain/gcc/patches/4.6-linaro/305-libmudflap-susv3-legacy.patch
new file mode 100644
index 0000000..8e2d15f
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/305-libmudflap-susv3-legacy.patch
@@ -0,0 +1,47 @@
+--- a/libmudflap/mf-hooks2.c
++++ b/libmudflap/mf-hooks2.c
+@@ -421,7 +421,7 @@ WRAPPER2(void, bzero, void *s, size_t n)
+ {
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region");
+- bzero (s, n);
++ memset (s, 0, n);
+ }
+
+
+@@ -431,7 +431,7 @@ WRAPPER2(void, bcopy, const void *src, v
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "bcopy src");
+ MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest");
+- bcopy (src, dest, n);
++ memmove (dest, src, n);
+ }
+
+
+@@ -441,7 +441,7 @@ WRAPPER2(int, bcmp, const void *s1, cons
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "bcmp 1st arg");
+ MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg");
+- return bcmp (s1, s2, n);
++ return n == 0 ? 0 : memcmp (s1, s2, n);
+ }
+
+
+@@ -450,7 +450,7 @@ WRAPPER2(char *, index, const char *s, i
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region");
+- return index (s, c);
++ return strchr (s, c);
+ }
+
+
+@@ -459,7 +459,7 @@ WRAPPER2(char *, rindex, const char *s,
+ size_t n = strlen (s);
+ TRACE ("%s\n", __PRETTY_FUNCTION__);
+ MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region");
+- return rindex (s, c);
++ return strrchr (s, c);
+ }
+
+ /* XXX: stpcpy, memccpy */
diff --git a/toolchain/gcc/patches/4.6-linaro/800-arm_v5te_no_ldrd_strd.patch b/toolchain/gcc/patches/4.6-linaro/800-arm_v5te_no_ldrd_strd.patch
new file mode 100644
index 0000000..4b7770d
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/800-arm_v5te_no_ldrd_strd.patch
@@ -0,0 +1,11 @@
+--- a/gcc/config/arm/arm.h
++++ b/gcc/config/arm/arm.h
+@@ -232,7 +232,7 @@ extern void (*arm_lang_output_object_att
+ #define TARGET_BACKTRACE (leaf_function_p () \
+ ? TARGET_TPCS_LEAF_FRAME \
+ : TARGET_TPCS_FRAME)
+-#define TARGET_LDRD (arm_arch5e && ARM_DOUBLEWORD_ALIGN)
++#define TARGET_LDRD (arm_arch6 && ARM_DOUBLEWORD_ALIGN)
+ #define TARGET_AAPCS_BASED \
+ (arm_abi != ARM_ABI_APCS && arm_abi != ARM_ABI_ATPCS)
+
diff --git a/toolchain/gcc/patches/4.6-linaro/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches/4.6-linaro/810-arm-softfloat-libgcc.patch
new file mode 100644
index 0000000..60cfde4
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/810-arm-softfloat-libgcc.patch
@@ -0,0 +1,26 @@
+--- a/gcc/config/arm/linux-elf.h
++++ b/gcc/config/arm/linux-elf.h
+@@ -60,7 +60,7 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{msoft-float:-lfloat} %{mfloat-abi=soft*:-lfloat} -lgcc"
++#define LIBGCC_SPEC "-lgcc"
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+--- a/gcc/config/arm/t-linux
++++ b/gcc/config/arm/t-linux
+@@ -23,7 +23,11 @@ TARGET_LIBGCC2_CFLAGS = -fomit-frame-poi
+
+ LIB1ASMSRC = arm/lib1funcs.asm
+ LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \
+- _arm_addsubdf3 _arm_addsubsf3
++ _arm_addsubdf3 _arm_addsubsf3 \
++ _arm_negdf2 _arm_muldivdf3 _arm_cmpdf2 _arm_unorddf2 \
++ _arm_fixdfsi _arm_fixunsdfsi _arm_truncdfsf2 \
++ _arm_negsf2 _arm_muldivsf3 _arm_cmpsf2 _arm_unordsf2 \
++ _arm_fixsfsi _arm_fixunssfsi
+
+ # MULTILIB_OPTIONS = mhard-float/msoft-float
+ # MULTILIB_DIRNAMES = hard-float soft-float
diff --git a/toolchain/gcc/patches/4.6-linaro/820-libgcc_pic.patch b/toolchain/gcc/patches/4.6-linaro/820-libgcc_pic.patch
new file mode 100644
index 0000000..3760ac2
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/820-libgcc_pic.patch
@@ -0,0 +1,36 @@
+--- a/libgcc/Makefile.in
++++ b/libgcc/Makefile.in
+@@ -747,11 +747,12 @@ $(libgcov-objects): %$(objext): $(gcc_sr
+
+ # Static libraries.
+ libgcc.a: $(libgcc-objects)
++libgcc_pic.a: $(libgcc-s-objects)
+ libgcov.a: $(libgcov-objects)
+ libunwind.a: $(libunwind-objects)
+ libgcc_eh.a: $(libgcc-eh-objects)
+
+-libgcc.a libgcov.a libunwind.a libgcc_eh.a:
++libgcc.a libgcov.a libunwind.a libgcc_eh.a libgcc_pic.a:
+ -rm -f $@
+
+ objects="$(objects)"; \
+@@ -773,7 +774,7 @@ libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_E
+ endif
+
+ ifeq ($(enable_shared),yes)
+-all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
++all: libgcc_eh.a libgcc_pic.a libgcc_s$(SHLIB_EXT)
+ ifneq ($(LIBUNWIND),)
+ all: libunwind$(SHLIB_EXT)
+ endif
+@@ -954,6 +955,10 @@ install-shared:
+ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a
+ $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a
+
++ $(INSTALL_DATA) libgcc_pic.a $(mapfile) $(DESTDIR)$(inst_libdir)/
++ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_pic.a
++ $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_pic.a
++
+ $(subst @multilib_dir@,$(MULTIDIR),$(subst \
+ @shlib_base_name@,libgcc_s,$(subst \
+ @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))
diff --git a/toolchain/gcc/patches/4.6-linaro/830-arm_unbreak_armv4t.patch b/toolchain/gcc/patches/4.6-linaro/830-arm_unbreak_armv4t.patch
new file mode 100644
index 0000000..7e2ed69
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/830-arm_unbreak_armv4t.patch
@@ -0,0 +1,13 @@
+http://sourceware.org/ml/crossgcc/2008-05/msg00009.html
+
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -46,7 +46,7 @@
+ The ARM10TDMI core is the default for armv5t, so set
+ SUBTARGET_CPU_DEFAULT to achieve this. */
+ #undef SUBTARGET_CPU_DEFAULT
+-#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm10tdmi
++#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm9tdmi
+
+ /* TARGET_BIG_ENDIAN_DEFAULT is set in
+ config.gcc for big endian configurations. */
diff --git a/toolchain/gcc/patches/4.6-linaro/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches/4.6-linaro/840-armv4_pass_fix-v4bx_to_ld.patch
new file mode 100644
index 0000000..3be371b
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/840-armv4_pass_fix-v4bx_to_ld.patch
@@ -0,0 +1,19 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -82,10 +82,15 @@
+ #undef MUSL_DYNAMIC_LINKER
+ #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1"
+
++/* For armv4 we pass --fix-v4bx to linker to support EABI */
++#undef TARGET_FIX_V4BX_SPEC
++#define TARGET_FIX_V4BX_SPEC " %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*"\
++ "|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx}"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
+-#define LINK_SPEC BE8_LINK_SPEC \
++#define LINK_SPEC BE8_LINK_SPEC TARGET_FIX_V4BX_SPEC \
+ LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \
+ LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
+
diff --git a/toolchain/gcc/patches/4.6-linaro/850-use_shared_libgcc.patch b/toolchain/gcc/patches/4.6-linaro/850-use_shared_libgcc.patch
new file mode 100644
index 0000000..61e1035
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/850-use_shared_libgcc.patch
@@ -0,0 +1,86 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -115,10 +115,6 @@
+ #define ENDFILE_SPEC \
+ LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC)
+
+-/* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we
+- do not use -lfloat. */
+-#undef LIBGCC_SPEC
+-
+ /* Clear the instruction cache from `beg' to `end'. This is
+ implemented in lib1funcs.asm, so ensure an error if this definition
+ is used. */
+--- a/gcc/config/arm/linux-elf.h
++++ b/gcc/config/arm/linux-elf.h
+@@ -60,8 +60,6 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "-lgcc"
+-
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+ #define LINUX_TARGET_LINK_SPEC "%{h*} \
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -52,6 +52,10 @@ see the files COPYING3 and COPYING.RUNTI
+ builtin_assert ("system=posix"); \
+ } while (0)
+
++#ifndef LIBGCC_SPEC
++#define LIBGCC_SPEC "%{static|static-libgcc:-lgcc}%{!static:%{!static-libgcc:-lgcc_s}}"
++#endif
++
+ /* Determine which dynamic linker to use depending on whether GLIBC or
+ uClibc or Bionic is the default C library and whether
+ -muclibc or -mglibc or -mbionic has been passed to change the default. */
+--- a/gcc/config/rs6000/linux.h
++++ b/gcc/config/rs6000/linux.h
+@@ -88,6 +88,8 @@
+ #define USE_LD_AS_NEEDED 1
+ #endif
+
++#define LIBGCC_SPEC "%{!static:%{!static-libgcc:-lgcc_s}} -lgcc"
++
+ #undef TARGET_VERSION
+ #define TARGET_VERSION fprintf (stderr, " (PowerPC GNU/Linux)");
+
+--- a/gcc/mkmap-symver.awk
++++ b/gcc/mkmap-symver.awk
+@@ -132,5 +132,5 @@ function output(lib) {
+ else if (inherit[lib])
+ printf("} %s;\n", inherit[lib]);
+ else
+- printf ("\n local:\n\t*;\n};\n");
++ printf ("\n\t*;\n};\n");
+ }
+--- a/libgcc/Makefile.in
++++ b/libgcc/Makefile.in
+@@ -269,6 +269,12 @@ ifeq ($(enable_shared),yes)
+ install-libunwind = install-libunwind
+ endif
+
++else
++# Not enable_shared.
++iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items))
++endif
++
++
+ # For -fvisibility=hidden. We need both a -fvisibility=hidden on
+ # the command line, and a #define to prevent libgcc2.h etc from
+ # overriding that with #pragmas.
+@@ -291,13 +297,6 @@ else
+ gen-hide-list = echo > $@
+ endif
+
+-else
+-# Not enable_shared.
+-iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items))
+-vis_hide =
+-gen-hide-list = echo > \$@
+-endif
+-
+ ifneq ($(EXTRA_PARTS),)
+ extra-parts = libgcc-extra-parts
+ INSTALL_PARTS = $(EXTRA_PARTS)
diff --git a/toolchain/gcc/patches/4.6-linaro/860-uclibc_use_eh_frame.patch b/toolchain/gcc/patches/4.6-linaro/860-uclibc_use_eh_frame.patch
new file mode 100644
index 0000000..381a14b
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/860-uclibc_use_eh_frame.patch
@@ -0,0 +1,29 @@
+--- a/gcc/crtstuff.c
++++ b/gcc/crtstuff.c
+@@ -100,15 +100,20 @@ call_ ## FUNC (void) \
+ #if defined(OBJECT_FORMAT_ELF) \
+ && !defined(OBJECT_FORMAT_FLAT) \
+ && defined(HAVE_LD_EH_FRAME_HDR) \
+- && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \
+- && defined(__GLIBC__) && __GLIBC__ >= 2
++ && !defined(inhibit_libc) && !defined(CRTSTUFFT_O)
+ #include <link.h>
+ /* uClibc pretends to be glibc 2.2 and DT_CONFIG is defined in its link.h.
+ But it doesn't use PT_GNU_EH_FRAME ELF segment currently. */
+-# if !defined(__UCLIBC__) \
+- && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
+- || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
+-# define USE_PT_GNU_EH_FRAME
++# if defined(__UCLIBC__)
++# if (__UCLIBC_MAJOR__ > 0 || __UCLIBC_MINOR__ > 9 || \
++ (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ >= 33))
++# define USE_PT_GNU_EH_FRAME
++# endif
++# elif defined(__GLIBC__)
++# if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
++ || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
++# define USE_PT_GNU_EH_FRAME
++# endif
+ # endif
+ #endif
+ #if defined(EH_FRAME_SECTION_NAME) && !defined(USE_PT_GNU_EH_FRAME)
diff --git a/toolchain/gcc/patches/4.6-linaro/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches/4.6-linaro/870-ppc_no_crtsavres.patch
new file mode 100644
index 0000000..0e15ffc
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/870-ppc_no_crtsavres.patch
@@ -0,0 +1,20 @@
+--- a/gcc/config/rs6000/sysv4.h
++++ b/gcc/config/rs6000/sysv4.h
+@@ -248,13 +248,13 @@ do { \
+
+ /* Define cutoff for using external functions to save floating point.
+ When optimizing for size, use external functions when profitable. */
+-#define FP_SAVE_INLINE(FIRST_REG) (optimize_size \
++#define FP_SAVE_INLINE(FIRST_REG) (1 || (optimize_size \
+ ? ((FIRST_REG) == 62 \
+ || (FIRST_REG) == 63) \
+- : (FIRST_REG) < 64)
++ : (FIRST_REG) < 64))
+ /* And similarly for general purpose registers. */
+-#define GP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 32 \
+- && !optimize_size)
++#define GP_SAVE_INLINE(FIRST_REG) (1 || ((FIRST_REG) < 32 \
++ && !optimize_size))
+
+ /* Put jump tables in read-only memory, rather than in .text. */
+ #define JUMP_TABLES_IN_TEXT_SECTION 0
diff --git a/toolchain/gcc/patches/4.6-linaro/880-no_java_section.patch b/toolchain/gcc/patches/4.6-linaro/880-no_java_section.patch
new file mode 100644
index 0000000..404b7d3
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/880-no_java_section.patch
@@ -0,0 +1,11 @@
+--- a/gcc/defaults.h
++++ b/gcc/defaults.h
+@@ -383,7 +383,7 @@ see the files COPYING3 and COPYING.RUNTI
+ /* If we have named section and we support weak symbols, then use the
+ .jcr section for recording java classes which need to be registered
+ at program start-up time. */
+-#if defined (TARGET_ASM_NAMED_SECTION) && SUPPORTS_WEAK
++#if 0 && defined (TARGET_ASM_NAMED_SECTION) && SUPPORTS_WEAK
+ #ifndef JCR_SECTION_NAME
+ #define JCR_SECTION_NAME ".jcr"
+ #endif
diff --git a/toolchain/gcc/patches/4.6-linaro/900-bad-mips16-crt b/toolchain/gcc/patches/4.6-linaro/900-bad-mips16-crt
new file mode 100644
index 0000000..5bb2ffb
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/900-bad-mips16-crt
@@ -0,0 +1,9 @@
+--- gcc/gcc/config/mips/t-libgcc-mips16~ 2013-03-26 09:09:34.209077496 -0400
++++ gcc/gcc/config/mips/t-libgcc-mips16 2013-03-26 18:21:01.717303669 -0400
+@@ -43,3 +43,6 @@
+
+ # Version these symbols if building libgcc.so.
+ SHLIB_MAPFILES += $(srcdir)/config/mips/libgcc-mips16.ver
++
++CRTSTUFF_T_CFLAGS += -mno-mips16
++CRTSTUFF_T_CFLAGS_S += -mno-mips16
diff --git a/toolchain/gcc/patches/4.6-linaro/910-mbsd_multi.patch b/toolchain/gcc/patches/4.6-linaro/910-mbsd_multi.patch
new file mode 100644
index 0000000..32b408a
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/910-mbsd_multi.patch
@@ -0,0 +1,253 @@
+
+ This patch brings over a few features from MirBSD:
+ * -fhonour-copts
+ If this option is not given, it's warned (depending
+ on environment variables). This is to catch errors
+ of misbuilt packages which override CFLAGS themselves.
+ * -Werror-maybe-reset
+ Has the effect of -Wno-error if GCC_NO_WERROR is
+ set and not '0', a no-operation otherwise. This is
+ to be able to use -Werror in "make" but prevent
+ GNU autoconf generated configure scripts from
+ freaking out.
+ * Make -fno-strict-aliasing and -fno-delete-null-pointer-checks
+ the default for -O2/-Os, because they trigger gcc bugs
+ and can delete code with security implications.
+
+ This patch was authored by Thorsten Glaser <tg at mirbsd.de>
+ with copyright assignment to the FSF in effect.
+
+--- a/gcc/c-family/c-opts.c
++++ b/gcc/c-family/c-opts.c
+@@ -103,6 +103,9 @@ static size_t deferred_count;
+ /* Number of deferred options scanned for -include. */
+ static size_t include_cursor;
+
++/* Check if a port honours COPTS. */
++static int honour_copts = 0;
++
+ static void handle_OPT_d (const char *);
+ static void set_std_cxx98 (int);
+ static void set_std_cxx0x (int);
+@@ -441,6 +444,9 @@ c_common_handle_option (size_t scode, co
+ global_dc->warning_as_error_requested = value;
+ break;
+
++ case OPT_Werror_maybe_reset:
++ break;
++
+ case OPT_Wformat:
+ set_Wformat (value);
+ break;
+@@ -584,6 +590,12 @@ c_common_handle_option (size_t scode, co
+ flag_no_builtin = !value;
+ break;
+
++ case OPT_fhonour_copts:
++ if (c_language == clk_c) {
++ honour_copts++;
++ }
++ break;
++
+ case OPT_fconstant_string_class_:
+ constant_string_class_name = arg;
+ break;
+@@ -1058,6 +1070,47 @@ c_common_init (void)
+ return false;
+ }
+
++ if (c_language == clk_c) {
++ char *ev = getenv ("GCC_HONOUR_COPTS");
++ int evv;
++ if (ev == NULL)
++ evv = -1;
++ else if ((*ev == '0') || (*ev == '\0'))
++ evv = 0;
++ else if (*ev == '1')
++ evv = 1;
++ else if (*ev == '2')
++ evv = 2;
++ else if (*ev == 's')
++ evv = -1;
++ else {
++ warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
++ evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
++ }
++ if (evv == 1) {
++ if (honour_copts == 0) {
++ error ("someone does not honour COPTS at all in lenient mode");
++ return false;
++ } else if (honour_copts != 1) {
++ warning (0, "someone does not honour COPTS correctly, passed %d times",
++ honour_copts);
++ }
++ } else if (evv == 2) {
++ if (honour_copts == 0) {
++ error ("someone does not honour COPTS at all in strict mode");
++ return false;
++ } else if (honour_copts != 1) {
++ error ("someone does not honour COPTS correctly, passed %d times",
++ honour_copts);
++ return false;
++ }
++ } else if (evv == 0) {
++ if (honour_copts != 1)
++ inform (0, "someone does not honour COPTS correctly, passed %d times",
++ honour_copts);
++ }
++ }
++
+ return true;
+ }
+
+--- a/gcc/c-family/c.opt
++++ b/gcc/c-family/c.opt
+@@ -363,6 +363,10 @@ Werror-implicit-function-declaration
+ C ObjC RejectNegative Warning Alias(Werror=, implicit-function-declaration)
+ This switch is deprecated; use -Werror=implicit-function-declaration instead
+
++Werror-maybe-reset
++C ObjC C++ ObjC++
++; Documented in common.opt
++
+ Wfloat-equal
+ C ObjC C++ ObjC++ Var(warn_float_equal) Warning
+ Warn if testing floating point numbers for equality
+@@ -794,6 +798,9 @@ C++ ObjC++ Optimization Alias(fexception
+ fhonor-std
+ C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
+
++fhonour-copts
++C ObjC C++ ObjC++ RejectNegative
++
+ fhosted
+ C ObjC
+ Assume normal C execution environment
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -523,6 +523,10 @@ Werror=
+ Common Joined
+ Treat specified warning as error
+
++Werror-maybe-reset
++Common
++If environment variable GCC_NO_WERROR is set, act as -Wno-error
++
+ Wextra
+ Common Var(extra_warnings) Warning
+ Print extra (possibly unwanted) warnings
+@@ -1159,6 +1163,9 @@ fguess-branch-probability
+ Common Report Var(flag_guess_branch_prob) Optimization
+ Enable guessing of branch probabilities
+
++fhonour-copts
++Common RejectNegative
++
+ ; Nonzero means ignore `#ident' directives. 0 means handle them.
+ ; Generate position-independent code for executables if possible
+ ; On SVR4 targets, it also controls whether or not to emit a
+--- a/gcc/opts.c
++++ b/gcc/opts.c
+@@ -477,8 +477,6 @@ static const struct default_options defa
+ { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 },
+ #endif
+ { OPT_LEVELS_2_PLUS, OPT_fregmove, NULL, 1 },
+- { OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 },
+- { OPT_LEVELS_2_PLUS, OPT_fstrict_overflow, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_freorder_blocks, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 },
+@@ -494,6 +492,8 @@ static const struct default_options defa
+ { OPT_LEVELS_2_PLUS, OPT_falign_functions, NULL, 1 },
+
+ /* -O3 optimizations. */
++ { OPT_LEVELS_3_PLUS, OPT_fstrict_aliasing, NULL, 1 },
++ { OPT_LEVELS_3_PLUS, OPT_fstrict_overflow, NULL, 1 },
+ { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
+ { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 },
+ /* Inlining of functions reducing size is a good idea with -Os
+@@ -1405,6 +1405,17 @@ common_handle_option (struct gcc_options
+ opts, opts_set, loc, dc);
+ break;
+
++ case OPT_Werror_maybe_reset:
++ {
++ char *ev = getenv ("GCC_NO_WERROR");
++ if ((ev != NULL) && (*ev != '0'))
++ warnings_are_errors = 0;
++ }
++ break;
++
++ case OPT_fhonour_copts:
++ break;
++
+ case OPT_Wlarger_than_:
+ opts->x_larger_than_size = value;
+ opts->x_warn_larger_than = value != -1;
+--- a/gcc/doc/cppopts.texi
++++ b/gcc/doc/cppopts.texi
+@@ -164,6 +164,11 @@ in older programs. This warning is on b
+ Make all warnings into hard errors. Source code which triggers warnings
+ will be rejected.
+
++ at item -Werror-maybe-reset
++ at opindex Werror-maybe-reset
++Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
++variable is set to anything other than 0 or empty.
++
+ @item -Wsystem-headers
+ @opindex Wsystem-headers
+ Issue warnings for code in system headers. These are normally unhelpful
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -240,7 +240,7 @@ Objective-C and Objective-C++ Dialects}.
+ -Wconversion -Wcoverage-mismatch -Wno-cpp -Wno-deprecated @gol
+ -Wno-deprecated-declarations -Wdisabled-optimization @gol
+ -Wno-div-by-zero -Wdouble-promotion -Wempty-body -Wenum-compare @gol
+--Wno-endif-labels -Werror -Werror=* @gol
++-Wno-endif-labels -Werror -Werror=* -Werror-maybe-reset @gol
+ -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
+ -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
+ -Wformat-security -Wformat-y2k @gol
+@@ -4498,6 +4498,22 @@ This option is only supported for C and
+ @option{-Wall} and by @option{-pedantic}, which can be disabled with
+ @option{-Wno-pointer-sign}.
+
++ at item -Werror-maybe-reset
++ at opindex Werror-maybe-reset
++Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
++variable is set to anything other than 0 or empty.
++
++ at item -fhonour-copts
++ at opindex fhonour-copts
++If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
++given at least once, and warn if it is given more than once.
++If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
++given exactly once.
++If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
++is not given exactly once.
++The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
++This flag and environment variable only affect the C language.
++
+ @item -Wstack-protector
+ @opindex Wstack-protector
+ @opindex Wno-stack-protector
+@@ -6322,7 +6338,7 @@ so, the first branch is redirected to ei
+ second branch or a point immediately following it, depending on whether
+ the condition is known to be true or false.
+
+-Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
++Enabled at levels @option{-O3}.
+
+ @item -fsplit-wide-types
+ @opindex fsplit-wide-types
+--- a/gcc/java/jvspec.c
++++ b/gcc/java/jvspec.c
+@@ -627,6 +627,7 @@ lang_specific_pre_link (void)
+ class name. Append dummy `.c' that can be stripped by set_input so %b
+ is correct. */
+ set_input (concat (main_class_name, "main.c", NULL));
++ putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
+ err = do_spec (jvgenmain_spec);
+ if (err == 0)
+ {
diff --git a/toolchain/gcc/patches/4.6-linaro/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches/4.6-linaro/920-specs_nonfatal_getenv.patch
new file mode 100644
index 0000000..0b241fa
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/920-specs_nonfatal_getenv.patch
@@ -0,0 +1,14 @@
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -7830,7 +7830,10 @@ getenv_spec_function (int argc, const ch
+
+ value = getenv (argv[0]);
+ if (!value)
+- fatal_error ("environment variable %qs not defined", argv[0]);
++ {
++ warning (0, "environment variable %qs not defined", argv[0]);
++ value = "";
++ }
+
+ /* We have to escape every character of the environment variable so
+ they are not interpreted as active spec characters. A
diff --git a/toolchain/gcc/patches/4.6-linaro/940-no-clobber-stamp-bits.patch b/toolchain/gcc/patches/4.6-linaro/940-no-clobber-stamp-bits.patch
new file mode 100644
index 0000000..9106a4a
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/940-no-clobber-stamp-bits.patch
@@ -0,0 +1,11 @@
+--- a/libstdc++-v3/include/Makefile.in
++++ b/libstdc++-v3/include/Makefile.in
+@@ -1326,7 +1326,7 @@
+ @$(STAMP) stamp-bits
+
+ stamp-bits-sup: stamp-bits ${bits_sup_headers}
+- @-cd ${bits_builddir} && $(LN_S) $? . 2>/dev/null
++ @-cd ${bits_builddir} && $(LN_S) $(filter-out stamp-bits,$?) . 2>/dev/null
+ @$(STAMP) stamp-bits-sup
+
+ stamp-c_base: ${c_base_headers}
diff --git a/toolchain/gcc/patches/4.6-linaro/999-coldfire.patch b/toolchain/gcc/patches/4.6-linaro/999-coldfire.patch
new file mode 100644
index 0000000..e014386
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/999-coldfire.patch
@@ -0,0 +1,11 @@
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -1809,7 +1809,7 @@ m68k-*-linux*) # Motorola m68k's runnin
+ default_m68k_cpu=68020
+ default_cf_cpu=5475
+ with_arch=${with_arch:-m68k}
+- tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h m68k/linux.h ./sysroot-suffix.h"
++ tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h m68k/linux.h"
+ extra_options="${extra_options} m68k/ieee.opt"
+ tm_defines="${tm_defines} MOTOROLA=1"
+ tmake_file="${tmake_file} m68k/t-floatlib m68k/t-linux m68k/t-mlibs"
diff --git a/toolchain/gcc/patches/4.6-linaro/999-gcc5-gcc_cp_cfns_h.patch b/toolchain/gcc/patches/4.6-linaro/999-gcc5-gcc_cp_cfns_h.patch
new file mode 100644
index 0000000..7ab0d4c
--- /dev/null
+++ b/toolchain/gcc/patches/4.6-linaro/999-gcc5-gcc_cp_cfns_h.patch
@@ -0,0 +1,21 @@
+--- a/gcc/cp/cfns.h
++++ b/gcc/cp/cfns.h
+@@ -53,6 +53,9 @@ __inline
+ static unsigned int hash (const char *, unsigned int);
+ #ifdef __GNUC__
+ __inline
++#ifdef __GNUC_STDC_INLINE__
++__attribute__ ((__gnu_inline__))
++#endif
+ #endif
+ const char * libc_name_p (const char *, unsigned int);
+ /* maximum key range = 391, duplicates = 0 */
+@@ -96,7 +99,7 @@ hash (register const char *str, register
+ 400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
+ 400, 400, 400, 400, 400, 400, 400
+ };
+- register int hval = len;
++ register int hval = (int)len;
+
+ switch (hval)
+ {
diff --git a/toolchain/gcc/patches/4.8-linaro/001-revert_register_mode_search.patch b/toolchain/gcc/patches/4.8-linaro/001-revert_register_mode_search.patch
new file mode 100644
index 0000000..162d651
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/001-revert_register_mode_search.patch
@@ -0,0 +1,65 @@
+Revert of:
+
+commit 275035b56823b26d5fb7e90fad945b998648edf2
+Author: bergner <bergner@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Thu Sep 5 14:09:07 2013 +0000
+
+ PR target/58139
+ * reginfo.c (choose_hard_reg_mode): Scan through all mode classes
+ looking for widest mode.
+
+
+ git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202286 138bc75d-0d04-0410-961f-82ee72b054a4
+
+
+--- a/gcc/reginfo.c
++++ b/gcc/reginfo.c
+@@ -620,35 +620,40 @@ choose_hard_reg_mode (unsigned int regno
+ mode = GET_MODE_WIDER_MODE (mode))
+ if ((unsigned) hard_regno_nregs[regno][mode] == nregs
+ && HARD_REGNO_MODE_OK (regno, mode)
+- && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
+- && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
++ && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
+ found_mode = mode;
+
++ if (found_mode != VOIDmode)
++ return found_mode;
++
+ for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
+ mode != VOIDmode;
+ mode = GET_MODE_WIDER_MODE (mode))
+ if ((unsigned) hard_regno_nregs[regno][mode] == nregs
+ && HARD_REGNO_MODE_OK (regno, mode)
+- && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
+- && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
++ && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
+ found_mode = mode;
+
++ if (found_mode != VOIDmode)
++ return found_mode;
++
+ for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_FLOAT);
+ mode != VOIDmode;
+ mode = GET_MODE_WIDER_MODE (mode))
+ if ((unsigned) hard_regno_nregs[regno][mode] == nregs
+ && HARD_REGNO_MODE_OK (regno, mode)
+- && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
+- && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
++ && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
+ found_mode = mode;
+
++ if (found_mode != VOIDmode)
++ return found_mode;
++
+ for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_INT);
+ mode != VOIDmode;
+ mode = GET_MODE_WIDER_MODE (mode))
+ if ((unsigned) hard_regno_nregs[regno][mode] == nregs
+ && HARD_REGNO_MODE_OK (regno, mode)
+- && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
+- && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
++ && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
+ found_mode = mode;
+
+ if (found_mode != VOIDmode)
diff --git a/toolchain/gcc/patches/4.8-linaro/002-weak_data_fix.patch b/toolchain/gcc/patches/4.8-linaro/002-weak_data_fix.patch
new file mode 100644
index 0000000..a740b4c
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/002-weak_data_fix.patch
@@ -0,0 +1,42 @@
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/visibility-21.c
+@@ -0,0 +1,14 @@
++/* PR target/32219 */
++/* { dg-do run } */
++/* { dg-require-visibility "" } */
++/* { dg-options "-fPIC" { target fpic } } */
++
++extern void f() __attribute__((weak,visibility("hidden")));
++extern int puts( char const* );
++int main()
++{
++ if (f)
++ f();
++ return 0;
++}
++
+--- a/gcc/varasm.c
++++ b/gcc/varasm.c
+@@ -6677,6 +6677,10 @@ default_binds_local_p_1 (const_tree exp,
+ /* Static variables are always local. */
+ else if (! TREE_PUBLIC (exp))
+ local_p = true;
++ /* hidden weak can't be overridden by something non-local, all
++ that is possible is that it is not defined at all. */
++ else if (DECL_WEAK (exp))
++ local_p = false;
+ /* A variable is local if the user has said explicitly that it will
+ be. */
+ else if ((DECL_VISIBILITY_SPECIFIED (exp)
+@@ -6690,11 +6694,6 @@ default_binds_local_p_1 (const_tree exp,
+ local. */
+ else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
+ local_p = true;
+- /* Default visibility weak data can be overridden by a strong symbol
+- in another module and so are not local. */
+- else if (DECL_WEAK (exp)
+- && !resolved_locally)
+- local_p = false;
+ /* If PIC, then assume that any global name can be overridden by
+ symbols resolved from other modules. */
+ else if (shlib)
diff --git a/toolchain/gcc/patches/4.8-linaro/003-universal_initializer.patch b/toolchain/gcc/patches/4.8-linaro/003-universal_initializer.patch
new file mode 100644
index 0000000..1b9a5b3
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/003-universal_initializer.patch
@@ -0,0 +1,94 @@
+--- a/gcc/c/c-typeck.c
++++ b/gcc/c/c-typeck.c
+@@ -62,9 +62,9 @@ int in_typeof;
+ if expr.original_code == SIZEOF_EXPR. */
+ tree c_last_sizeof_arg;
+
+-/* Nonzero if we've already printed a "missing braces around initializer"
+- message within this initializer. */
+-static int missing_braces_mentioned;
++/* Nonzero if we might need to print a "missing braces around
++ initializer" message within this initializer. */
++static int found_missing_braces;
+
+ static int require_constant_value;
+ static int require_constant_elements;
+@@ -6363,6 +6363,9 @@ static int constructor_nonconst;
+ /* 1 if this constructor is erroneous so far. */
+ static int constructor_erroneous;
+
++/* 1 if this constructor is the universal zero initializer { 0 }. */
++static int constructor_zeroinit;
++
+ /* Structure for managing pending initializer elements, organized as an
+ AVL tree. */
+
+@@ -6524,7 +6527,7 @@ start_init (tree decl, tree asmspec_tree
+ constructor_stack = 0;
+ constructor_range_stack = 0;
+
+- missing_braces_mentioned = 0;
++ found_missing_braces = 0;
+
+ spelling_base = 0;
+ spelling_size = 0;
+@@ -6619,6 +6622,7 @@ really_start_incremental_init (tree type
+ constructor_type = type;
+ constructor_incremental = 1;
+ constructor_designated = 0;
++ constructor_zeroinit = 1;
+ designator_depth = 0;
+ designator_erroneous = 0;
+
+@@ -6816,11 +6820,8 @@ push_init_level (int implicit, struct ob
+ set_nonincremental_init (braced_init_obstack);
+ }
+
+- if (implicit == 1 && warn_missing_braces && !missing_braces_mentioned)
+- {
+- missing_braces_mentioned = 1;
+- warning_init (OPT_Wmissing_braces, "missing braces around initializer");
+- }
++ if (implicit == 1)
++ found_missing_braces = 1;
+
+ if (TREE_CODE (constructor_type) == RECORD_TYPE
+ || TREE_CODE (constructor_type) == UNION_TYPE)
+@@ -6953,16 +6954,23 @@ pop_init_level (int implicit, struct obs
+ }
+ }
+
++ if (vec_safe_length (constructor_elements) != 1)
++ constructor_zeroinit = 0;
++
++ /* Warn when some structs are initialized with direct aggregation. */
++ if (!implicit && found_missing_braces && warn_missing_braces
++ && !constructor_zeroinit)
++ {
++ warning_init (OPT_Wmissing_braces,
++ "missing braces around initializer");
++ }
++
+ /* Warn when some struct elements are implicitly initialized to zero. */
+ if (warn_missing_field_initializers
+ && constructor_type
+ && TREE_CODE (constructor_type) == RECORD_TYPE
+ && constructor_unfilled_fields)
+ {
+- bool constructor_zeroinit =
+- (vec_safe_length (constructor_elements) == 1
+- && integer_zerop ((*constructor_elements)[0].value));
+-
+ /* Do not warn for flexible array members or zero-length arrays. */
+ while (constructor_unfilled_fields
+ && (!DECL_SIZE (constructor_unfilled_fields)
+@@ -8077,6 +8085,9 @@ process_init_element (struct c_expr valu
+ designator_depth = 0;
+ designator_erroneous = 0;
+
++ if (!implicit && value.value && !integer_zerop (value.value))
++ constructor_zeroinit = 0;
++
+ /* Handle superfluous braces around string cst as in
+ char x[] = {"foo"}; */
+ if (string_flag
diff --git a/toolchain/gcc/patches/4.8-linaro/004-case_insensitive.patch b/toolchain/gcc/patches/4.8-linaro/004-case_insensitive.patch
new file mode 100644
index 0000000..b3d2dbe
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/004-case_insensitive.patch
@@ -0,0 +1,14 @@
+--- a/include/filenames.h
++++ b/include/filenames.h
+@@ -43,11 +43,6 @@ extern "C" {
+ # define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c)
+ # define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f)
+ #else /* not DOSish */
+-# if defined(__APPLE__)
+-# ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
+-# define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
+-# endif
+-# endif /* __APPLE__ */
+ # define HAS_DRIVE_SPEC(f) (0)
+ # define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c)
+ # define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f)
diff --git a/toolchain/gcc/patches/4.8-linaro/010-documentation.patch b/toolchain/gcc/patches/4.8-linaro/010-documentation.patch
new file mode 100644
index 0000000..5548069
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/010-documentation.patch
@@ -0,0 +1,23 @@
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -4327,18 +4327,10 @@ doc/gcc.info: $(TEXI_GCC_FILES)
+ doc/gccint.info: $(TEXI_GCCINT_FILES)
+ doc/cppinternals.info: $(TEXI_CPPINT_FILES)
+
+-doc/%.info: %.texi
+- if [ x$(BUILD_INFO) = xinfo ]; then \
+- $(MAKEINFO) $(MAKEINFOFLAGS) -I . -I $(gcc_docdir) \
+- -I $(gcc_docdir)/include -o $@ $<; \
+- fi
++doc/%.info:
+
+ # Duplicate entry to handle renaming of gccinstall.info
+-doc/gccinstall.info: $(TEXI_GCCINSTALL_FILES)
+- if [ x$(BUILD_INFO) = xinfo ]; then \
+- $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
+- -I $(gcc_docdir)/include -o $@ $<; \
+- fi
++doc/gccinstall.info:
+
+ doc/cpp.dvi: $(TEXI_CPP_FILES)
+ doc/gcc.dvi: $(TEXI_GCC_FILES)
diff --git a/toolchain/gcc/patches/4.8-linaro/020-no-plt-backport.patch b/toolchain/gcc/patches/4.8-linaro/020-no-plt-backport.patch
new file mode 100644
index 0000000..b225376
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/020-no-plt-backport.patch
@@ -0,0 +1,28 @@
+--- a/gcc/calls.c
++++ b/gcc/calls.c
+@@ -176,6 +176,12 @@ prepare_call_address (tree fndecl, rtx f
+ && targetm.small_register_classes_for_mode_p (FUNCTION_MODE))
+ ? force_not_mem (memory_address (FUNCTION_MODE, funexp))
+ : memory_address (FUNCTION_MODE, funexp));
++ else if (flag_pic && !flag_plt && fndecl
++ && TREE_CODE (fndecl) == FUNCTION_DECL
++ && !targetm.binds_local_p (fndecl))
++ {
++ funexp = force_reg (Pmode, funexp);
++ }
+ else if (! sibcallp)
+ {
+ #ifndef NO_FUNCTION_CSE
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -1617,6 +1617,10 @@ fpie
+ Common Report Var(flag_pie,1) Negative(fPIC)
+ Generate position-independent code for executables if possible (small mode)
+
++fplt
++Common Report Var(flag_plt) Init(1)
++Use PLT for PIC calls (-fno-plt: load the address from GOT at call site)
++
+ fplugin=
+ Common Joined RejectNegative Var(common_deferred_options) Defer
+ Specify a plugin to load
diff --git a/toolchain/gcc/patches/4.8-linaro/100-uclibc-conf.patch b/toolchain/gcc/patches/4.8-linaro/100-uclibc-conf.patch
new file mode 100644
index 0000000..ff9ad94
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/100-uclibc-conf.patch
@@ -0,0 +1,33 @@
+--- a/contrib/regression/objs-gcc.sh
++++ b/contrib/regression/objs-gcc.sh
+@@ -106,6 +106,10 @@ if [ $H_REAL_TARGET = $H_REAL_HOST -a $H
+ then
+ make all-gdb all-dejagnu all-ld || exit 1
+ make install-gdb install-dejagnu install-ld || exit 1
++elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
++ then
++ make all-gdb all-dejagnu all-ld || exit 1
++ make install-gdb install-dejagnu install-ld || exit 1
+ elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
+ make bootstrap || exit 1
+ make install || exit 1
+--- a/libjava/classpath/ltconfig
++++ b/libjava/classpath/ltconfig
+@@ -603,7 +603,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1247,7 +1247,7 @@ linux-gnuoldld* | linux-gnuaout* | linux
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
diff --git a/toolchain/gcc/patches/4.8-linaro/200-musl_config.patch b/toolchain/gcc/patches/4.8-linaro/200-musl_config.patch
new file mode 100644
index 0000000..0142745
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/200-musl_config.patch
@@ -0,0 +1,204 @@
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -559,7 +559,7 @@ case ${target} in
+ esac
+
+ # Common C libraries.
+-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
++tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
+
+ # Common parts for widely ported systems.
+ case ${target} in
+@@ -662,6 +662,9 @@ case ${target} in
+ *-*-*uclibc*)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
+ ;;
++ *-*-*musl*)
++ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
++ ;;
+ *)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
+ ;;
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -32,10 +32,12 @@ see the files COPYING3 and COPYING.RUNTI
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
+@@ -53,18 +55,21 @@ see the files COPYING3 and COPYING.RUNTI
+ uClibc or Bionic is the default C library and whether
+ -muclibc or -mglibc or -mbionic has been passed to change the default. */
+
+-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
+- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
++#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
++ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
+
+ #if DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
+ #elif DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
+ #elif DEFAULT_LIBC == LIBC_BIONIC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif /* DEFAULT_LIBC */
+@@ -84,21 +89,21 @@ see the files COPYING3 and COPYING.RUNTI
+
+ #define GNU_USER_DYNAMIC_LINKER \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
+- BIONIC_DYNAMIC_LINKER)
++ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+ #define GNU_USER_DYNAMIC_LINKER32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
+- BIONIC_DYNAMIC_LINKER32)
++ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define GNU_USER_DYNAMIC_LINKER64 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
+- BIONIC_DYNAMIC_LINKER64)
++ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+ #define GNU_USER_DYNAMIC_LINKERX32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
+- BIONIC_DYNAMIC_LINKERX32)
++ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
+
+ /* Determine whether the entire c99 runtime
+ is present in the runtime library. */
+ #undef TARGET_C99_FUNCTIONS
+-#define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
++#define TARGET_C99_FUNCTIONS (OPTION_GLIBC || OPTION_MUSL)
+
+ /* Whether we have sincos that follows the GNU extension. */
+ #undef TARGET_HAS_SINCOS
+@@ -107,3 +112,74 @@ see the files COPYING3 and COPYING.RUNTI
+ /* Whether we have Bionic libc runtime */
+ #undef TARGET_HAS_BIONIC
+ #define TARGET_HAS_BIONIC (OPTION_BIONIC)
++
++/* musl avoids problematic includes by rearranging the include directories.
++ * Unfortunately, this is mostly duplicated from cppdefault.c */
++#if DEFAULT_LIBC == LIBC_MUSL
++#define INCLUDE_DEFAULTS_MUSL_GPP \
++ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
++ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
++ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
++
++#ifdef LOCAL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_LOCAL \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_LOCAL
++#endif
++
++#ifdef PREFIX_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_PREFIX \
++ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_PREFIX
++#endif
++
++#ifdef CROSS_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_CROSS \
++ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#ifdef TOOL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_TOOL \
++ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_TOOL
++#endif
++
++#ifdef NATIVE_SYSTEM_HEADER_DIR
++#define INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_NATIVE
++#endif
++
++#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
++# undef INCLUDE_DEFAULTS_MUSL_LOCAL
++# define INCLUDE_DEFAULTS_MUSL_LOCAL
++# undef INCLUDE_DEFAULTS_MUSL_NATIVE
++# define INCLUDE_DEFAULTS_MUSL_NATIVE
++#else
++# undef INCLUDE_DEFAULTS_MUSL_CROSS
++# define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#undef INCLUDE_DEFAULTS
++#define INCLUDE_DEFAULTS \
++ { \
++ INCLUDE_DEFAULTS_MUSL_GPP \
++ INCLUDE_DEFAULTS_MUSL_PREFIX \
++ INCLUDE_DEFAULTS_MUSL_CROSS \
++ INCLUDE_DEFAULTS_MUSL_TOOL \
++ INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
++ { 0, 0, 0, 0, 0, 0 } \
++ }
++#endif
+--- a/gcc/config/linux.opt
++++ b/gcc/config/linux.opt
+@@ -30,3 +30,7 @@ Use GNU C library
+ muclibc
+ Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
+ Use uClibc C library
++
++mmusl
++Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
++Use musl C library
+--- a/gcc/ginclude/stddef.h
++++ b/gcc/ginclude/stddef.h
+@@ -181,6 +181,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
+ #ifndef _GCC_SIZE_T
+ #ifndef _SIZET_
+ #ifndef __size_t
++#ifndef __DEFINED_size_t /* musl */
+ #define __size_t__ /* BeOS */
+ #define __SIZE_T__ /* Cray Unicos/Mk */
+ #define _SIZE_T
+@@ -197,6 +198,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
+ #define ___int_size_t_h
+ #define _GCC_SIZE_T
+ #define _SIZET_
++#define __DEFINED_size_t /* musl */
+ #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
+ || defined(__FreeBSD_kernel__)
+ /* __size_t is a typedef on FreeBSD 5, must not trash it. */
+@@ -214,6 +216,7 @@ typedef __SIZE_TYPE__ size_t;
+ typedef long ssize_t;
+ #endif /* __BEOS__ */
+ #endif /* !(defined (__GNUG__) && defined (size_t)) */
++#endif /* __DEFINED_size_t */
+ #endif /* __size_t */
+ #endif /* _SIZET_ */
+ #endif /* _GCC_SIZE_T */
diff --git a/toolchain/gcc/patches/4.8-linaro/201-musl_arm.patch b/toolchain/gcc/patches/4.8-linaro/201-musl_arm.patch
new file mode 100644
index 0000000..f39ff52
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/201-musl_arm.patch
@@ -0,0 +1,40 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -77,6 +77,23 @@
+ %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
+ %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
+
++/* For ARM musl currently supports four dynamic linkers:
++ - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI
++ - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI
++ - ld-musl-armeb.so.1 - for the EABI-derived soft-float ABI, EB
++ - ld-musl-armebhf.so.1 - for the EABI-derived hard-float ABI, EB
++ musl does not support the legacy OABI mode.
++ All the dynamic linkers live in /lib.
++ We default to soft-float, EL. */
++#undef MUSL_DYNAMIC_LINKER
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:eb}"
++#else
++#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
++#endif
++#define MUSL_DYNAMIC_LINKER \
++ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
+--- a/libitm/config/arm/hwcap.cc
++++ b/libitm/config/arm/hwcap.cc
+@@ -40,7 +40,11 @@ int GTM_hwcap HIDDEN = 0
+
+ #ifdef __linux__
+ #include <unistd.h>
++#ifdef __GLIBC__
+ #include <sys/fcntl.h>
++#else
++#include <fcntl.h>
++#endif
+ #include <elf.h>
+
+ static void __attribute__((constructor))
diff --git a/toolchain/gcc/patches/4.8-linaro/202-musl_mips.patch b/toolchain/gcc/patches/4.8-linaro/202-musl_mips.patch
new file mode 100644
index 0000000..42a2648
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/202-musl_mips.patch
@@ -0,0 +1,13 @@
+--- a/gcc/config/mips/linux.h
++++ b/gcc/config/mips/linux.h
+@@ -18,3 +18,10 @@ along with GCC; see the file COPYING3.
+ <http://www.gnu.org/licenses/>. */
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
++
++#if TARGET_ENDIAN_DEFAULT == 0 /* LE */
++#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
++#else
++#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
++#endif
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E ".so.1"
diff --git a/toolchain/gcc/patches/4.8-linaro/203-musl_powerpc.patch b/toolchain/gcc/patches/4.8-linaro/203-musl_powerpc.patch
new file mode 100644
index 0000000..61e94be
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/203-musl_powerpc.patch
@@ -0,0 +1,100 @@
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -2122,6 +2122,10 @@ powerpc*-*-linux*)
+ powerpc*-*-linux*paired*)
+ tm_file="${tm_file} rs6000/750cl.h" ;;
+ esac
++ case ${target} in
++ *-linux*-musl*)
++ enable_secureplt=yes ;;
++ esac
+ if test x${enable_secureplt} = xyes; then
+ tm_file="rs6000/secureplt.h ${tm_file}"
+ fi
+--- a/gcc/config/rs6000/linux64.h
++++ b/gcc/config/rs6000/linux64.h
+@@ -354,17 +354,21 @@ extern int dot_symbols;
+ #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%{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 "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
+ #elif DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif
+ #define GNU_USER_DYNAMIC_LINKER32 \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define GNU_USER_DYNAMIC_LINKER64 \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+
+ #undef DEFAULT_ASM_ENDIAN
+ #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
+--- a/gcc/config/rs6000/secureplt.h
++++ b/gcc/config/rs6000/secureplt.h
+@@ -18,3 +18,4 @@ along with GCC; see the file COPYING3.
+ <http://www.gnu.org/licenses/>. */
+
+ #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
++#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
+--- a/gcc/config/rs6000/sysv4.h
++++ b/gcc/config/rs6000/sysv4.h
+@@ -550,6 +550,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+ #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
+ #define CC1_SECURE_PLT_DEFAULT_SPEC ""
+ #endif
++#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
++#define LINK_SECURE_PLT_DEFAULT_SPEC ""
++#endif
+
+ /* Pass -G xxx to the compiler and set correct endian mode. */
+ #define CC1_SPEC "%{G*} %(cc1_cpu)" \
+@@ -600,7 +603,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+
+ /* Override the default target of the linker. */
+ #define LINK_TARGET_SPEC \
+- ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
++ ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
++ "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
+
+ /* Any specific OS flags. */
+ #define LINK_OS_SPEC "\
+@@ -778,15 +782,18 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+
+ #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%{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 "}}"
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
+ #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif
+ #define GNU_USER_DYNAMIC_LINKER \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+
+ #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
+ %{rdynamic:-export-dynamic} \
+@@ -912,6 +919,7 @@ ncrtn.o%s"
+ { "cc1_endian_little", CC1_ENDIAN_LITTLE_SPEC }, \
+ { "cc1_endian_default", CC1_ENDIAN_DEFAULT_SPEC }, \
+ { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
++ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
+ { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
+ { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
+ { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
diff --git a/toolchain/gcc/patches/4.8-linaro/204-musl_sh.patch b/toolchain/gcc/patches/4.8-linaro/204-musl_sh.patch
new file mode 100644
index 0000000..9a50c22
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/204-musl_sh.patch
@@ -0,0 +1,17 @@
+--- a/gcc/config/sh/linux.h
++++ b/gcc/config/sh/linux.h
+@@ -43,7 +43,14 @@ along with GCC; see the file COPYING3.
+
+ #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
+
++#if TARGET_BIG_ENDIAN_DEFAULT /* BE */
++#define MUSL_DYNAMIC_LINKER_E "eb"
++#else
++#define MUSL_DYNAMIC_LINKER_E
++#endif
++
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E ".so.1"
+
+ #undef SUBTARGET_LINK_EMUL_SUFFIX
+ #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
diff --git a/toolchain/gcc/patches/4.8-linaro/205-musl_x86.patch b/toolchain/gcc/patches/4.8-linaro/205-musl_x86.patch
new file mode 100644
index 0000000..9a25113
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/205-musl_x86.patch
@@ -0,0 +1,48 @@
+--- a/gcc/config/i386/linux.h
++++ b/gcc/config/i386/linux.h
+@@ -21,3 +21,4 @@ along with GCC; see the file COPYING3.
+
+ #define GNU_USER_LINK_EMULATION "elf_i386"
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
+--- a/gcc/config/i386/linux64.h
++++ b/gcc/config/i386/linux64.h
+@@ -30,3 +30,7 @@ see the files COPYING3 and COPYING.RUNTI
+ #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
+ #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
+ #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
++
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
++#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
+--- a/libitm/config/linux/x86/tls.h
++++ b/libitm/config/linux/x86/tls.h
+@@ -25,16 +25,19 @@
+ #ifndef LIBITM_X86_TLS_H
+ #define LIBITM_X86_TLS_H 1
+
+-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
++#if defined(__GLIBC_PREREQ)
++#if __GLIBC_PREREQ(2, 10)
+ /* Use slots in the TCB head rather than __thread lookups.
+ GLIBC has reserved words 10 through 13 for TM. */
+ #define HAVE_ARCH_GTM_THREAD 1
+ #define HAVE_ARCH_GTM_THREAD_DISP 1
+ #endif
++#endif
+
+ #include "config/generic/tls.h"
+
+-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
++#if defined(__GLIBC_PREREQ)
++#if __GLIBC_PREREQ(2, 10)
+ namespace GTM HIDDEN {
+
+ #ifdef __x86_64__
+@@ -101,5 +104,6 @@ static inline void set_abi_disp(struct a
+
+ } // namespace GTM
+ #endif /* >= GLIBC 2.10 */
++#endif
+
+ #endif // LIBITM_X86_TLS_H
diff --git a/toolchain/gcc/patches/4.8-linaro/206-musl_aarch64.patch b/toolchain/gcc/patches/4.8-linaro/206-musl_aarch64.patch
new file mode 100644
index 0000000..9d75dc9
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/206-musl_aarch64.patch
@@ -0,0 +1,14 @@
+--- a/gcc/config/aarch64/aarch64-linux.h
++++ b/gcc/config/aarch64/aarch64-linux.h
+@@ -21,7 +21,11 @@
+ #ifndef GCC_AARCH64_LINUX_H
+ #define GCC_AARCH64_LINUX_H
+
++/* The AArch64 port currently supports two dynamic linkers:
++ - ld-linux-aarch64.so.1 - GLIBC dynamic linker
++ - ld-musl-aarch64.so.1 - musl libc dynamic linker */
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64.so.1"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64.so.1"
+
+ #define CPP_SPEC "%{pthread:-D_REENTRANT}"
+
diff --git a/toolchain/gcc/patches/4.8-linaro/207-musl_fixincludes.patch b/toolchain/gcc/patches/4.8-linaro/207-musl_fixincludes.patch
new file mode 100644
index 0000000..e6fa47f
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/207-musl_fixincludes.patch
@@ -0,0 +1,12 @@
+--- a/fixincludes/mkfixinc.sh
++++ b/fixincludes/mkfixinc.sh
+@@ -19,7 +19,8 @@ case $machine in
+ powerpc-*-eabi* | \
+ powerpc-*-rtems* | \
+ powerpcle-*-eabisim* | \
+- powerpcle-*-eabi* )
++ powerpcle-*-eabi* | \
++ *-musl* )
+ # IF there is no include fixing,
+ # THEN create a no-op fixer and exit
+ (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}
diff --git a/toolchain/gcc/patches/4.8-linaro/208-musl_gomp.patch b/toolchain/gcc/patches/4.8-linaro/208-musl_gomp.patch
new file mode 100644
index 0000000..84c781e
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/208-musl_gomp.patch
@@ -0,0 +1,11 @@
+--- a/libgomp/config/posix/time.c
++++ b/libgomp/config/posix/time.c
+@@ -28,6 +28,8 @@
+ The following implementation uses the most simple POSIX routines.
+ If present, POSIX 4 clocks should be used instead. */
+
++#define _POSIX_C_SOURCE 199309L /* for clocks */
++
+ #include "libgomp.h"
+ #include <unistd.h>
+ #if TIME_WITH_SYS_TIME
diff --git a/toolchain/gcc/patches/4.8-linaro/209-musl_libstdc++.patch b/toolchain/gcc/patches/4.8-linaro/209-musl_libstdc++.patch
new file mode 100644
index 0000000..6643935
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/209-musl_libstdc++.patch
@@ -0,0 +1,26 @@
+--- a/libstdc++-v3/configure.host
++++ b/libstdc++-v3/configure.host
+@@ -264,6 +264,13 @@ case "${host_os}" in
+ os_include_dir="os/bsd/freebsd"
+ ;;
+ gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
++ # check for musl by target
++ case "${host_os}" in
++ *-musl*)
++ os_include_dir="os/generic"
++ ;;
++ *)
++
+ if [ "$uclibc" = "yes" ]; then
+ os_include_dir="os/uclibc"
+ elif [ "$bionic" = "yes" ]; then
+@@ -272,6 +279,9 @@ case "${host_os}" in
+ os_include_dir="os/gnu-linux"
+ fi
+ ;;
++
++ esac
++ ;;
+ hpux*)
+ os_include_dir="os/hpux"
+ ;;
diff --git a/toolchain/gcc/patches/4.8-linaro/210-disable_libsanitizer_off_t_check.patch b/toolchain/gcc/patches/4.8-linaro/210-disable_libsanitizer_off_t_check.patch
new file mode 100644
index 0000000..5608469
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/210-disable_libsanitizer_off_t_check.patch
@@ -0,0 +1,11 @@
+--- a/libsanitizer/interception/interception_type_test.cc
++++ b/libsanitizer/interception/interception_type_test.cc
+@@ -31,7 +31,7 @@ COMPILER_CHECK(sizeof(OFF64_T) == sizeof
+ // rest (they depend on _FILE_OFFSET_BITS setting when building an application).
+ # if defined(__ANDROID__) || !defined _FILE_OFFSET_BITS || \
+ _FILE_OFFSET_BITS != 64
+-COMPILER_CHECK(sizeof(OFF_T) == sizeof(off_t));
++// COMPILER_CHECK(sizeof(OFF_T) == sizeof(off_t));
+ # endif
+
+ #endif
diff --git a/toolchain/gcc/patches/4.8-linaro/220-musl_mips_softfloat.patch b/toolchain/gcc/patches/4.8-linaro/220-musl_mips_softfloat.patch
new file mode 100644
index 0000000..b86adf5
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/220-musl_mips_softfloat.patch
@@ -0,0 +1,8 @@
+--- a/gcc/config/mips/linux.h
++++ b/gcc/config/mips/linux.h
+@@ -24,4 +24,4 @@ along with GCC; see the file COPYING3.
+ #else
+ #define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
+ #endif
+-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E ".so.1"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
diff --git a/toolchain/gcc/patches/4.8-linaro/221-musl_mips64.patch b/toolchain/gcc/patches/4.8-linaro/221-musl_mips64.patch
new file mode 100644
index 0000000..7447dbd
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/221-musl_mips64.patch
@@ -0,0 +1,22 @@
+Index: gcc-linaro-4.8-2014.04/gcc/config/mips/linux64.h
+===================================================================
+--- gcc-linaro-4.8-2014.04.orig/gcc/config/mips/linux64.h 2014-10-23 15:52:48.999134219 -0700
++++ gcc-linaro-4.8-2014.04/gcc/config/mips/linux64.h 2014-10-23 15:59:19.815116979 -0700
+@@ -27,6 +27,16 @@
+ #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
+ #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
+ #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
++
++#if TARGET_ENDIAN_DEFAULT == 0 /* LE */
++#define MUSL_DYNAMIC_LINKER_E "%{EB:;:el}"
++#else
++#define MUSL_DYNAMIC_LINKER_E "%{EL:el}"
++#endif
++
++#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+ #define GNU_USER_DYNAMIC_LINKERN32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
+- BIONIC_DYNAMIC_LINKERN32)
++ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
diff --git a/toolchain/gcc/patches/4.8-linaro/230-musl_libssp.patch b/toolchain/gcc/patches/4.8-linaro/230-musl_libssp.patch
new file mode 100644
index 0000000..2217693
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/230-musl_libssp.patch
@@ -0,0 +1,13 @@
+--- 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}"
diff --git a/toolchain/gcc/patches/4.8-linaro/800-arm_v5te_no_ldrd_strd.patch b/toolchain/gcc/patches/4.8-linaro/800-arm_v5te_no_ldrd_strd.patch
new file mode 100644
index 0000000..efa9789
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/800-arm_v5te_no_ldrd_strd.patch
@@ -0,0 +1,11 @@
+--- a/gcc/config/arm/arm.h
++++ b/gcc/config/arm/arm.h
+@@ -277,7 +277,7 @@ extern void (*arm_lang_output_object_att
+ /* Thumb-1 only. */
+ #define TARGET_THUMB1_ONLY (TARGET_THUMB1 && !arm_arch_notm)
+
+-#define TARGET_LDRD (arm_arch5e && ARM_DOUBLEWORD_ALIGN \
++#define TARGET_LDRD (arm_arch6 && ARM_DOUBLEWORD_ALIGN \
+ && !TARGET_THUMB1)
+
+ #define TARGET_CRC32 (arm_arch_crc)
diff --git a/toolchain/gcc/patches/4.8-linaro/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches/4.8-linaro/810-arm-softfloat-libgcc.patch
new file mode 100644
index 0000000..33cf8ad
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/810-arm-softfloat-libgcc.patch
@@ -0,0 +1,25 @@
+--- a/libgcc/config/arm/t-linux
++++ b/libgcc/config/arm/t-linux
+@@ -1,6 +1,10 @@
+ LIB1ASMSRC = arm/lib1funcs.S
+ LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \
+- _ctzsi2 _arm_addsubdf3 _arm_addsubsf3
++ _ctzsi2 _arm_addsubdf3 _arm_addsubsf3 \
++ _arm_negdf2 _arm_muldivdf3 _arm_cmpdf2 _arm_unorddf2 \
++ _arm_fixdfsi _arm_fixunsdfsi _arm_truncdfsf2 \
++ _arm_negsf2 _arm_muldivsf3 _arm_cmpsf2 _arm_unordsf2 \
++ _arm_fixsfsi _arm_fixunssfsi
+
+ # Just for these, we omit the frame pointer since it makes such a big
+ # difference.
+--- a/gcc/config/arm/linux-elf.h
++++ b/gcc/config/arm/linux-elf.h
+@@ -55,8 +55,6 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
+-
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+ #define LINUX_TARGET_LINK_SPEC "%{h*} \
diff --git a/toolchain/gcc/patches/4.8-linaro/820-libgcc_pic.patch b/toolchain/gcc/patches/4.8-linaro/820-libgcc_pic.patch
new file mode 100644
index 0000000..7a0ac73
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/820-libgcc_pic.patch
@@ -0,0 +1,36 @@
+--- a/libgcc/Makefile.in
++++ b/libgcc/Makefile.in
+@@ -865,11 +865,12 @@ $(libgcov-objects): %$(objext): $(srcdir
+
+ # Static libraries.
+ libgcc.a: $(libgcc-objects)
++libgcc_pic.a: $(libgcc-s-objects)
+ libgcov.a: $(libgcov-objects)
+ libunwind.a: $(libunwind-objects)
+ libgcc_eh.a: $(libgcc-eh-objects)
+
+-libgcc.a libgcov.a libunwind.a libgcc_eh.a:
++libgcc.a libgcov.a libunwind.a libgcc_eh.a libgcc_pic.a:
+ -rm -f $@
+
+ objects="$(objects)"; \
+@@ -891,7 +892,7 @@ libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_E
+ endif
+
+ ifeq ($(enable_shared),yes)
+-all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
++all: libgcc_eh.a libgcc_pic.a libgcc_s$(SHLIB_EXT)
+ ifneq ($(LIBUNWIND),)
+ all: libunwind$(SHLIB_EXT)
+ endif
+@@ -1058,6 +1059,10 @@ install-shared:
+ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a
+ $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a
+
++ $(INSTALL_DATA) libgcc_pic.a $(mapfile) $(DESTDIR)$(inst_libdir)/
++ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_pic.a
++ $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_pic.a
++
+ $(subst @multilib_dir@,$(MULTIDIR),$(subst \
+ @shlib_base_name@,libgcc_s,$(subst \
+ @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))
diff --git a/toolchain/gcc/patches/4.8-linaro/830-arm_unbreak_armv4t.patch b/toolchain/gcc/patches/4.8-linaro/830-arm_unbreak_armv4t.patch
new file mode 100644
index 0000000..37f8f2a
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/830-arm_unbreak_armv4t.patch
@@ -0,0 +1,13 @@
+http://sourceware.org/ml/crossgcc/2008-05/msg00009.html
+
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -45,7 +45,7 @@
+ The ARM10TDMI core is the default for armv5t, so set
+ SUBTARGET_CPU_DEFAULT to achieve this. */
+ #undef SUBTARGET_CPU_DEFAULT
+-#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm10tdmi
++#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm9tdmi
+
+ /* TARGET_BIG_ENDIAN_DEFAULT is set in
+ config.gcc for big endian configurations. */
diff --git a/toolchain/gcc/patches/4.8-linaro/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches/4.8-linaro/840-armv4_pass_fix-v4bx_to_ld.patch
new file mode 100644
index 0000000..2283b83
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/840-armv4_pass_fix-v4bx_to_ld.patch
@@ -0,0 +1,19 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -94,10 +94,15 @@
+ #define MUSL_DYNAMIC_LINKER \
+ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
+
++/* For armv4 we pass --fix-v4bx to linker to support EABI */
++#undef TARGET_FIX_V4BX_SPEC
++#define TARGET_FIX_V4BX_SPEC " %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*"\
++ "|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx}"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
+-#define LINK_SPEC BE8_LINK_SPEC \
++#define LINK_SPEC BE8_LINK_SPEC TARGET_FIX_V4BX_SPEC \
+ LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \
+ LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
+
diff --git a/toolchain/gcc/patches/4.8-linaro/850-use_shared_libgcc.patch b/toolchain/gcc/patches/4.8-linaro/850-use_shared_libgcc.patch
new file mode 100644
index 0000000..6934bc9
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/850-use_shared_libgcc.patch
@@ -0,0 +1,47 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -131,10 +131,6 @@
+ #define ENDFILE_SPEC \
+ LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC)
+
+-/* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we
+- do not use -lfloat. */
+-#undef LIBGCC_SPEC
+-
+ /* Clear the instruction cache from `beg' to `end'. This is
+ implemented in lib1funcs.S, so ensure an error if this definition
+ is used. */
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -51,6 +51,10 @@ see the files COPYING3 and COPYING.RUNTI
+ builtin_assert ("system=posix"); \
+ } while (0)
+
++#ifndef LIBGCC_SPEC
++#define LIBGCC_SPEC "%{static|static-libgcc:-lgcc}%{!static:%{!static-libgcc:-lgcc_s}}"
++#endif
++
+ /* Determine which dynamic linker to use depending on whether GLIBC or
+ uClibc or Bionic is the default C library and whether
+ -muclibc or -mglibc or -mbionic has been passed to change the default. */
+--- a/libgcc/mkmap-symver.awk
++++ b/libgcc/mkmap-symver.awk
+@@ -132,5 +132,5 @@ function output(lib) {
+ else if (inherit[lib])
+ printf("} %s;\n", inherit[lib]);
+ else
+- printf ("\n local:\n\t*;\n};\n");
++ printf ("\n\t*;\n};\n");
+ }
+--- a/gcc/config/rs6000/linux.h
++++ b/gcc/config/rs6000/linux.h
+@@ -61,6 +61,9 @@
+ #undef CPLUSPLUS_CPP_SPEC
+ #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
+
++#undef LIBGCC_SPEC
++#define LIBGCC_SPEC "%{!static:%{!static-libgcc:-lgcc_s}} -lgcc"
++
+ #undef LINK_SHLIB_SPEC
+ #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
+
diff --git a/toolchain/gcc/patches/4.8-linaro/851-libgcc_no_compat.patch b/toolchain/gcc/patches/4.8-linaro/851-libgcc_no_compat.patch
new file mode 100644
index 0000000..80c3476
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/851-libgcc_no_compat.patch
@@ -0,0 +1,12 @@
+--- a/libgcc/config/t-libunwind
++++ b/libgcc/config/t-libunwind
+@@ -2,8 +2,7 @@
+
+ HOST_LIBGCC2_CFLAGS += -DUSE_GAS_SYMVER
+
+-LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c \
+- $(srcdir)/unwind-compat.c $(srcdir)/unwind-dw2-fde-compat.c
++LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
+ LIB2ADDEHSTATIC = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
+
+ # Override the default value from t-slibgcc-elf-ver and mention -lunwind
diff --git a/toolchain/gcc/patches/4.8-linaro/860-use_eh_frame.patch b/toolchain/gcc/patches/4.8-linaro/860-use_eh_frame.patch
new file mode 100644
index 0000000..1ac83fe
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/860-use_eh_frame.patch
@@ -0,0 +1,42 @@
+--- a/libgcc/unwind-dw2-fde-dip.c
++++ b/libgcc/unwind-dw2-fde-dip.c
+@@ -46,33 +46,13 @@
+ #include "unwind-compat.h"
+ #include "gthr.h"
+
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+- && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
+- || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
+-# define USE_PT_GNU_EH_FRAME
+-#endif
+-
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+- && defined(__BIONIC__)
+-# define USE_PT_GNU_EH_FRAME
+-#endif
+-
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+- && defined(__FreeBSD__) && __FreeBSD__ >= 7
+-# define ElfW __ElfN
+-# define USE_PT_GNU_EH_FRAME
+-#endif
+-
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+- && defined(__OpenBSD__)
+-# define ElfW(type) Elf_##type
+-# define USE_PT_GNU_EH_FRAME
+-#endif
+-
+-#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+- && defined(TARGET_DL_ITERATE_PHDR) \
+- && defined(__sun__) && defined(__svr4__)
++#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR)
+ # define USE_PT_GNU_EH_FRAME
++# ifdef __OpenBSD__
++# define ElfW(type) Elf_##type
++# elif defined(__FreeBSD__) && __FreeBSD__ >= 7
++# define ElfW __ElfN
++# endif
+ #endif
+
+ #if defined(USE_PT_GNU_EH_FRAME)
diff --git a/toolchain/gcc/patches/4.8-linaro/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches/4.8-linaro/870-ppc_no_crtsavres.patch
new file mode 100644
index 0000000..4b7fcbd
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/870-ppc_no_crtsavres.patch
@@ -0,0 +1,11 @@
+--- a/gcc/config/rs6000/rs6000.c
++++ b/gcc/config/rs6000/rs6000.c
+@@ -17662,7 +17662,7 @@ rs6000_savres_strategy (rs6000_stack_t *
+ /* Define cutoff for using out-of-line functions to save registers. */
+ if (DEFAULT_ABI == ABI_V4 || TARGET_ELF)
+ {
+- if (!optimize_size)
++ if (1)
+ {
+ strategy |= SAVE_INLINE_FPRS | REST_INLINE_FPRS;
+ strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS;
diff --git a/toolchain/gcc/patches/4.8-linaro/880-no_java_section.patch b/toolchain/gcc/patches/4.8-linaro/880-no_java_section.patch
new file mode 100644
index 0000000..def6c9f
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/880-no_java_section.patch
@@ -0,0 +1,11 @@
+--- a/gcc/defaults.h
++++ b/gcc/defaults.h
+@@ -380,7 +380,7 @@ see the files COPYING3 and COPYING.RUNTI
+ /* If we have named section and we support weak symbols, then use the
+ .jcr section for recording java classes which need to be registered
+ at program start-up time. */
+-#if defined (TARGET_ASM_NAMED_SECTION) && SUPPORTS_WEAK
++#if 0 && defined (TARGET_ASM_NAMED_SECTION) && SUPPORTS_WEAK
+ #ifndef JCR_SECTION_NAME
+ #define JCR_SECTION_NAME ".jcr"
+ #endif
diff --git a/toolchain/gcc/patches/4.8-linaro/900-bad-mips16-crt.patch b/toolchain/gcc/patches/4.8-linaro/900-bad-mips16-crt.patch
new file mode 100644
index 0000000..dd6e9dc
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/900-bad-mips16-crt.patch
@@ -0,0 +1,9 @@
+--- a/libgcc/config/mips/t-mips16
++++ b/libgcc/config/mips/t-mips16
+@@ -43,3 +43,6 @@ SYNC_CFLAGS = -mno-mips16
+
+ # Version these symbols if building libgcc.so.
+ SHLIB_MAPFILES += $(srcdir)/config/mips/libgcc-mips16.ver
++
++CRTSTUFF_T_CFLAGS += -mno-mips16
++CRTSTUFF_T_CFLAGS_S += -mno-mips16
diff --git a/toolchain/gcc/patches/4.8-linaro/910-mbsd_multi.patch b/toolchain/gcc/patches/4.8-linaro/910-mbsd_multi.patch
new file mode 100644
index 0000000..5387f8e
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/910-mbsd_multi.patch
@@ -0,0 +1,253 @@
+
+ This patch brings over a few features from MirBSD:
+ * -fhonour-copts
+ If this option is not given, it's warned (depending
+ on environment variables). This is to catch errors
+ of misbuilt packages which override CFLAGS themselves.
+ * -Werror-maybe-reset
+ Has the effect of -Wno-error if GCC_NO_WERROR is
+ set and not '0', a no-operation otherwise. This is
+ to be able to use -Werror in "make" but prevent
+ GNU autoconf generated configure scripts from
+ freaking out.
+ * Make -fno-strict-aliasing and -fno-delete-null-pointer-checks
+ the default for -O2/-Os, because they trigger gcc bugs
+ and can delete code with security implications.
+
+ This patch was authored by Thorsten Glaser <tg at mirbsd.de>
+ with copyright assignment to the FSF in effect.
+
+--- a/gcc/c-family/c-opts.c
++++ b/gcc/c-family/c-opts.c
+@@ -104,6 +104,9 @@ static size_t include_cursor;
+ /* Whether any standard preincluded header has been preincluded. */
+ static bool done_preinclude;
+
++/* Check if a port honours COPTS. */
++static int honour_copts = 0;
++
+ static void handle_OPT_d (const char *);
+ static void set_std_cxx98 (int);
+ static void set_std_cxx11 (int);
+@@ -383,6 +386,9 @@ c_common_handle_option (size_t scode, co
+ cpp_opts->warn_endif_labels = value;
+ break;
+
++ case OPT_Werror_maybe_reset:
++ break;
++
+ case OPT_Winvalid_pch:
+ cpp_opts->warn_invalid_pch = value;
+ break;
+@@ -491,6 +497,12 @@ c_common_handle_option (size_t scode, co
+ flag_no_builtin = !value;
+ break;
+
++ case OPT_fhonour_copts:
++ if (c_language == clk_c) {
++ honour_copts++;
++ }
++ break;
++
+ case OPT_fconstant_string_class_:
+ constant_string_class_name = arg;
+ break;
+@@ -1027,6 +1039,47 @@ c_common_init (void)
+ return false;
+ }
+
++ if (c_language == clk_c) {
++ char *ev = getenv ("GCC_HONOUR_COPTS");
++ int evv;
++ if (ev == NULL)
++ evv = -1;
++ else if ((*ev == '0') || (*ev == '\0'))
++ evv = 0;
++ else if (*ev == '1')
++ evv = 1;
++ else if (*ev == '2')
++ evv = 2;
++ else if (*ev == 's')
++ evv = -1;
++ else {
++ warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
++ evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
++ }
++ if (evv == 1) {
++ if (honour_copts == 0) {
++ error ("someone does not honour COPTS at all in lenient mode");
++ return false;
++ } else if (honour_copts != 1) {
++ warning (0, "someone does not honour COPTS correctly, passed %d times",
++ honour_copts);
++ }
++ } else if (evv == 2) {
++ if (honour_copts == 0) {
++ error ("someone does not honour COPTS at all in strict mode");
++ return false;
++ } else if (honour_copts != 1) {
++ error ("someone does not honour COPTS correctly, passed %d times",
++ honour_copts);
++ return false;
++ }
++ } else if (evv == 0) {
++ if (honour_copts != 1)
++ inform (0, "someone does not honour COPTS correctly, passed %d times",
++ honour_copts);
++ }
++ }
++
+ return true;
+ }
+
+--- a/gcc/c-family/c.opt
++++ b/gcc/c-family/c.opt
+@@ -379,6 +379,10 @@ Werror-implicit-function-declaration
+ C ObjC RejectNegative Warning Alias(Werror=, implicit-function-declaration)
+ This switch is deprecated; use -Werror=implicit-function-declaration instead
+
++Werror-maybe-reset
++C ObjC C++ ObjC++
++; Documented in common.opt
++
+ Wfloat-equal
+ C ObjC C++ ObjC++ Var(warn_float_equal) Warning
+ Warn if testing floating point numbers for equality
+@@ -949,6 +953,9 @@ C++ ObjC++ Optimization Alias(fexception
+ fhonor-std
+ C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
+
++fhonour-copts
++C ObjC C++ ObjC++ RejectNegative
++
+ fhosted
+ C ObjC
+ Assume normal C execution environment
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -541,6 +541,10 @@ Werror=
+ Common Joined
+ Treat specified warning as error
+
++Werror-maybe-reset
++Common
++If environment variable GCC_NO_WERROR is set, act as -Wno-error
++
+ Wextra
+ Common Var(extra_warnings) Warning
+ Print extra (possibly unwanted) warnings
+@@ -1242,6 +1246,9 @@ fguess-branch-probability
+ Common Report Var(flag_guess_branch_prob) Optimization
+ Enable guessing of branch probabilities
+
++fhonour-copts
++Common RejectNegative
++
+ ; Nonzero means ignore `#ident' directives. 0 means handle them.
+ ; Generate position-independent code for executables if possible
+ ; On SVR4 targets, it also controls whether or not to emit a
+--- a/gcc/opts.c
++++ b/gcc/opts.c
+@@ -468,8 +468,6 @@ static const struct default_options defa
+ { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 },
+ #endif
+ { OPT_LEVELS_2_PLUS, OPT_fregmove, NULL, 1 },
+- { OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 },
+- { OPT_LEVELS_2_PLUS, OPT_fstrict_overflow, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_freorder_blocks, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 },
+ { OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 },
+@@ -489,6 +487,8 @@ static const struct default_options defa
+ { OPT_LEVELS_2_PLUS, OPT_fhoist_adjacent_loads, NULL, 1 },
+
+ /* -O3 optimizations. */
++ { OPT_LEVELS_3_PLUS, OPT_fstrict_aliasing, NULL, 1 },
++ { OPT_LEVELS_3_PLUS, OPT_fstrict_overflow, NULL, 1 },
+ { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
+ { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 },
+ /* Inlining of functions reducing size is a good idea with -Os
+@@ -1435,6 +1435,17 @@ common_handle_option (struct gcc_options
+ opts, opts_set, loc, dc);
+ break;
+
++ case OPT_Werror_maybe_reset:
++ {
++ char *ev = getenv ("GCC_NO_WERROR");
++ if ((ev != NULL) && (*ev != '0'))
++ warnings_are_errors = 0;
++ }
++ break;
++
++ case OPT_fhonour_copts:
++ break;
++
+ case OPT_Wlarger_than_:
+ opts->x_larger_than_size = value;
+ opts->x_warn_larger_than = value != -1;
+--- a/gcc/doc/cppopts.texi
++++ b/gcc/doc/cppopts.texi
+@@ -163,6 +163,11 @@ in older programs. This warning is on b
+ Make all warnings into hard errors. Source code which triggers warnings
+ will be rejected.
+
++ at item -Werror-maybe-reset
++ at opindex Werror-maybe-reset
++Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
++variable is set to anything other than 0 or empty.
++
+ @item -Wsystem-headers
+ @opindex Wsystem-headers
+ Issue warnings for code in system headers. These are normally unhelpful
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -240,7 +240,7 @@ Objective-C and Objective-C++ Dialects}.
+ -Wconversion -Wcoverage-mismatch -Wno-cpp -Wno-deprecated @gol
+ -Wno-deprecated-declarations -Wdisabled-optimization @gol
+ -Wno-div-by-zero -Wdouble-promotion -Wempty-body -Wenum-compare @gol
+--Wno-endif-labels -Werror -Werror=* @gol
++-Wno-endif-labels -Werror -Werror=* -Werror-maybe-reset @gol
+ -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
+ -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
+ -Wformat-security -Wformat-y2k @gol
+@@ -4817,6 +4817,22 @@ This option is only supported for C and
+ @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
+ @option{-Wno-pointer-sign}.
+
++ at item -Werror-maybe-reset
++ at opindex Werror-maybe-reset
++Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
++variable is set to anything other than 0 or empty.
++
++ at item -fhonour-copts
++ at opindex fhonour-copts
++If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
++given at least once, and warn if it is given more than once.
++If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
++given exactly once.
++If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
++is not given exactly once.
++The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
++This flag and environment variable only affect the C language.
++
+ @item -Wstack-protector
+ @opindex Wstack-protector
+ @opindex Wno-stack-protector
+@@ -6928,7 +6944,7 @@ so, the first branch is redirected to ei
+ second branch or a point immediately following it, depending on whether
+ the condition is known to be true or false.
+
+-Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
++Enabled at levels @option{-O3}.
+
+ @item -fsplit-wide-types
+ @opindex fsplit-wide-types
+--- a/gcc/java/jvspec.c
++++ b/gcc/java/jvspec.c
+@@ -626,6 +626,7 @@ lang_specific_pre_link (void)
+ class name. Append dummy `.c' that can be stripped by set_input so %b
+ is correct. */
+ set_input (concat (main_class_name, "main.c", NULL));
++ putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
+ err = do_spec (jvgenmain_spec);
+ if (err == 0)
+ {
diff --git a/toolchain/gcc/patches/4.8-linaro/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches/4.8-linaro/920-specs_nonfatal_getenv.patch
new file mode 100644
index 0000000..09768f5
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/920-specs_nonfatal_getenv.patch
@@ -0,0 +1,14 @@
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -8029,7 +8029,10 @@ getenv_spec_function (int argc, const ch
+
+ value = getenv (argv[0]);
+ if (!value)
+- fatal_error ("environment variable %qs not defined", argv[0]);
++ {
++ warning (0, "environment variable %qs not defined", argv[0]);
++ value = "";
++ }
+
+ /* We have to escape every character of the environment variable so
+ they are not interpreted as active spec characters. A
diff --git a/toolchain/gcc/patches/4.8-linaro/930-fix-mips-noexecstack.patch b/toolchain/gcc/patches/4.8-linaro/930-fix-mips-noexecstack.patch
new file mode 100644
index 0000000..e72ed3a
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/930-fix-mips-noexecstack.patch
@@ -0,0 +1,111 @@
+From da45b3fde60095756f5f6030f6012c23a3d34429 Mon Sep 17 00:00:00 2001
+From: Andrew McDonnell <bugs@andrewmcdonnell.net>
+Date: Fri, 3 Oct 2014 19:09:00 +0930
+Subject: Add .note.GNU-stack section
+
+See http://lists.busybox.net/pipermail/uclibc/2014-October/048671.html
+Below copied from https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02430.html
+
+Re: [Patch, MIPS] Add .note.GNU-stack section
+
+ From: Steve Ellcey <sellcey at mips dot com>
+
+On Wed, 2014-09-10 at 10:15 -0700, Eric Christopher wrote:
+>
+>
+> On Wed, Sep 10, 2014 at 9:27 AM, <pinskia@gmail.com> wrote:
+
+> This works except you did not update the assembly files in
+> libgcc or glibc. We (Cavium) have the same patch in our tree
+> for a few released versions.
+
+> Mind just checking yours in then Andrew?
+
+> Thanks!
+> -eric
+
+I talked to Andrew about what files he changed in GCC and created and
+tested this new patch. Andrew also mentioned changing some assembly
+files in glibc but I don't see any use of '.section .note.GNU-stack' in
+any assembly files in glibc (for any platform) so I wasn't planning on
+creating a glibc to add them to mips glibc assembly language files.
+
+OK to check in this patch?
+
+Steve Ellcey
+sellcey@mips.com
+
+
+
+2014-09-26 Steve Ellcey <sellcey@mips.com>
+---
+ gcc/config/mips/mips.c | 3 +++
+ libgcc/config/mips/crti.S | 4 ++++
+ libgcc/config/mips/crtn.S | 3 +++
+ libgcc/config/mips/mips16.S | 4 ++++
+ libgcc/config/mips/vr4120-div.S | 4 ++++
+ 5 files changed, 18 insertions(+)
+
+--- a/gcc/config/mips/mips.c
++++ b/gcc/config/mips/mips.c
+@@ -18223,6 +18223,9 @@ mips_expand_vec_minmax (rtx target, rtx
+ #undef TARGET_VECTORIZE_VEC_PERM_CONST_OK
+ #define TARGET_VECTORIZE_VEC_PERM_CONST_OK mips_vectorize_vec_perm_const_ok
+
++#undef TARGET_ASM_FILE_END
++#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
++
+ struct gcc_target targetm = TARGET_INITIALIZER;
+
+ #include "gt-mips.h"
+--- a/libgcc/config/mips/crti.S
++++ b/libgcc/config/mips/crti.S
+@@ -21,6 +21,10 @@ a copy of the GCC Runtime Library Except
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++
+ /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack.
+ Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */
+
+--- a/libgcc/config/mips/crtn.S
++++ b/libgcc/config/mips/crtn.S
+@@ -21,6 +21,9 @@ a copy of the GCC Runtime Library Except
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++
+ /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack.
+ Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */
+
+--- a/libgcc/config/mips/mips16.S
++++ b/libgcc/config/mips/mips16.S
+@@ -27,6 +27,10 @@ see the files COPYING3 and COPYING.RUNTI
+ values using the soft-float calling convention, but do the actual
+ operation using the hard floating point instructions. */
+
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++ .previous
++
+ #if defined _MIPS_SIM && (_MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIO64)
+
+ /* This file contains 32-bit assembly code. */
+--- a/libgcc/config/mips/vr4120-div.S
++++ b/libgcc/config/mips/vr4120-div.S
+@@ -26,6 +26,10 @@ see the files COPYING3 and COPYING.RUNTI
+ -mfix-vr4120. div and ddiv do not give the correct result when one
+ of the operands is negative. */
+
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++ .previous
++
+ .set nomips16
+
+ #define DIV \
diff --git a/toolchain/gcc/patches/4.8-linaro/940-no-clobber-stamp-bits.patch b/toolchain/gcc/patches/4.8-linaro/940-no-clobber-stamp-bits.patch
new file mode 100644
index 0000000..dbecef2
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/940-no-clobber-stamp-bits.patch
@@ -0,0 +1,11 @@
+--- a/libstdc++-v3/include/Makefile.in
++++ b/libstdc++-v3/include/Makefile.in
+@@ -1342,7 +1342,7 @@
+ @$(STAMP) stamp-bits
+
+ stamp-bits-sup: stamp-bits ${bits_sup_headers}
+- @-cd ${bits_builddir} && $(LN_S) $? . 2>/dev/null
++ @-cd ${bits_builddir} && $(LN_S) $(filter-out stamp-bits,$?) . 2>/dev/null
+ @$(STAMP) stamp-bits-sup
+
+ stamp-c_base: ${c_base_headers}
diff --git a/toolchain/gcc/patches/4.8-linaro/951-arm_bug_58595.patch b/toolchain/gcc/patches/4.8-linaro/951-arm_bug_58595.patch
new file mode 100644
index 0000000..f487dbc
--- /dev/null
+++ b/toolchain/gcc/patches/4.8-linaro/951-arm_bug_58595.patch
@@ -0,0 +1,117 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58595
+
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/tls/pr58595.c
+@@ -0,0 +1,28 @@
++/* PR target/58595 */
++/* { dg-do run } */
++/* { dg-options "-O2" } */
++/* { dg-additional-options "-fpic" { target fpic } } */
++/* { dg-require-effective-target tls } */
++/* { dg-require-effective-target sync_int_long } */
++
++struct S { unsigned long a, b; };
++__thread struct S s;
++void bar (unsigned long *);
++
++__attribute__((noinline)) void
++foo (void)
++{
++ int i;
++ for (i = 0; i < 10; i++)
++ __sync_fetch_and_add (&s.b, 1L);
++}
++
++int
++main ()
++{
++ s.b = 12;
++ foo ();
++ if (s.b != 22)
++ __builtin_abort ();
++ return 0;
++}
+--- a/gcc/config/arm/arm.c
++++ b/gcc/config/arm/arm.c
+@@ -231,7 +231,6 @@ static tree arm_gimplify_va_arg_expr (tr
+ static void arm_option_override (void);
+ static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode);
+ static bool arm_cannot_copy_insn_p (rtx);
+-static bool arm_tls_symbol_p (rtx x);
+ static int arm_issue_rate (void);
+ static void arm_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
+ static bool arm_output_addr_const_extra (FILE *, rtx);
+@@ -6665,6 +6664,32 @@ legitimize_tls_address (rtx x, rtx reg)
+ rtx
+ arm_legitimize_address (rtx x, rtx orig_x, enum machine_mode mode)
+ {
++ if (arm_tls_referenced_p (x))
++ {
++ rtx addend = NULL;
++
++ if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS)
++ {
++ addend = XEXP (XEXP (x, 0), 1);
++ x = XEXP (XEXP (x, 0), 0);
++ }
++
++ if (GET_CODE (x) != SYMBOL_REF)
++ return x;
++
++ gcc_assert (SYMBOL_REF_TLS_MODEL (x) != 0);
++
++ x = legitimize_tls_address (x, NULL_RTX);
++
++ if (addend)
++ {
++ x = gen_rtx_PLUS (SImode, x, addend);
++ orig_x = x;
++ }
++ else
++ return x;
++ }
++
+ if (!TARGET_ARM)
+ {
+ /* TODO: legitimize_address for Thumb2. */
+@@ -6673,9 +6698,6 @@ arm_legitimize_address (rtx x, rtx orig_
+ return thumb_legitimize_address (x, orig_x, mode);
+ }
+
+- if (arm_tls_symbol_p (x))
+- return legitimize_tls_address (x, NULL_RTX);
+-
+ if (GET_CODE (x) == PLUS)
+ {
+ rtx xop0 = XEXP (x, 0);
+@@ -6787,9 +6809,6 @@ arm_legitimize_address (rtx x, rtx orig_
+ rtx
+ thumb_legitimize_address (rtx x, rtx orig_x, enum machine_mode mode)
+ {
+- if (arm_tls_symbol_p (x))
+- return legitimize_tls_address (x, NULL_RTX);
+-
+ if (GET_CODE (x) == PLUS
+ && CONST_INT_P (XEXP (x, 1))
+ && (INTVAL (XEXP (x, 1)) >= 32 * GET_MODE_SIZE (mode)
+@@ -7080,20 +7099,6 @@ thumb_legitimize_reload_address (rtx *x_
+
+ /* Test for various thread-local symbols. */
+
+-/* Return TRUE if X is a thread-local symbol. */
+-
+-static bool
+-arm_tls_symbol_p (rtx x)
+-{
+- if (! TARGET_HAVE_TLS)
+- return false;
+-
+- if (GET_CODE (x) != SYMBOL_REF)
+- return false;
+-
+- return SYMBOL_REF_TLS_MODEL (x) != 0;
+-}
+-
+ /* Helper for arm_tls_referenced_p. */
+
+ static int
diff --git a/toolchain/gcc/patches/5.2.0/001-revert_register_mode_search.patch b/toolchain/gcc/patches/5.2.0/001-revert_register_mode_search.patch
new file mode 100644
index 0000000..06373eb
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/001-revert_register_mode_search.patch
@@ -0,0 +1,65 @@
+Revert of:
+
+commit 275035b56823b26d5fb7e90fad945b998648edf2
+Author: bergner <bergner@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Thu Sep 5 14:09:07 2013 +0000
+
+ PR target/58139
+ * reginfo.c (choose_hard_reg_mode): Scan through all mode classes
+ looking for widest mode.
+
+
+ git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202286 138bc75d-0d04-0410-961f-82ee72b054a4
+
+
+--- a/gcc/reginfo.c
++++ b/gcc/reginfo.c
+@@ -665,35 +665,40 @@ choose_hard_reg_mode (unsigned int regno
+ mode = GET_MODE_WIDER_MODE (mode))
+ if ((unsigned) hard_regno_nregs[regno][mode] == nregs
+ && HARD_REGNO_MODE_OK (regno, mode)
+- && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
+- && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
++ && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
+ found_mode = mode;
+
++ if (found_mode != VOIDmode)
++ return found_mode;
++
+ for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
+ mode != VOIDmode;
+ mode = GET_MODE_WIDER_MODE (mode))
+ if ((unsigned) hard_regno_nregs[regno][mode] == nregs
+ && HARD_REGNO_MODE_OK (regno, mode)
+- && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
+- && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
++ && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
+ found_mode = mode;
+
++ if (found_mode != VOIDmode)
++ return found_mode;
++
+ for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_FLOAT);
+ mode != VOIDmode;
+ mode = GET_MODE_WIDER_MODE (mode))
+ if ((unsigned) hard_regno_nregs[regno][mode] == nregs
+ && HARD_REGNO_MODE_OK (regno, mode)
+- && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
+- && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
++ && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
+ found_mode = mode;
+
++ if (found_mode != VOIDmode)
++ return found_mode;
++
+ for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_INT);
+ mode != VOIDmode;
+ mode = GET_MODE_WIDER_MODE (mode))
+ if ((unsigned) hard_regno_nregs[regno][mode] == nregs
+ && HARD_REGNO_MODE_OK (regno, mode)
+- && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode))
+- && GET_MODE_SIZE (mode) > GET_MODE_SIZE (found_mode))
++ && (! call_saved || ! HARD_REGNO_CALL_PART_CLOBBERED (regno, mode)))
+ found_mode = mode;
+
+ if (found_mode != VOIDmode)
diff --git a/toolchain/gcc/patches/5.2.0/002-case_insensitive.patch b/toolchain/gcc/patches/5.2.0/002-case_insensitive.patch
new file mode 100644
index 0000000..b3d2dbe
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/002-case_insensitive.patch
@@ -0,0 +1,14 @@
+--- a/include/filenames.h
++++ b/include/filenames.h
+@@ -43,11 +43,6 @@ extern "C" {
+ # define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c)
+ # define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f)
+ #else /* not DOSish */
+-# if defined(__APPLE__)
+-# ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
+-# define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
+-# endif
+-# endif /* __APPLE__ */
+ # define HAS_DRIVE_SPEC(f) (0)
+ # define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c)
+ # define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f)
diff --git a/toolchain/gcc/patches/5.2.0/010-documentation.patch b/toolchain/gcc/patches/5.2.0/010-documentation.patch
new file mode 100644
index 0000000..07064a9
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/010-documentation.patch
@@ -0,0 +1,23 @@
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -2941,18 +2941,10 @@ doc/gcc.info: $(TEXI_GCC_FILES)
+ doc/gccint.info: $(TEXI_GCCINT_FILES)
+ doc/cppinternals.info: $(TEXI_CPPINT_FILES)
+
+-doc/%.info: %.texi
+- if [ x$(BUILD_INFO) = xinfo ]; then \
+- $(MAKEINFO) $(MAKEINFOFLAGS) -I . -I $(gcc_docdir) \
+- -I $(gcc_docdir)/include -o $@ $<; \
+- fi
++doc/%.info:
+
+ # Duplicate entry to handle renaming of gccinstall.info
+-doc/gccinstall.info: $(TEXI_GCCINSTALL_FILES)
+- if [ x$(BUILD_INFO) = xinfo ]; then \
+- $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
+- -I $(gcc_docdir)/include -o $@ $<; \
+- fi
++doc/gccinstall.info:
+
+ doc/cpp.dvi: $(TEXI_CPP_FILES)
+ doc/gcc.dvi: $(TEXI_GCC_FILES)
diff --git a/toolchain/gcc/patches/5.2.0/020-no-plt-backport.patch b/toolchain/gcc/patches/5.2.0/020-no-plt-backport.patch
new file mode 100644
index 0000000..b9702c9
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/020-no-plt-backport.patch
@@ -0,0 +1,28 @@
+--- a/gcc/calls.c
++++ b/gcc/calls.c
+@@ -225,6 +225,12 @@ prepare_call_address (tree fndecl_or_typ
+ && targetm.small_register_classes_for_mode_p (FUNCTION_MODE))
+ ? force_not_mem (memory_address (FUNCTION_MODE, funexp))
+ : memory_address (FUNCTION_MODE, funexp));
++ else if (flag_pic && !flag_plt && fndecl_or_type
++ && TREE_CODE (fndecl_or_type) == FUNCTION_DECL
++ && !targetm.binds_local_p (fndecl_or_type))
++ {
++ funexp = force_reg (Pmode, funexp);
++ }
+ else if (! sibcallp)
+ {
+ #ifndef NO_FUNCTION_CSE
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -1779,6 +1779,10 @@ fpie
+ Common Report Var(flag_pie,1) Negative(fPIC)
+ Generate position-independent code for executables if possible (small mode)
+
++fplt
++Common Report Var(flag_plt) Init(1)
++Use PLT for PIC calls (-fno-plt: load the address from GOT at call site)
++
+ fplugin=
+ Common Joined RejectNegative Var(common_deferred_options) Defer
+ Specify a plugin to load
diff --git a/toolchain/gcc/patches/5.2.0/030-fix-arm-codegen-PR-65932.patch b/toolchain/gcc/patches/5.2.0/030-fix-arm-codegen-PR-65932.patch
new file mode 100644
index 0000000..7f0b43c
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/030-fix-arm-codegen-PR-65932.patch
@@ -0,0 +1,21 @@
+Fix from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65932
+
+--- a/gcc/config/arm/arm.h
++++ b/gcc/config/arm/arm.h
+@@ -628,16 +628,10 @@ extern int arm_arch_crc;
+ type, but kept valid in the wider mode. The signedness of the
+ extension may differ from that of the type. */
+
+-/* It is far faster to zero extend chars than to sign extend them */
+-
+ #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
+ if (GET_MODE_CLASS (MODE) == MODE_INT \
+ && GET_MODE_SIZE (MODE) < 4) \
+ { \
+- if (MODE == QImode) \
+- UNSIGNEDP = 1; \
+- else if (MODE == HImode) \
+- UNSIGNEDP = 1; \
+ (MODE) = SImode; \
+ }
+
diff --git a/toolchain/gcc/patches/5.2.0/100-uclibc-conf.patch b/toolchain/gcc/patches/5.2.0/100-uclibc-conf.patch
new file mode 100644
index 0000000..ff9ad94
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/100-uclibc-conf.patch
@@ -0,0 +1,33 @@
+--- a/contrib/regression/objs-gcc.sh
++++ b/contrib/regression/objs-gcc.sh
+@@ -106,6 +106,10 @@ if [ $H_REAL_TARGET = $H_REAL_HOST -a $H
+ then
+ make all-gdb all-dejagnu all-ld || exit 1
+ make install-gdb install-dejagnu install-ld || exit 1
++elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
++ then
++ make all-gdb all-dejagnu all-ld || exit 1
++ make install-gdb install-dejagnu install-ld || exit 1
+ elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
+ make bootstrap || exit 1
+ make install || exit 1
+--- a/libjava/classpath/ltconfig
++++ b/libjava/classpath/ltconfig
+@@ -603,7 +603,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-
+
+ # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+ case $host_os in
+-linux-gnu*) ;;
++linux-gnu*|linux-uclibc*) ;;
+ linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+ esac
+
+@@ -1247,7 +1247,7 @@ linux-gnuoldld* | linux-gnuaout* | linux
+ ;;
+
+ # This must be Linux ELF.
+-linux-gnu*)
++linux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
diff --git a/toolchain/gcc/patches/5.2.0/200-musl_config.patch b/toolchain/gcc/patches/5.2.0/200-musl_config.patch
new file mode 100644
index 0000000..a2b41b3
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/200-musl_config.patch
@@ -0,0 +1,309 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Fri, 8 May 2015 08:25:47 +0000 (+0000)
+Subject: [PATCH 2/13] musl libc config
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=a9173ceabaf29c16f8ef226fbf98af373a4b2ceb
+
+[PATCH 2/13] musl libc config
+
+2015-05-08 Gregor Richards <gregor.richards@uwaterloo.ca>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config.gcc (LIBC_MUSL): New tm_defines macro.
+ * config/linux.h (OPTION_MUSL): Define.
+ (MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,)
+ (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,)
+ (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
+ (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
+ (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
+ * config/linux.opt (mmusl): New option.
+ * doc/invoke.texi (GNU/Linux Options): Document -mmusl.
+ * configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
+ (gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
+ * configure: Regenerate.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222904 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -575,7 +575,7 @@ case ${target} in
+ esac
+
+ # Common C libraries.
+-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
++tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
+
+ # 32-bit x86 processors supported by --with-arch=. Each processor
+ # MUST be separated by exactly one space.
+@@ -720,6 +720,9 @@ case ${target} in
+ *-*-*uclibc*)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
+ ;;
++ *-*-*musl*)
++ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
++ ;;
+ *)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
+ ;;
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -32,10 +32,12 @@ see the files COPYING3 and COPYING.RUNTI
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
+@@ -50,21 +52,25 @@ see the files COPYING3 and COPYING.RUNTI
+ } while (0)
+
+ /* Determine which dynamic linker to use depending on whether GLIBC or
+- uClibc or Bionic is the default C library and whether
+- -muclibc or -mglibc or -mbionic has been passed to change the default. */
++ uClibc or Bionic or musl is the default C library and whether
++ -muclibc or -mglibc or -mbionic or -mmusl has been passed to change
++ the default. */
+
+-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
+- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
++#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
++ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
+
+ #if DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
+ #elif DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
+ #elif DEFAULT_LIBC == LIBC_BIONIC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif /* DEFAULT_LIBC */
+@@ -81,24 +87,100 @@ see the files COPYING3 and COPYING.RUNTI
+ #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
+ #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
+ #define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32"
++/* Should be redefined for each target that supports musl. */
++#define MUSL_DYNAMIC_LINKER "/dev/null"
++#define MUSL_DYNAMIC_LINKER32 "/dev/null"
++#define MUSL_DYNAMIC_LINKER64 "/dev/null"
++#define MUSL_DYNAMIC_LINKERX32 "/dev/null"
+
+ #define GNU_USER_DYNAMIC_LINKER \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
+- BIONIC_DYNAMIC_LINKER)
++ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+ #define GNU_USER_DYNAMIC_LINKER32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
+- BIONIC_DYNAMIC_LINKER32)
++ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define GNU_USER_DYNAMIC_LINKER64 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
+- BIONIC_DYNAMIC_LINKER64)
++ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+ #define GNU_USER_DYNAMIC_LINKERX32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
+- BIONIC_DYNAMIC_LINKERX32)
++ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
+
+ /* Whether we have Bionic libc runtime */
+ #undef TARGET_HAS_BIONIC
+ #define TARGET_HAS_BIONIC (OPTION_BIONIC)
+
++/* musl avoids problematic includes by rearranging the include directories.
++ * Unfortunately, this is mostly duplicated from cppdefault.c */
++#if DEFAULT_LIBC == LIBC_MUSL
++#define INCLUDE_DEFAULTS_MUSL_GPP \
++ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
++ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
++ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
++
++#ifdef LOCAL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_LOCAL \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_LOCAL
++#endif
++
++#ifdef PREFIX_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_PREFIX \
++ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_PREFIX
++#endif
++
++#ifdef CROSS_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_CROSS \
++ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#ifdef TOOL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_TOOL \
++ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_TOOL
++#endif
++
++#ifdef NATIVE_SYSTEM_HEADER_DIR
++#define INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_NATIVE
++#endif
++
++#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
++# undef INCLUDE_DEFAULTS_MUSL_LOCAL
++# define INCLUDE_DEFAULTS_MUSL_LOCAL
++# undef INCLUDE_DEFAULTS_MUSL_NATIVE
++# define INCLUDE_DEFAULTS_MUSL_NATIVE
++#else
++# undef INCLUDE_DEFAULTS_MUSL_CROSS
++# define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#undef INCLUDE_DEFAULTS
++#define INCLUDE_DEFAULTS \
++ { \
++ INCLUDE_DEFAULTS_MUSL_GPP \
++ INCLUDE_DEFAULTS_MUSL_PREFIX \
++ INCLUDE_DEFAULTS_MUSL_CROSS \
++ INCLUDE_DEFAULTS_MUSL_TOOL \
++ INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
++ { 0, 0, 0, 0, 0, 0 } \
++ }
++#endif
++
+ #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
+ /* This is a *uclinux* target. We don't define below macros to normal linux
+ versions, because doing so would require *uclinux* targets to include
+--- a/gcc/config/linux.opt
++++ b/gcc/config/linux.opt
+@@ -28,5 +28,9 @@ Target Report RejectNegative Var(linux_l
+ Use GNU C library
+
+ muclibc
+-Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
++Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mmusl)
+ Use uClibc C library
++
++mmusl
++Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mbionic)
++Use musl C library
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -27742,6 +27742,9 @@ if test "${gcc_cv_libc_provides_ssp+set}
+ else
+ gcc_cv_libc_provides_ssp=no
+ case "$target" in
++ *-*-musl*)
++ # All versions of musl provide stack protector
++ gcc_cv_libc_provides_ssp=yes;;
+ *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
+ # glibc 2.4 and later provides __stack_chk_fail and
+ # either __stack_chk_guard, or TLS access to stack guard canary.
+@@ -27774,6 +27777,7 @@ fi
+ # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
+ # simply assert that glibc does provide this, which is true for all
+ # realistically usable GNU/Hurd configurations.
++ # All supported versions of musl provide it as well
+ gcc_cv_libc_provides_ssp=yes;;
+ *-*-darwin* | *-*-freebsd*)
+ ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
+@@ -27870,6 +27874,9 @@ case "$target" in
+ gcc_cv_target_dl_iterate_phdr=no
+ fi
+ ;;
++ *-linux-musl*)
++ gcc_cv_target_dl_iterate_phdr=yes
++ ;;
+ esac
+
+ if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -5229,6 +5229,9 @@ AC_CACHE_CHECK(__stack_chk_fail in targe
+ gcc_cv_libc_provides_ssp,
+ [gcc_cv_libc_provides_ssp=no
+ case "$target" in
++ *-*-musl*)
++ # All versions of musl provide stack protector
++ gcc_cv_libc_provides_ssp=yes;;
+ *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
+ # glibc 2.4 and later provides __stack_chk_fail and
+ # either __stack_chk_guard, or TLS access to stack guard canary.
+@@ -5255,6 +5258,7 @@ AC_CACHE_CHECK(__stack_chk_fail in targe
+ # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
+ # simply assert that glibc does provide this, which is true for all
+ # realistically usable GNU/Hurd configurations.
++ # All supported versions of musl provide it as well
+ gcc_cv_libc_provides_ssp=yes;;
+ *-*-darwin* | *-*-freebsd*)
+ AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
+@@ -5328,6 +5332,9 @@ case "$target" in
+ gcc_cv_target_dl_iterate_phdr=no
+ fi
+ ;;
++ *-linux-musl*)
++ gcc_cv_target_dl_iterate_phdr=yes
++ ;;
+ esac
+ GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
+ if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -667,7 +667,7 @@ Objective-C and Objective-C++ Dialects}.
+ -mcpu=@var{cpu}}
+
+ @emph{GNU/Linux Options}
+-@gccoptlist{-mglibc -muclibc -mbionic -mandroid @gol
++@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
+ -tno-android-cc -tno-android-ld}
+
+ @emph{H8/300 Options}
+@@ -15324,13 +15324,19 @@ These @samp{-m} options are defined for
+ @item -mglibc
+ @opindex mglibc
+ Use the GNU C library. This is the default except
+-on @samp{*-*-linux-*uclibc*} and @samp{*-*-linux-*android*} targets.
++on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
++@samp{*-*-linux-*android*} targets.
+
+ @item -muclibc
+ @opindex muclibc
+ Use uClibc C library. This is the default on
+ @samp{*-*-linux-*uclibc*} targets.
+
++@item -mmusl
++@opindex mmusl
++Use the musl C library. This is the default on
++@samp{*-*-linux-*musl*} targets.
++
+ @item -mbionic
+ @opindex mbionic
+ Use Bionic C library. This is the default on
diff --git a/toolchain/gcc/patches/5.2.0/201-musl_arm.patch b/toolchain/gcc/patches/5.2.0/201-musl_arm.patch
new file mode 100644
index 0000000..27a26af
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/201-musl_arm.patch
@@ -0,0 +1,43 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 27 May 2015 13:17:11 +0000 (+0000)
+Subject: [PATCH 4/13] arm musl support
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=de799bd087ab9a179768fea75bd195a31d3432a4
+
+[PATCH 4/13] arm musl support
+
+On behalf of szabolcs.nagy@arm.com
+
+2015-05-27 Gregor Richards <gregor.richards@uwaterloo.ca>
+
+ * config/arm/linux-eabi.h (MUSL_DYNAMIC_LINKER): Define.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223749 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -77,6 +77,23 @@
+ %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
+ %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
+
++/* For ARM musl currently supports four dynamic linkers:
++ - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI
++ - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI
++ - ld-musl-armeb.so.1 - for the EABI-derived soft-float ABI, EB
++ - ld-musl-armebhf.so.1 - for the EABI-derived hard-float ABI, EB
++ musl does not support the legacy OABI mode.
++ All the dynamic linkers live in /lib.
++ We default to soft-float, EL. */
++#undef MUSL_DYNAMIC_LINKER
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:eb}"
++#else
++#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
++#endif
++#define MUSL_DYNAMIC_LINKER \
++ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
diff --git a/toolchain/gcc/patches/5.2.0/202-musl_mips.patch b/toolchain/gcc/patches/5.2.0/202-musl_mips.patch
new file mode 100644
index 0000000..816dd8d
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/202-musl_mips.patch
@@ -0,0 +1,35 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Fri, 8 May 2015 15:16:50 +0000 (+0000)
+Subject: [PATCH 6/13] mips musl support
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=2550b6a866c887472b587bef87d433c51cf1ebc8
+
+[PATCH 6/13] mips musl support
+
+2015-05-08 Gregor Richards <gregor.richards@uwaterloo.ca>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config/mips/linux.h (MUSL_DYNAMIC_LINKER32): Define.
+ (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERN32): Define.
+ (GNU_USER_DYNAMIC_LINKERN32): Update.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222915 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/gcc/config/mips/linux.h
++++ b/gcc/config/mips/linux.h
+@@ -37,7 +37,13 @@ along with GCC; see the file COPYING3.
+ #define UCLIBC_DYNAMIC_LINKERN32 \
+ "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}"
+
++#undef MUSL_DYNAMIC_LINKER32
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips%{EL:el}%{msoft-float:-sf}.so.1"
++#undef MUSL_DYNAMIC_LINKER64
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips64%{EL:el}%{msoft-float:-sf}.so.1"
++#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mipsn32%{EL:el}%{msoft-float:-sf}.so.1"
++
+ #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
+ #define GNU_USER_DYNAMIC_LINKERN32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
+- BIONIC_DYNAMIC_LINKERN32)
++ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
diff --git a/toolchain/gcc/patches/5.2.0/203-musl_powerpc.patch b/toolchain/gcc/patches/5.2.0/203-musl_powerpc.patch
new file mode 100644
index 0000000..2783b27
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/203-musl_powerpc.patch
@@ -0,0 +1,209 @@
+
+gcc/Changelog:
+
+2015-04-24 Gregor Richards <gregor.richards@uwaterloo.ca>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config.gcc (secure_plt): Add *-linux*-musl*.
+ * config/rs6000/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
+ (MUSL_DYNAMIC_LINKER64): Define.
+ (GNU_USER_DYNAMIC_LINKER32): Update.
+ (GNU_USER_DYNAMIC_LINKER64): Update.
+ (CHOOSE_DYNAMIC_LINKER): Update.
+
+ * config/rs6000/secureplt.h (LINK_SECURE_PLT_DEFAULT_SPEC): Define.
+ * config/rs6000/sysv4.h (GNU_USER_DYNAMIC_LINKER): Update.
+ (MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER_E,)
+ (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
+ (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
+ (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
+ (LINK_SECURE_PLT_DEFAULT_SPEC): Define.
+ (CHOOSE_DYNAMIC_LINKER, LINK_TARGET_SPEC, LINK_OS_LINUX_SPEC): Update.
+
+ * config/rs6000/sysv4le.h (MUSL_DYNAMIC_LINKER_E): Define.
+
+--- a/gcc/config/rs6000/linux64.h
++++ b/gcc/config/rs6000/linux64.h
+@@ -365,17 +365,21 @@ extern int dot_symbols;
+ #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" MUSL_DYNAMIC_LINKER_E ".so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E ".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 "}}"
+ #elif DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif
+ #define GNU_USER_DYNAMIC_LINKER32 \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define GNU_USER_DYNAMIC_LINKER64 \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+
+ #undef DEFAULT_ASM_ENDIAN
+ #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
+--- a/gcc/config/rs6000/secureplt.h
++++ b/gcc/config/rs6000/secureplt.h
+@@ -18,3 +18,4 @@ along with GCC; see the file COPYING3.
+ <http://www.gnu.org/licenses/>. */
+
+ #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
++#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
+--- a/gcc/config/rs6000/sysv4.h
++++ b/gcc/config/rs6000/sysv4.h
+@@ -537,6 +537,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+ #ifndef CC1_SECURE_PLT_DEFAULT_SPEC
+ #define CC1_SECURE_PLT_DEFAULT_SPEC ""
+ #endif
++#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
++#define LINK_SECURE_PLT_DEFAULT_SPEC ""
++#endif
+
+ /* Pass -G xxx to the compiler. */
+ #undef CC1_SPEC
+@@ -586,7 +589,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+
+ /* Override the default target of the linker. */
+ #define LINK_TARGET_SPEC \
+- ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
++ ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
++ "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
+
+ /* Any specific OS flags. */
+ #define LINK_OS_SPEC "\
+@@ -762,17 +766,22 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+
+ #define LINK_START_LINUX_SPEC ""
+
++#define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","")
++
+ #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" MUSL_DYNAMIC_LINKER_E ".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 "}}"
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
+ #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
++#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif
+ #define GNU_USER_DYNAMIC_LINKER \
+- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
++ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+
+ #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
+ %{rdynamic:-export-dynamic} \
+@@ -895,6 +904,7 @@ ncrtn.o%s"
+ { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
+ { "link_os_default", LINK_OS_DEFAULT_SPEC }, \
+ { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
++ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
+ { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
+ { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
+ { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
+@@ -949,3 +959,72 @@ ncrtn.o%s"
+ /* This target uses the sysv4.opt file. */
+ #define TARGET_USES_SYSV4_OPT 1
+
++/* Include order changes for musl, same as in generic linux.h. */
++#if DEFAULT_LIBC == LIBC_MUSL
++#define INCLUDE_DEFAULTS_MUSL_GPP \
++ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
++ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
++ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
++
++#ifdef LOCAL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_LOCAL \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_LOCAL
++#endif
++
++#ifdef PREFIX_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_PREFIX \
++ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_PREFIX
++#endif
++
++#ifdef CROSS_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_CROSS \
++ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#ifdef TOOL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_TOOL \
++ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_TOOL
++#endif
++
++#ifdef NATIVE_SYSTEM_HEADER_DIR
++#define INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_NATIVE
++#endif
++
++#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
++# undef INCLUDE_DEFAULTS_MUSL_LOCAL
++# define INCLUDE_DEFAULTS_MUSL_LOCAL
++# undef INCLUDE_DEFAULTS_MUSL_NATIVE
++# define INCLUDE_DEFAULTS_MUSL_NATIVE
++#else
++# undef INCLUDE_DEFAULTS_MUSL_CROSS
++# define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#undef INCLUDE_DEFAULTS
++#define INCLUDE_DEFAULTS \
++ { \
++ INCLUDE_DEFAULTS_MUSL_GPP \
++ INCLUDE_DEFAULTS_MUSL_PREFIX \
++ INCLUDE_DEFAULTS_MUSL_CROSS \
++ INCLUDE_DEFAULTS_MUSL_TOOL \
++ INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
++ { 0, 0, 0, 0, 0, 0 } \
++ }
++#endif
+--- a/gcc/config/rs6000/sysv4le.h
++++ b/gcc/config/rs6000/sysv4le.h
+@@ -35,3 +35,5 @@
+ /* Little-endian PowerPC64 Linux uses the ELF v2 ABI by default. */
+ #define LINUX64_DEFAULT_ABI_ELFv2
+
++#undef MUSL_DYNAMIC_LINKER_E
++#define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","le")
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -2410,6 +2410,10 @@ powerpc*-*-linux*)
+ powerpc*-*-linux*paired*)
+ tm_file="${tm_file} rs6000/750cl.h" ;;
+ esac
++ case ${target} in
++ *-linux*-musl*)
++ enable_secureplt=yes ;;
++ esac
+ if test x${enable_secureplt} = xyes; then
+ tm_file="rs6000/secureplt.h ${tm_file}"
+ fi
diff --git a/toolchain/gcc/patches/5.2.0/204-musl_sh.patch b/toolchain/gcc/patches/5.2.0/204-musl_sh.patch
new file mode 100644
index 0000000..8c3753d
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/204-musl_sh.patch
@@ -0,0 +1,39 @@
+gcc/Changelog:
+
+2015-04-27 Gregor Richards <gregor.richards@uwaterloo.ca>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config/sh/linux.h (MUSL_DYNAMIC_LINKER): Define.
+ (MUSL_DYNAMIC_LINKER_E, MUSL_DYNAMIC_LINKER_FP): Define.
+
+--- a/gcc/config/sh/linux.h
++++ b/gcc/config/sh/linux.h
+@@ -43,6 +43,28 @@ along with GCC; see the file COPYING3.
+
+ #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
+
++#if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN
++#define MUSL_DYNAMIC_LINKER_E "%{mb:eb}"
++#else
++#define MUSL_DYNAMIC_LINKER_E "%{!ml:eb}"
++#endif
++
++#if TARGET_CPU_DEFAULT & ( MASK_HARD_SH2A_DOUBLE | MASK_SH4 )
++/* "-nofpu" if any nofpu option is specified */
++#define MUSL_DYNAMIC_LINKER_FP \
++ "%{m1|m2|m2a-nofpu|m3|m4-nofpu|m4-100-nofpu|m4-200-nofpu|m4-300-nofpu|" \
++ "m4-340|m4-400|m4-500|m4al|m5-32media-nofpu|m5-64media-nofpu|" \
++ "m5-compact-nofpu:-nofpu}"
++#else
++/* "-nofpu" if none of the hard fpu options are specified */
++#define MUSL_DYNAMIC_LINKER_FP \
++ "%{m2a|m4|m4-100|m4-200|m4-300|m4a|m5-32media|m5-64media|m5-compact:;:-nofpu}"
++#endif
++
++#undef MUSL_DYNAMIC_LINKER
++#define MUSL_DYNAMIC_LINKER \
++ "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP ".so.1"
++
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+ #undef SUBTARGET_LINK_EMUL_SUFFIX
diff --git a/toolchain/gcc/patches/5.2.0/205-musl_x86.patch b/toolchain/gcc/patches/5.2.0/205-musl_x86.patch
new file mode 100644
index 0000000..8772328
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/205-musl_x86.patch
@@ -0,0 +1,41 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Fri, 15 May 2015 13:20:01 +0000 (+0000)
+Subject: [PATCH 9/13] x86 musl support
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=5551c8d927c17f60837f15f8dfe46f945ba3fa9c
+
+[PATCH 9/13] x86 musl support
+
+On behalf of Szabolcs Nagy.
+
+2015-05-15 Gregor Richards <gregor.richards@uwaterloo.ca>
+
+ * config/i386/linux.h (MUSL_DYNAMIC_LINKER): Define.
+ * config/i386/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
+ (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32): Define.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223218 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/gcc/config/i386/linux.h
++++ b/gcc/config/i386/linux.h
+@@ -21,3 +21,6 @@ along with GCC; see the file COPYING3.
+
+ #define GNU_USER_LINK_EMULATION "elf_i386"
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++
++#undef MUSL_DYNAMIC_LINKER
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
+--- a/gcc/config/i386/linux64.h
++++ b/gcc/config/i386/linux64.h
+@@ -30,3 +30,10 @@ see the files COPYING3 and COPYING.RUNTI
+ #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
+ #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
+ #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
++
++#undef MUSL_DYNAMIC_LINKER32
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
++#undef MUSL_DYNAMIC_LINKER64
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
++#undef MUSL_DYNAMIC_LINKERX32
++#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
diff --git a/toolchain/gcc/patches/5.2.0/206-musl_aarch64.patch b/toolchain/gcc/patches/5.2.0/206-musl_aarch64.patch
new file mode 100644
index 0000000..6925a02
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/206-musl_aarch64.patch
@@ -0,0 +1,31 @@
+From: jgreenhalgh <jgreenhalgh@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 27 May 2015 16:46:39 +0000 (+0000)
+Subject: [PATCH 3/13] aarch64 musl support
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=b3ff21cf0531be91bc3fb8200296a7633090ec78
+
+[PATCH 3/13] aarch64 musl support
+
+gcc/Changelog:
+
+2015-05-27 Gregor Richards <gregor.richards@uwaterloo.ca>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config/aarch64/aarch64-linux.h (MUSL_DYNAMIC_LINKER): Define.
+
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223766 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/gcc/config/aarch64/aarch64-linux.h
++++ b/gcc/config/aarch64/aarch64-linux.h
+@@ -23,6 +23,9 @@
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
+
++#undef MUSL_DYNAMIC_LINKER
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
++
+ #undef ASAN_CC1_SPEC
+ #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
+
diff --git a/toolchain/gcc/patches/5.2.0/207-musl_fixincludes.patch b/toolchain/gcc/patches/5.2.0/207-musl_fixincludes.patch
new file mode 100644
index 0000000..0ff33d3
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/207-musl_fixincludes.patch
@@ -0,0 +1,30 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 22 Apr 2015 14:18:16 +0000 (+0000)
+Subject: fixincludes update for musl support
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=2dc727de2e87c2756a514cbb43cea23c99deaa3d
+
+fixincludes update for musl support
+
+On behalf of Szabolcs.Nagy@arm.com
+
+2015-04-22 Gregor Richards <gregor.richards@uwaterloo.ca>
+
+ * mkfixinc.sh: Add *-musl* with no fixes.
+
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222327 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/fixincludes/mkfixinc.sh
++++ b/fixincludes/mkfixinc.sh
+@@ -19,7 +19,8 @@ case $machine in
+ powerpc-*-eabi* | \
+ powerpc-*-rtems* | \
+ powerpcle-*-eabisim* | \
+- powerpcle-*-eabi* )
++ powerpcle-*-eabi* | \
++ *-musl* )
+ # IF there is no include fixing,
+ # THEN create a no-op fixer and exit
+ (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}
diff --git a/toolchain/gcc/patches/5.2.0/209-musl_libstdc++.patch b/toolchain/gcc/patches/5.2.0/209-musl_libstdc++.patch
new file mode 100644
index 0000000..861bc76
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/209-musl_libstdc++.patch
@@ -0,0 +1,72 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 22 Apr 2015 14:24:11 +0000 (+0000)
+Subject: libstdc++, libgfortran gthr workaround for musl
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=1e5f711c11cb80ce609db9e9c1d8b2da0f7b5b61
+
+libstdc++, libgfortran gthr workaround for musl
+
+On behalf of szabolcs.nagy@arm.com
+
+[libstdc++-v3/]
+2015-04-22 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config/os/generic/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK): Define.
+ * configure.host (os_include_dir): Set to "os/generic" for linux-musl*.
+
+[libgfortran/]
+2015-04-22 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * acinclude.m4 (GTHREAD_USE_WEAK): Define as 0 for *-*-musl*.
+ * configure: Regenerate.
+
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222329 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/libgfortran/acinclude.m4
++++ b/libgfortran/acinclude.m4
+@@ -100,7 +100,7 @@ void foo (void);
+ [Define to 1 if the target supports #pragma weak])
+ fi
+ case "$host" in
+- *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* )
++ *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* )
+ AC_DEFINE(GTHREAD_USE_WEAK, 0,
+ [Define to 0 if the target shouldn't use #pragma weak])
+ ;;
+--- a/libgfortran/configure
++++ b/libgfortran/configure
+@@ -26447,7 +26447,7 @@ $as_echo "#define SUPPORTS_WEAK 1" >>con
+
+ fi
+ case "$host" in
+- *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* )
++ *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* )
+
+ $as_echo "#define GTHREAD_USE_WEAK 0" >>confdefs.h
+
+--- a/libstdc++-v3/config/os/generic/os_defines.h
++++ b/libstdc++-v3/config/os/generic/os_defines.h
+@@ -33,4 +33,9 @@
+ // System-specific #define, typedefs, corrections, etc, go here. This
+ // file will come before all others.
+
++// Disable the weak reference logic in gthr.h for os/generic because it
++// is broken on every platform unless there is implementation specific
++// workaround in gthr-posix.h and at link-time for static linking.
++#define _GLIBCXX_GTHREAD_USE_WEAK 0
++
+ #endif
+--- a/libstdc++-v3/configure.host
++++ b/libstdc++-v3/configure.host
+@@ -273,6 +273,9 @@ case "${host_os}" in
+ freebsd*)
+ os_include_dir="os/bsd/freebsd"
+ ;;
++ linux-musl*)
++ os_include_dir="os/generic"
++ ;;
+ gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
+ if [ "$uclibc" = "yes" ]; then
+ os_include_dir="os/uclibc"
diff --git a/toolchain/gcc/patches/5.2.0/230-musl_libssp.patch b/toolchain/gcc/patches/5.2.0/230-musl_libssp.patch
new file mode 100644
index 0000000..30f42e9
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/230-musl_libssp.patch
@@ -0,0 +1,13 @@
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -727,7 +727,9 @@ proper position among the other output f
+ #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|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit:}"
+ #else
diff --git a/toolchain/gcc/patches/5.2.0/240-musl-libitm-fixes.patch b/toolchain/gcc/patches/5.2.0/240-musl-libitm-fixes.patch
new file mode 100644
index 0000000..533cb68
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/240-musl-libitm-fixes.patch
@@ -0,0 +1,61 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 22 Apr 2015 14:11:25 +0000 (+0000)
+Subject: libitm fixes for musl support
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=e53a4d49c3d03ab8eaddb073cf972c1c46d75338
+
+libitm fixes for musl support
+
+On behalf of Szabolcs.Nagy@arm.com
+
+2015-04-22 Gregor Richards <gregor.richards@uwaterloo.ca>
+
+ * config/arm/hwcap.cc: Use fcntl.h instead of sys/fcntl.h.
+ * config/linux/x86/tls.h: Only use __GLIBC_PREREQ if defined.
+
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222325 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/libitm/config/arm/hwcap.cc
++++ b/libitm/config/arm/hwcap.cc
+@@ -40,7 +40,7 @@ int GTM_hwcap HIDDEN = 0
+
+ #ifdef __linux__
+ #include <unistd.h>
+-#include <sys/fcntl.h>
++#include <fcntl.h>
+ #include <elf.h>
+
+ static void __attribute__((constructor))
+--- a/libitm/config/linux/x86/tls.h
++++ b/libitm/config/linux/x86/tls.h
+@@ -25,16 +25,19 @@
+ #ifndef LIBITM_X86_TLS_H
+ #define LIBITM_X86_TLS_H 1
+
+-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
++#if defined(__GLIBC_PREREQ)
++#if __GLIBC_PREREQ(2, 10)
+ /* Use slots in the TCB head rather than __thread lookups.
+ GLIBC has reserved words 10 through 13 for TM. */
+ #define HAVE_ARCH_GTM_THREAD 1
+ #define HAVE_ARCH_GTM_THREAD_DISP 1
+ #endif
++#endif
+
+ #include "config/generic/tls.h"
+
+-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
++#if defined(__GLIBC_PREREQ)
++#if __GLIBC_PREREQ(2, 10)
+ namespace GTM HIDDEN {
+
+ #ifdef __x86_64__
+@@ -101,5 +104,6 @@ static inline void set_abi_disp(struct a
+
+ } // namespace GTM
+ #endif /* >= GLIBC 2.10 */
++#endif
+
+ #endif // LIBITM_X86_TLS_H
diff --git a/toolchain/gcc/patches/5.2.0/250-add-musl.patch b/toolchain/gcc/patches/5.2.0/250-add-musl.patch
new file mode 100644
index 0000000..8cbedde
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/250-add-musl.patch
@@ -0,0 +1,120 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Fri, 8 May 2015 08:30:40 +0000 (+0000)
+Subject: [PATCH 0/13] Add musl support to GCC
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=f2d678afa5b8385d763b93772d73d6bf80a9739e
+
+[PATCH 0/13] Add musl support to GCC
+
+2015-05-08 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * config/glibc-stdint.h (OPTION_MUSL): Define.
+ (INT_FAST16_TYPE, INT_FAST32_TYPE, UINT_FAST16_TYPE, UINT_FAST32_TYPE):
+ Change the definition based on OPTION_MUSL for 64 bit targets.
+ * config/linux.h (OPTION_MUSL): Redefine.
+ * config/alpha/linux.h (OPTION_MUSL): Redefine.
+ * config/rs6000/linux.h (OPTION_MUSL): Redefine.
+ * config/rs6000/linux64.h (OPTION_MUSL): Redefine.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222905 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/gcc/config/alpha/linux.h
++++ b/gcc/config/alpha/linux.h
+@@ -61,10 +61,14 @@ along with GCC; see the file COPYING3.
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#undef OPTION_MUSL
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#undef OPTION_MUSL
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ /* Determine what functions are present at the runtime;
+--- a/gcc/config/glibc-stdint.h
++++ b/gcc/config/glibc-stdint.h
+@@ -22,6 +22,12 @@ a copy of the GCC Runtime Library Except
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++/* Systems using musl libc should use this header and make sure
++ OPTION_MUSL is defined correctly before using the TYPE macros. */
++#ifndef OPTION_MUSL
++#define OPTION_MUSL 0
++#endif
++
+ #define SIG_ATOMIC_TYPE "int"
+
+ #define INT8_TYPE "signed char"
+@@ -43,12 +49,12 @@ see the files COPYING3 and COPYING.RUNTI
+ #define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
+
+ #define INT_FAST8_TYPE "signed char"
+-#define INT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
+-#define INT_FAST32_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
++#define INT_FAST16_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long int" : "int")
++#define INT_FAST32_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long int" : "int")
+ #define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
+ #define UINT_FAST8_TYPE "unsigned char"
+-#define UINT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
+-#define UINT_FAST32_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
++#define UINT_FAST16_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long unsigned int" : "unsigned int")
++#define UINT_FAST32_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long unsigned int" : "unsigned int")
+ #define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
+
+ #define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -32,11 +32,13 @@ see the files COPYING3 and COPYING.RUNTI
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#undef OPTION_MUSL
+ #define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#undef OPTION_MUSL
+ #define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+--- a/gcc/config/rs6000/linux.h
++++ b/gcc/config/rs6000/linux.h
+@@ -30,10 +30,14 @@
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#undef OPTION_MUSL
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#undef OPTION_MUSL
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ /* Determine what functions are present at the runtime;
+--- a/gcc/config/rs6000/linux64.h
++++ b/gcc/config/rs6000/linux64.h
+@@ -299,10 +299,14 @@ extern int dot_symbols;
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#undef OPTION_MUSL
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#undef OPTION_MUSL
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ /* Determine what functions are present at the runtime;
diff --git a/toolchain/gcc/patches/5.2.0/260-musl-add-unwind-fix.patch b/toolchain/gcc/patches/5.2.0/260-musl-add-unwind-fix.patch
new file mode 100644
index 0000000..a3b83e2
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/260-musl-add-unwind-fix.patch
@@ -0,0 +1,34 @@
+From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 22 Apr 2015 14:20:01 +0000 (+0000)
+Subject: unwind fix for musl
+X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=a2e31d0681d8a47389b8a3552622fbd9827bcef4
+
+unwind fix for musl
+
+On behalf of szabolcs.nagy@arm.com
+
+2015-04-22 Gregor Richards <gregor.richards@uwaterloo.ca>
+ Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * unwind-dw2-fde-dip.c (USE_PT_GNU_EH_FRAME): Define it on
+ Linux if target provides dl_iterate_phdr.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222328 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/libgcc/unwind-dw2-fde-dip.c
++++ b/libgcc/unwind-dw2-fde-dip.c
+@@ -59,6 +59,12 @@
+
+ #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+ && defined(TARGET_DL_ITERATE_PHDR) \
++ && defined(__linux__)
++# define USE_PT_GNU_EH_FRAME
++#endif
++
++#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
++ && defined(TARGET_DL_ITERATE_PHDR) \
+ && (defined(__DragonFly__) || defined(__FreeBSD__))
+ # define ElfW __ElfN
+ # define USE_PT_GNU_EH_FRAME
diff --git a/toolchain/gcc/patches/5.2.0/270-musl-add-powerpc-softfloat-fix.patch b/toolchain/gcc/patches/5.2.0/270-musl-add-powerpc-softfloat-fix.patch
new file mode 100644
index 0000000..798936c
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/270-musl-add-powerpc-softfloat-fix.patch
@@ -0,0 +1,24 @@
+--- a/gcc/config/rs6000/linux64.h
++++ b/gcc/config/rs6000/linux64.h
+@@ -369,8 +369,8 @@ extern int dot_symbols;
+ #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" MUSL_DYNAMIC_LINKER_E ".so.1"
+-#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E ".so.1"
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+ #if DEFAULT_LIBC == LIBC_UCLIBC
+ #define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
+ #elif DEFAULT_LIBC == LIBC_GLIBC
+--- a/gcc/config/rs6000/sysv4.h
++++ b/gcc/config/rs6000/sysv4.h
+@@ -770,7 +770,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
+
+ #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" MUSL_DYNAMIC_LINKER_E ".so.1"
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+ #if DEFAULT_LIBC == LIBC_UCLIBC
+ #define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
+ #elif DEFAULT_LIBC == LIBC_MUSL
diff --git a/toolchain/gcc/patches/5.2.0/800-arm_v5te_no_ldrd_strd.patch b/toolchain/gcc/patches/5.2.0/800-arm_v5te_no_ldrd_strd.patch
new file mode 100644
index 0000000..0edeb13
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/800-arm_v5te_no_ldrd_strd.patch
@@ -0,0 +1,11 @@
+--- a/gcc/config/arm/arm.h
++++ b/gcc/config/arm/arm.h
+@@ -285,7 +285,7 @@ extern void (*arm_lang_output_object_att
+ /* Thumb-1 only. */
+ #define TARGET_THUMB1_ONLY (TARGET_THUMB1 && !arm_arch_notm)
+
+-#define TARGET_LDRD (arm_arch5e && ARM_DOUBLEWORD_ALIGN \
++#define TARGET_LDRD (arm_arch6 && ARM_DOUBLEWORD_ALIGN \
+ && !TARGET_THUMB1)
+
+ #define TARGET_CRC32 (arm_arch_crc)
diff --git a/toolchain/gcc/patches/5.2.0/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches/5.2.0/810-arm-softfloat-libgcc.patch
new file mode 100644
index 0000000..1d06f5b
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/810-arm-softfloat-libgcc.patch
@@ -0,0 +1,25 @@
+--- a/libgcc/config/arm/t-linux
++++ b/libgcc/config/arm/t-linux
+@@ -1,6 +1,10 @@
+ LIB1ASMSRC = arm/lib1funcs.S
+ LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \
+- _ctzsi2 _arm_addsubdf3 _arm_addsubsf3
++ _ctzsi2 _arm_addsubdf3 _arm_addsubsf3 \
++ _arm_negdf2 _arm_muldivdf3 _arm_cmpdf2 _arm_unorddf2 \
++ _arm_fixdfsi _arm_fixunsdfsi _arm_truncdfsf2 \
++ _arm_negsf2 _arm_muldivsf3 _arm_cmpsf2 _arm_unordsf2 \
++ _arm_fixsfsi _arm_fixunssfsi
+
+ # Just for these, we omit the frame pointer since it makes such a big
+ # difference.
+--- a/gcc/config/arm/linux-elf.h
++++ b/gcc/config/arm/linux-elf.h
+@@ -60,8 +60,6 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
+-
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+ #define LINUX_TARGET_LINK_SPEC "%{h*} \
diff --git a/toolchain/gcc/patches/5.2.0/820-libgcc_pic.patch b/toolchain/gcc/patches/5.2.0/820-libgcc_pic.patch
new file mode 100644
index 0000000..42bf0c8
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/820-libgcc_pic.patch
@@ -0,0 +1,36 @@
+--- a/libgcc/Makefile.in
++++ b/libgcc/Makefile.in
+@@ -887,11 +887,12 @@ $(libgcov-driver-objects): %$(objext): $
+
+ # Static libraries.
+ libgcc.a: $(libgcc-objects)
++libgcc_pic.a: $(libgcc-s-objects)
+ libgcov.a: $(libgcov-objects)
+ libunwind.a: $(libunwind-objects)
+ libgcc_eh.a: $(libgcc-eh-objects)
+
+-libgcc.a libgcov.a libunwind.a libgcc_eh.a:
++libgcc.a libgcov.a libunwind.a libgcc_eh.a libgcc_pic.a:
+ -rm -f $@
+
+ objects="$(objects)"; \
+@@ -913,7 +914,7 @@ libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_E
+ endif
+
+ ifeq ($(enable_shared),yes)
+-all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
++all: libgcc_eh.a libgcc_pic.a libgcc_s$(SHLIB_EXT)
+ ifneq ($(LIBUNWIND),)
+ all: libunwind$(SHLIB_EXT)
+ endif
+@@ -1108,6 +1109,10 @@ install-shared:
+ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a
+ $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a
+
++ $(INSTALL_DATA) libgcc_pic.a $(mapfile) $(DESTDIR)$(inst_libdir)/
++ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_pic.a
++ $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_pic.a
++
+ $(subst @multilib_dir@,$(MULTIDIR),$(subst \
+ @shlib_base_name@,libgcc_s,$(subst \
+ @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))
diff --git a/toolchain/gcc/patches/5.2.0/830-arm_unbreak_armv4t.patch b/toolchain/gcc/patches/5.2.0/830-arm_unbreak_armv4t.patch
new file mode 100644
index 0000000..37f8f2a
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/830-arm_unbreak_armv4t.patch
@@ -0,0 +1,13 @@
+http://sourceware.org/ml/crossgcc/2008-05/msg00009.html
+
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -45,7 +45,7 @@
+ The ARM10TDMI core is the default for armv5t, so set
+ SUBTARGET_CPU_DEFAULT to achieve this. */
+ #undef SUBTARGET_CPU_DEFAULT
+-#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm10tdmi
++#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm9tdmi
+
+ /* TARGET_BIG_ENDIAN_DEFAULT is set in
+ config.gcc for big endian configurations. */
diff --git a/toolchain/gcc/patches/5.2.0/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches/5.2.0/840-armv4_pass_fix-v4bx_to_ld.patch
new file mode 100644
index 0000000..cb1fb98
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/840-armv4_pass_fix-v4bx_to_ld.patch
@@ -0,0 +1,19 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -94,10 +94,15 @@
+ #define MUSL_DYNAMIC_LINKER \
+ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
+
++/* For armv4 we pass --fix-v4bx to linker to support EABI */
++#undef TARGET_FIX_V4BX_SPEC
++#define TARGET_FIX_V4BX_SPEC " %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*"\
++ "|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx}"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
+-#define LINK_SPEC EABI_LINK_SPEC \
++#define LINK_SPEC EABI_LINK_SPEC TARGET_FIX_V4BX_SPEC \
+ LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \
+ LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
+
diff --git a/toolchain/gcc/patches/5.2.0/850-use_shared_libgcc.patch b/toolchain/gcc/patches/5.2.0/850-use_shared_libgcc.patch
new file mode 100644
index 0000000..5818cf4
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/850-use_shared_libgcc.patch
@@ -0,0 +1,47 @@
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -131,10 +131,6 @@
+ #define ENDFILE_SPEC \
+ LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC)
+
+-/* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we
+- do not use -lfloat. */
+-#undef LIBGCC_SPEC
+-
+ /* Clear the instruction cache from `beg' to `end'. This is
+ implemented in lib1funcs.S, so ensure an error if this definition
+ is used. */
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -53,6 +53,10 @@ see the files COPYING3 and COPYING.RUNTI
+ builtin_assert ("system=posix"); \
+ } while (0)
+
++#ifndef LIBGCC_SPEC
++#define LIBGCC_SPEC "%{static|static-libgcc:-lgcc}%{!static:%{!static-libgcc:-lgcc_s}}"
++#endif
++
+ /* Determine which dynamic linker to use depending on whether GLIBC or
+ uClibc or Bionic or musl is the default C library and whether
+ -muclibc or -mglibc or -mbionic or -mmusl has been passed to change
+--- a/libgcc/mkmap-symver.awk
++++ b/libgcc/mkmap-symver.awk
+@@ -132,5 +132,5 @@ function output(lib) {
+ else if (inherit[lib])
+ printf("} %s;\n", inherit[lib]);
+ else
+- printf ("\n local:\n\t*;\n};\n");
++ printf ("\n\t*;\n};\n");
+ }
+--- a/gcc/config/rs6000/linux.h
++++ b/gcc/config/rs6000/linux.h
+@@ -60,6 +60,9 @@
+ #undef CPP_OS_DEFAULT_SPEC
+ #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
+
++#undef LIBGCC_SPEC
++#define LIBGCC_SPEC "%{!static:%{!static-libgcc:-lgcc_s}} -lgcc"
++
+ #undef LINK_SHLIB_SPEC
+ #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
+
diff --git a/toolchain/gcc/patches/5.2.0/851-libgcc_no_compat.patch b/toolchain/gcc/patches/5.2.0/851-libgcc_no_compat.patch
new file mode 100644
index 0000000..80c3476
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/851-libgcc_no_compat.patch
@@ -0,0 +1,12 @@
+--- a/libgcc/config/t-libunwind
++++ b/libgcc/config/t-libunwind
+@@ -2,8 +2,7 @@
+
+ HOST_LIBGCC2_CFLAGS += -DUSE_GAS_SYMVER
+
+-LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c \
+- $(srcdir)/unwind-compat.c $(srcdir)/unwind-dw2-fde-compat.c
++LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
+ LIB2ADDEHSTATIC = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
+
+ # Override the default value from t-slibgcc-elf-ver and mention -lunwind
diff --git a/toolchain/gcc/patches/5.2.0/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches/5.2.0/870-ppc_no_crtsavres.patch
new file mode 100644
index 0000000..b38b9d5
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/870-ppc_no_crtsavres.patch
@@ -0,0 +1,11 @@
+--- a/gcc/config/rs6000/rs6000.c
++++ b/gcc/config/rs6000/rs6000.c
+@@ -21453,7 +21453,7 @@ rs6000_savres_strategy (rs6000_stack_t *
+ /* Define cutoff for using out-of-line functions to save registers. */
+ if (DEFAULT_ABI == ABI_V4 || TARGET_ELF)
+ {
+- if (!optimize_size)
++ if (1)
+ {
+ strategy |= SAVE_INLINE_FPRS | REST_INLINE_FPRS;
+ strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS;
diff --git a/toolchain/gcc/patches/5.2.0/880-no_java_section.patch b/toolchain/gcc/patches/5.2.0/880-no_java_section.patch
new file mode 100644
index 0000000..def6c9f
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/880-no_java_section.patch
@@ -0,0 +1,11 @@
+--- a/gcc/defaults.h
++++ b/gcc/defaults.h
+@@ -380,7 +380,7 @@ see the files COPYING3 and COPYING.RUNTI
+ /* If we have named section and we support weak symbols, then use the
+ .jcr section for recording java classes which need to be registered
+ at program start-up time. */
+-#if defined (TARGET_ASM_NAMED_SECTION) && SUPPORTS_WEAK
++#if 0 && defined (TARGET_ASM_NAMED_SECTION) && SUPPORTS_WEAK
+ #ifndef JCR_SECTION_NAME
+ #define JCR_SECTION_NAME ".jcr"
+ #endif
diff --git a/toolchain/gcc/patches/5.2.0/900-bad-mips16-crt.patch b/toolchain/gcc/patches/5.2.0/900-bad-mips16-crt.patch
new file mode 100644
index 0000000..dd6e9dc
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/900-bad-mips16-crt.patch
@@ -0,0 +1,9 @@
+--- a/libgcc/config/mips/t-mips16
++++ b/libgcc/config/mips/t-mips16
+@@ -43,3 +43,6 @@ SYNC_CFLAGS = -mno-mips16
+
+ # Version these symbols if building libgcc.so.
+ SHLIB_MAPFILES += $(srcdir)/config/mips/libgcc-mips16.ver
++
++CRTSTUFF_T_CFLAGS += -mno-mips16
++CRTSTUFF_T_CFLAGS_S += -mno-mips16
diff --git a/toolchain/gcc/patches/5.2.0/910-mbsd_multi.patch b/toolchain/gcc/patches/5.2.0/910-mbsd_multi.patch
new file mode 100644
index 0000000..68661d2
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/910-mbsd_multi.patch
@@ -0,0 +1,222 @@
+
+ This patch brings over a few features from MirBSD:
+ * -fhonour-copts
+ If this option is not given, it's warned (depending
+ on environment variables). This is to catch errors
+ of misbuilt packages which override CFLAGS themselves.
+ * -Werror-maybe-reset
+ Has the effect of -Wno-error if GCC_NO_WERROR is
+ set and not '0', a no-operation otherwise. This is
+ to be able to use -Werror in "make" but prevent
+ GNU autoconf generated configure scripts from
+ freaking out.
+
+ This patch was authored by Thorsten Glaser <tg at mirbsd.de>
+ with copyright assignment to the FSF in effect.
+
+--- a/gcc/c-family/c-opts.c
++++ b/gcc/c-family/c-opts.c
+@@ -122,6 +122,9 @@ static int class_dump_flags;
+ /* Whether any standard preincluded header has been preincluded. */
+ static bool done_preinclude;
+
++/* Check if a port honours COPTS. */
++static int honour_copts = 0;
++
+ static void handle_OPT_d (const char *);
+ static void set_std_cxx98 (int);
+ static void set_std_cxx11 (int);
+@@ -449,6 +452,12 @@ c_common_handle_option (size_t scode, co
+ flag_no_builtin = !value;
+ break;
+
++ case OPT_fhonour_copts:
++ if (c_language == clk_c) {
++ honour_copts++;
++ }
++ break;
++
+ case OPT_fconstant_string_class_:
+ constant_string_class_name = arg;
+ break;
+@@ -1034,6 +1043,47 @@ c_common_init (void)
+ return false;
+ }
+
++ if (c_language == clk_c) {
++ char *ev = getenv ("GCC_HONOUR_COPTS");
++ int evv;
++ if (ev == NULL)
++ evv = -1;
++ else if ((*ev == '0') || (*ev == '\0'))
++ evv = 0;
++ else if (*ev == '1')
++ evv = 1;
++ else if (*ev == '2')
++ evv = 2;
++ else if (*ev == 's')
++ evv = -1;
++ else {
++ warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
++ evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
++ }
++ if (evv == 1) {
++ if (honour_copts == 0) {
++ error ("someone does not honour COPTS at all in lenient mode");
++ return false;
++ } else if (honour_copts != 1) {
++ warning (0, "someone does not honour COPTS correctly, passed %d times",
++ honour_copts);
++ }
++ } else if (evv == 2) {
++ if (honour_copts == 0) {
++ error ("someone does not honour COPTS at all in strict mode");
++ return false;
++ } else if (honour_copts != 1) {
++ error ("someone does not honour COPTS correctly, passed %d times",
++ honour_copts);
++ return false;
++ }
++ } else if (evv == 0) {
++ if (honour_copts != 1)
++ inform (0, "someone does not honour COPTS correctly, passed %d times",
++ honour_copts);
++ }
++ }
++
+ return true;
+ }
+
+--- a/gcc/c-family/c.opt
++++ b/gcc/c-family/c.opt
+@@ -431,6 +431,10 @@ Wfloat-conversion
+ C ObjC C++ ObjC++ Var(warn_float_conversion) LangEnabledBy(C ObjC C++ ObjC++,Wconversion)
+ Warn for implicit type conversions that cause loss of floating point precision
+
++Werror-maybe-reset
++C ObjC C++ ObjC++
++; Documented in common.opt
++
+ Wfloat-equal
+ C ObjC C++ ObjC++ Var(warn_float_equal) Warning
+ Warn if testing floating point numbers for equality
+@@ -1161,6 +1165,9 @@ C++ ObjC++ Optimization Alias(fexception
+ fhonor-std
+ C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
+
++fhonour-copts
++C ObjC C++ ObjC++ RejectNegative
++
+ fhosted
+ C ObjC
+ Assume normal C execution environment
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -561,6 +561,10 @@ Werror=
+ Common Joined
+ Treat specified warning as error
+
++Werror-maybe-reset
++Common
++If environment variable GCC_NO_WERROR is set, act as -Wno-error
++
+ Wextra
+ Common Var(extra_warnings) Warning
+ Print extra (possibly unwanted) warnings
+@@ -1360,6 +1364,9 @@ fguess-branch-probability
+ Common Report Var(flag_guess_branch_prob) Optimization
+ Enable guessing of branch probabilities
+
++fhonour-copts
++Common RejectNegative
++
+ ; Nonzero means ignore `#ident' directives. 0 means handle them.
+ ; Generate position-independent code for executables if possible
+ ; On SVR4 targets, it also controls whether or not to emit a
+--- a/gcc/opts.c
++++ b/gcc/opts.c
+@@ -1699,6 +1699,17 @@ common_handle_option (struct gcc_options
+ opts, opts_set, loc, dc);
+ break;
+
++ case OPT_Werror_maybe_reset:
++ {
++ char *ev = getenv ("GCC_NO_WERROR");
++ if ((ev != NULL) && (*ev != '0'))
++ warnings_are_errors = 0;
++ }
++ break;
++
++ case OPT_fhonour_copts:
++ break;
++
+ case OPT_Wlarger_than_:
+ opts->x_larger_than_size = value;
+ opts->x_warn_larger_than = value != -1;
+--- a/gcc/doc/cppopts.texi
++++ b/gcc/doc/cppopts.texi
+@@ -163,6 +163,11 @@ in older programs. This warning is on b
+ Make all warnings into hard errors. Source code which triggers warnings
+ will be rejected.
+
++ at item -Werror-maybe-reset
++ at opindex Werror-maybe-reset
++Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
++variable is set to anything other than 0 or empty.
++
+ @item -Wsystem-headers
+ @opindex Wsystem-headers
+ Issue warnings for code in system headers. These are normally unhelpful
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -251,7 +251,7 @@ Objective-C and Objective-C++ Dialects}.
+ -Wdisabled-optimization @gol
+ -Wno-discarded-qualifiers -Wno-discarded-array-qualifiers @gol
+ -Wno-div-by-zero -Wdouble-promotion -Wempty-body -Wenum-compare @gol
+--Wno-endif-labels -Werror -Werror=* @gol
++-Wno-endif-labels -Werror -Werror=* -Werror-maybe-reset @gol
+ -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
+ -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
+ -Wformat-security -Wformat-signedness -Wformat-y2k @gol
+@@ -5371,6 +5371,22 @@ This option is only supported for C and
+ @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
+ @option{-Wno-pointer-sign}.
+
++ at item -Werror-maybe-reset
++ at opindex Werror-maybe-reset
++Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
++variable is set to anything other than 0 or empty.
++
++ at item -fhonour-copts
++ at opindex fhonour-copts
++If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
++given at least once, and warn if it is given more than once.
++If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
++given exactly once.
++If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
++is not given exactly once.
++The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
++This flag and environment variable only affect the C language.
++
+ @item -Wstack-protector
+ @opindex Wstack-protector
+ @opindex Wno-stack-protector
+@@ -7844,7 +7860,7 @@ so, the first branch is redirected to ei
+ second branch or a point immediately following it, depending on whether
+ the condition is known to be true or false.
+
+-Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
++Enabled at levels @option{-O3}.
+
+ @item -fsplit-wide-types
+ @opindex fsplit-wide-types
+--- a/gcc/java/jvspec.c
++++ b/gcc/java/jvspec.c
+@@ -629,6 +629,7 @@ lang_specific_pre_link (void)
+ class name. Append dummy `.c' that can be stripped by set_input so %b
+ is correct. */
+ set_input (concat (main_class_name, "main.c", NULL));
++ putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
+ err = do_spec (jvgenmain_spec);
+ if (err == 0)
+ {
diff --git a/toolchain/gcc/patches/5.2.0/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches/5.2.0/920-specs_nonfatal_getenv.patch
new file mode 100644
index 0000000..3d708f2
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/920-specs_nonfatal_getenv.patch
@@ -0,0 +1,15 @@
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -8807,8 +8807,10 @@ getenv_spec_function (int argc, const ch
+
+ value = getenv (argv[0]);
+ if (!value)
+- fatal_error (input_location,
+- "environment variable %qs not defined", argv[0]);
++ {
++ warning (input_location, "environment variable %qs not defined", argv[0]);
++ value = "";
++ }
+
+ /* We have to escape every character of the environment variable so
+ they are not interpreted as active spec characters. A
diff --git a/toolchain/gcc/patches/5.2.0/930-fix-mips-noexecstack.patch b/toolchain/gcc/patches/5.2.0/930-fix-mips-noexecstack.patch
new file mode 100644
index 0000000..4bb126e
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/930-fix-mips-noexecstack.patch
@@ -0,0 +1,111 @@
+From da45b3fde60095756f5f6030f6012c23a3d34429 Mon Sep 17 00:00:00 2001
+From: Andrew McDonnell <bugs@andrewmcdonnell.net>
+Date: Fri, 3 Oct 2014 19:09:00 +0930
+Subject: Add .note.GNU-stack section
+
+See http://lists.busybox.net/pipermail/uclibc/2014-October/048671.html
+Below copied from https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02430.html
+
+Re: [Patch, MIPS] Add .note.GNU-stack section
+
+ From: Steve Ellcey <sellcey at mips dot com>
+
+On Wed, 2014-09-10 at 10:15 -0700, Eric Christopher wrote:
+>
+>
+> On Wed, Sep 10, 2014 at 9:27 AM, <pinskia@gmail.com> wrote:
+
+> This works except you did not update the assembly files in
+> libgcc or glibc. We (Cavium) have the same patch in our tree
+> for a few released versions.
+
+> Mind just checking yours in then Andrew?
+
+> Thanks!
+> -eric
+
+I talked to Andrew about what files he changed in GCC and created and
+tested this new patch. Andrew also mentioned changing some assembly
+files in glibc but I don't see any use of '.section .note.GNU-stack' in
+any assembly files in glibc (for any platform) so I wasn't planning on
+creating a glibc to add them to mips glibc assembly language files.
+
+OK to check in this patch?
+
+Steve Ellcey
+sellcey@mips.com
+
+
+
+2014-09-26 Steve Ellcey <sellcey@mips.com>
+---
+ gcc/config/mips/mips.c | 3 +++
+ libgcc/config/mips/crti.S | 4 ++++
+ libgcc/config/mips/crtn.S | 3 +++
+ libgcc/config/mips/mips16.S | 4 ++++
+ libgcc/config/mips/vr4120-div.S | 4 ++++
+ 5 files changed, 18 insertions(+)
+
+--- a/gcc/config/mips/mips.c
++++ b/gcc/config/mips/mips.c
+@@ -19621,6 +19621,9 @@ mips_lra_p (void)
+ #undef TARGET_LRA_P
+ #define TARGET_LRA_P mips_lra_p
+
++#undef TARGET_ASM_FILE_END
++#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
++
+ struct gcc_target targetm = TARGET_INITIALIZER;
+
+ #include "gt-mips.h"
+--- a/libgcc/config/mips/crti.S
++++ b/libgcc/config/mips/crti.S
+@@ -21,6 +21,10 @@ a copy of the GCC Runtime Library Except
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++
+ /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack.
+ Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */
+
+--- a/libgcc/config/mips/crtn.S
++++ b/libgcc/config/mips/crtn.S
+@@ -21,6 +21,9 @@ a copy of the GCC Runtime Library Except
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++
+ /* 4 slots for argument spill area. 1 for cpreturn, 1 for stack.
+ Return spill offset of 40 and 20. Aligned to 16 bytes for n32. */
+
+--- a/libgcc/config/mips/mips16.S
++++ b/libgcc/config/mips/mips16.S
+@@ -48,6 +48,10 @@ see the files COPYING3 and COPYING.RUNTI
+ values using the soft-float calling convention, but do the actual
+ operation using the hard floating point instructions. */
+
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++ .previous
++
+ #if defined _MIPS_SIM && (_MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIO64)
+
+ /* This file contains 32-bit assembly code. */
+--- a/libgcc/config/mips/vr4120-div.S
++++ b/libgcc/config/mips/vr4120-div.S
+@@ -26,6 +26,10 @@ see the files COPYING3 and COPYING.RUNTI
+ -mfix-vr4120. div and ddiv do not give the correct result when one
+ of the operands is negative. */
+
++/* An executable stack is *not* required for these functions. */
++ .section .note.GNU-stack,"",%progbits
++ .previous
++
+ .set nomips16
+
+ #define DIV \
diff --git a/toolchain/gcc/patches/5.2.0/940-no-clobber-stamp-bits.patch b/toolchain/gcc/patches/5.2.0/940-no-clobber-stamp-bits.patch
new file mode 100644
index 0000000..bf2ab07
--- /dev/null
+++ b/toolchain/gcc/patches/5.2.0/940-no-clobber-stamp-bits.patch
@@ -0,0 +1,11 @@
+--- a/libstdc++-v3/include/Makefile.in
++++ b/libstdc++-v3/include/Makefile.in
+@@ -1382,7 +1382,7 @@ stamp-bits: ${bits_headers}
+ @$(STAMP) stamp-bits
+
+ stamp-bits-sup: stamp-bits ${bits_sup_headers}
+- @-cd ${bits_builddir} && $(LN_S) $? . 2>/dev/null
++ @-cd ${bits_builddir} && $(LN_S) $(filter-out stamp-bits,$?) . 2>/dev/null
+ @$(STAMP) stamp-bits-sup
+
+ stamp-c_base: ${c_base_headers}
diff --git a/toolchain/gdb/Makefile b/toolchain/gdb/Makefile
new file mode 100644
index 0000000..fa5179a
--- /dev/null
+++ b/toolchain/gdb/Makefile
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gdb
+PKG_VERSION:=7.8
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@GNU/gdb
+PKG_MD5SUM:=bd958fe9019d7c7896f29f6724a764ed
+
+HOST_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+HOST_CONFIGURE_VARS += \
+ gdb_cv_func_sigsetjmp=yes
+
+HOST_CONFIGURE_ARGS = \
+ --prefix=$(TOOLCHAIN_DIR) \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --disable-werror \
+ --without-uiout \
+ --disable-tui --disable-gdbtk --without-x \
+ --without-included-gettext \
+ --enable-threads \
+ --with-expat
+
+define Host/Install
+ mkdir -p $(TOOLCHAIN_DIR)/bin
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/gdb/gdb $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)gdb
+ ln -fs $(TARGET_CROSS)gdb $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-gdb
+ strip $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)gdb
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)gdb \
+ $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-gdb
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/gdb/patches/100-no_extern_inline.patch b/toolchain/gdb/patches/100-no_extern_inline.patch
new file mode 100644
index 0000000..bbae1d7
--- /dev/null
+++ b/toolchain/gdb/patches/100-no_extern_inline.patch
@@ -0,0 +1,32 @@
+--- a/sim/common/sim-arange.c
++++ b/sim/common/sim-arange.c
+@@ -280,11 +280,7 @@ sim_addr_range_delete (ADDR_RANGE *ar, a
+ build_search_tree (ar);
+ }
+
+-#endif /* DEFINE_NON_INLINE_P */
+-
+-#if DEFINE_INLINE_P
+-
+-SIM_ARANGE_INLINE int
++int
+ sim_addr_range_hit_p (ADDR_RANGE *ar, address_word addr)
+ {
+ ADDR_RANGE_TREE *t = ar->range_tree;
+@@ -301,4 +297,4 @@ sim_addr_range_hit_p (ADDR_RANGE *ar, ad
+ return 0;
+ }
+
+-#endif /* DEFINE_INLINE_P */
++#endif /* DEFINE_NON_INLINE_P */
+--- a/sim/common/sim-arange.h
++++ b/sim/common/sim-arange.h
+@@ -62,7 +62,7 @@ extern void sim_addr_range_delete (ADDR_
+
+ /* Return non-zero if ADDR is in range AR, traversing the entire tree.
+ If no range is specified, that is defined to mean "everything". */
+-extern INLINE int
++extern int
+ sim_addr_range_hit_p (ADDR_RANGE * /*ar*/, address_word /*addr*/);
+ #define ADDR_RANGE_HIT_P(ar, addr) \
+ ((ar)->range_tree == NULL || sim_addr_range_hit_p ((ar), (addr)))
diff --git a/toolchain/gdb/patches/110-no_testsuite.patch b/toolchain/gdb/patches/110-no_testsuite.patch
new file mode 100644
index 0000000..5c5d15c
--- /dev/null
+++ b/toolchain/gdb/patches/110-no_testsuite.patch
@@ -0,0 +1,21 @@
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -855,8 +855,7 @@ MAKEINFOFLAGS
+ YACC
+ YFLAGS
+ XMKMF'
+-ac_subdirs_all='testsuite
+-gdbtk
++ac_subdirs_all='gdbtk
+ multi-ice
+ gdbserver'
+
+@@ -5168,7 +5167,7 @@ $as_echo "$with_auto_load_safe_path" >&6
+
+
+
+-subdirs="$subdirs testsuite"
++subdirs="$subdirs"
+
+
+ # Check whether to support alternative target configurations
diff --git a/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch b/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch
new file mode 100644
index 0000000..ce34c95
--- /dev/null
+++ b/toolchain/gdb/patches/120-fix-compile-flag-mismatch.patch
@@ -0,0 +1,11 @@
+--- a/gdb/gdbserver/configure
++++ b/gdb/gdbserver/configure
+@@ -2183,7 +2183,7 @@ $as_echo "$as_me: error: \`$ac_var' was
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+- if test "x$ac_old_val" != "x$ac_new_val"; then
++ if test "`echo x$ac_old_val`" != "`echo x$ac_new_val`"; then
+ # differences in whitespace do not lead to failure.
+ ac_old_val_w=`echo x $ac_old_val`
+ ac_new_val_w=`echo x $ac_new_val`
diff --git a/toolchain/glibc/Config.in b/toolchain/glibc/Config.in
new file mode 100644
index 0000000..66ff2f4
--- /dev/null
+++ b/toolchain/glibc/Config.in
@@ -0,0 +1,21 @@
+choice
+ prompt "(e)glibc version"
+ depends on TOOLCHAINOPTS && USE_GLIBC
+ default EGLIBC_USE_VERSION_2_19
+ help
+ Select the version of glibc you wish to use.
+
+ config EGLIBC_USE_VERSION_2_19
+ bool "eglibc 2.19"
+ select EGLIBC_VERSION_2_19
+
+ config GLIBC_USE_VERSION_2_21
+ bool "glibc 2.21"
+ select GLIBC_VERSION_2_21
+
+endchoice
+
+menu "eglibc configuration"
+ depends on TOOLCHAINOPTS && USE_GLIBC && EGLIBC_USE_VERSION_2_19
+ source toolchain/glibc/config/Config.in
+endmenu
diff --git a/toolchain/glibc/Config.version b/toolchain/glibc/Config.version
new file mode 100644
index 0000000..2ac01d7
--- /dev/null
+++ b/toolchain/glibc/Config.version
@@ -0,0 +1,26 @@
+if USE_GLIBC
+
+config GLIBC_VERSION
+ string
+ default "2.19" if EGLIBC_VERSION_2_19
+ default "2.21" if GLIBC_VERSION_2_21
+
+config EGLIBC_VERSION_2_19
+ default y if !TOOLCHAINOPTS
+ bool
+
+config GLIBC_VERSION_2_21
+ bool
+
+config GLIBC_REVISION
+ string
+ default "25243" if EGLIBC_VERSION_2_19
+ default "4e42b5b8f8" if GLIBC_VERSION_2_21
+ default ""
+
+endif
+
+menu "eglibc configuration"
+ depends on !TOOLCHAINOPTS && USE_GLIBC
+ source toolchain/glibc/config/Config.in
+endmenu
diff --git a/toolchain/glibc/Makefile b/toolchain/glibc/Makefile
new file mode 100644
index 0000000..f880db8
--- /dev/null
+++ b/toolchain/glibc/Makefile
@@ -0,0 +1,31 @@
+PATH_PREFIX := .
+VARIANT:=final
+HOST_BUILD_PARALLEL:=0
+
+include ./common.mk
+
+define Host/Compile
+ $(MAKE) -C $(CUR_BUILD_DIR) \
+ PARALLELMFLAGS="$(HOST_JOBS)" \
+ BUILD_CFLAGS="$(HOST_CFLAGS)" \
+ all
+endef
+
+define Host/Install
+ $(call Host/SetToolchainInfo)
+ $(MAKE) -C $(CUR_BUILD_DIR) \
+ BUILD_CFLAGS="$(HOST_CFLAGS)" \
+ install_root="$(TOOLCHAIN_DIR)" \
+ install
+ ( cd $(TOOLCHAIN_DIR) ; \
+ for d in lib usr/lib ; do \
+ for f in libc.so libpthread.so libgcc_s.so ; do \
+ if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
+ $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
+ fi \
+ done \
+ done \
+ )
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/glibc/common.mk b/toolchain/glibc/common.mk
new file mode 100644
index 0000000..7487ca2
--- /dev/null
+++ b/toolchain/glibc/common.mk
@@ -0,0 +1,109 @@
+#
+# Copyright (C) 2006-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=glibc
+PKG_VERSION:=$(call qstrip,$(CONFIG_GLIBC_VERSION))
+PKG_REVISION:=$(call qstrip,$(CONFIG_GLIBC_REVISION))
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://sourceware.org/git/glibc.git
+PKG_SOURCE_VERSION:=$(PKG_REVISION)
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)-r$(PKG_REVISION)
+PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.bz2
+
+GLIBC_PATH:=
+ifneq ($(CONFIG_EGLIBC_VERSION_2_19),)
+ GLIBC_PATH:=libc/
+ PKG_SOURCE_PROTO:=svn
+ PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.bz2
+ PKG_SOURCE_URL:=svn://svn.eglibc.org/branches/eglibc-2_19
+endif
+
+PATCH_DIR:=$(PATH_PREFIX)/patches/$(PKG_VERSION)
+
+HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_SOURCE_SUBDIR)
+CUR_BUILD_DIR:=$(HOST_BUILD_DIR)-$(VARIANT)
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+HOST_STAMP_PREPARED:=$(HOST_BUILD_DIR)/.prepared
+HOST_STAMP_CONFIGURED:=$(CUR_BUILD_DIR)/.configured
+HOST_STAMP_BUILT:=$(CUR_BUILD_DIR)/.built
+HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.glibc_$(VARIANT)_installed
+
+ifeq ($(ARCH),mips64)
+ ifdef CONFIG_MIPS64_ABI_N64
+ TARGET_CFLAGS += -mabi=64
+ endif
+ ifdef CONFIG_MIPS64_ABI_N32
+ TARGET_CFLAGS += -mabi=n32
+ endif
+ ifdef CONFIG_MIPS64_ABI_O32
+ TARGET_CFLAGS += -mabi=32
+ endif
+endif
+
+GLIBC_CONFIGURE:= \
+ BUILD_CC="$(HOSTCC)" \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ libc_cv_slibdir="/lib" \
+ use_ldconfig=no \
+ $(HOST_BUILD_DIR)/$(GLIBC_PATH)configure \
+ --prefix= \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(REAL_GNU_TARGET_NAME) \
+ --with-headers=$(TOOLCHAIN_DIR)/include \
+ --disable-profile \
+ --disable-werror \
+ --without-gd \
+ --without-cvs \
+ --enable-add-ons \
+ --$(if $(CONFIG_SOFT_FLOAT),without,with)-fp
+
+export libc_cv_ssp=no
+export ac_cv_header_cpuid_h=yes
+export HOST_CFLAGS := $(HOST_CFLAGS) -idirafter $(CURDIR)/$(PATH_PREFIX)/include
+
+define Host/SetToolchainInfo
+ $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
+ifneq ($(CONFIG_GLIBC_VERSION_2_21),)
+ $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.gnu.org/software/libc/,' $(TOOLCHAIN_DIR)/info.mk
+else
+ $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.eglibc.org/,' $(TOOLCHAIN_DIR)/info.mk
+endif
+ $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+endef
+
+define Host/Configure
+ [ -f $(HOST_BUILD_DIR)/.autoconf ] || { \
+ cd $(HOST_BUILD_DIR)/$(GLIBC_PATH); \
+ autoconf --force && \
+ touch $(HOST_BUILD_DIR)/.autoconf; \
+ }
+ mkdir -p $(CUR_BUILD_DIR)
+ grep 'CONFIG_EGLIBC_OPTION_' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_EGLIBC_\\(.*\\),\\1\\2,g" > $(CUR_BUILD_DIR)/option-groups.config
+ ( cd $(CUR_BUILD_DIR); rm -f config.cache; \
+ $(GLIBC_CONFIGURE) \
+ );
+endef
+
+define Host/Prepare
+ $(call Host/Prepare/Default)
+ ln -snf $(PKG_SOURCE_SUBDIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+ifeq ($(CONFIG_GLIBC_VERSION_2_21),)
+ $(SED) 's,y,n,' $(HOST_BUILD_DIR)/libc/option-groups.defaults
+endif
+endef
+
+define Host/Clean
+ rm -rf $(CUR_BUILD_DIR)* \
+ $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
+ $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+endef
diff --git a/toolchain/glibc/config/Config.in b/toolchain/glibc/config/Config.in
new file mode 100644
index 0000000..6f02223
--- /dev/null
+++ b/toolchain/glibc/config/Config.in
@@ -0,0 +1,903 @@
+config EGLIBC_OPTION_EGLIBC_ADVANCED_INET6
+ bool "IPv6 Advanced Sockets API support (RFC3542)"
+ default y
+ select EGLIBC_OPTION_EGLIBC_INET
+ help
+ This option group includes the functions specified by RFC 3542,
+ "Advanced Sockets Application Program Interface (API) for
+ IPv6".
+
+ This option group includes the following functions:
+
+ inet6_opt_append
+ inet6_opt_find
+ inet6_opt_finish
+ inet6_opt_get_val
+ inet6_opt_init
+ inet6_option_alloc
+ inet6_option_append
+ inet6_option_find
+ inet6_option_init
+ inet6_option_next
+ inet6_option_space
+ inet6_opt_next
+ inet6_opt_set_val
+ inet6_rth_add
+ inet6_rth_getaddr
+ inet6_rth_init
+ inet6_rth_reverse
+ inet6_rth_segments
+ inet6_rth_space
+
+
+config EGLIBC_OPTION_EGLIBC_BACKTRACE
+ bool "Functions for producing backtraces"
+ default y
+ help
+ This option group includes functions for producing a list of
+ the function calls that are currently active in a thread, from
+ within the thread itself. These functions are often used
+ within signal handlers, to produce diagnostic output.
+
+ This option group includes the following functions:
+
+ backtrace
+ backtrace_symbols
+ backtrace_symbols_fd
+
+
+config EGLIBC_OPTION_EGLIBC_BIG_MACROS
+ bool "Use extensive inline code"
+ default y
+ help
+ This option group specifies whether certain pieces of code
+ should be inlined to achieve maximum speed. If this option
+ group is not selected, function calls will be used instead,
+ hence reducing the library footprint.
+
+
+config EGLIBC_OPTION_EGLIBC_BSD
+ bool "BSD-specific functions, and their compatibility stubs"
+ default y
+ help
+ This option group includes functions specific to BSD kernels.
+ A number of these functions have stub versions that are also
+ included in libraries built for non-BSD systems for
+ compatibility.
+
+ This option group includes the following functions:
+
+ chflags
+ fchflags
+ lchmod
+ revoke
+ setlogin
+
+
+config EGLIBC_OPTION_EGLIBC_CXX_TESTS
+ bool "Tests that link against the standard C++ library."
+ default y
+ select EGLIBC_OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+ select EGLIBC_OPTION_EGLIBC_LIBM
+ help
+ This option group does not include any C library functions;
+ instead, it controls which EGLIBC tests an ordinary 'make
+ tests' runs. With this group disabled, tests that would
+ normally link against the standard C++ library are not
+ run.
+
+ The standard C++ library depends on the math library 'libm' and
+ the wide character I/O functions included in EGLIBC. If those
+ option groups are disabled, this test must also be disabled.
+
+
+config EGLIBC_OPTION_EGLIBC_CATGETS
+ bool "Functions for accessing message catalogs"
+ default y
+ select EGLIBC_OPTION_EGLIBC_LOCALE_CODE
+ help
+ This option group includes functions for accessing message
+ catalogs: catopen, catclose, and catgets.
+
+ This option group depends on the EGLIBC_OPTION_EGLIBC_LOCALE_CODE
+ option group; if you disable that, you must also disable this.
+
+
+config EGLIBC_OPTION_EGLIBC_CHARSETS
+ bool "iconv/gconv character set conversion libraries"
+ default y
+ help
+
+ This option group includes support for character sets other
+ than ASCII (ANSI_X3.4-1968) and Unicode and ISO-10646 in their
+ various encodings. This affects both the character sets
+ supported by the wide and multibyte character functions, and
+ those supported by the 'iconv' functions.
+
+ With this option group disabled, EGLIBC supports only the
+ following character sets:
+
+ ANSI_X3.4 - ASCII
+ ANSI_X3.4-1968
+ ANSI_X3.4-1986
+ ASCII
+ CP367
+ CSASCII
+ IBM367
+ ISO-IR-6
+ ISO646-US
+ ISO_646.IRV:1991
+ OSF00010020
+ US
+ US-ASCII
+
+ 10646-1:1993 - ISO 10646, in big-endian UCS4 form
+ 10646-1:1993/UCS4
+ CSUCS4
+ ISO-10646
+ ISO-10646/UCS4
+ OSF00010104
+ OSF00010105
+ OSF00010106
+ UCS-4
+ UCS-4BE
+ UCS4
+
+ UCS-4LE - ISO 10646, in little-endian UCS4 form
+
+ ISO-10646/UTF-8 - ISO 10646, in UTF-8 form
+ ISO-10646/UTF8
+ ISO-IR-193
+ OSF05010001
+ UTF-8
+ UTF8
+
+ ISO-10646/UCS2 - ISO 10646, in target-endian UCS2 form
+ OSF00010100
+ OSF00010101
+ OSF00010102
+ UCS-2
+ UCS2
+
+ UCS-2BE - ISO 10646, in big-endian UCS2 form
+ UNICODEBIG
+
+ UCS-2LE - ISO 10646, in little-endian UCS2 form
+ UNICODELITTLE
+
+ WCHAR_T - EGLIBC's internal form (target-endian,
+ 32-bit ISO 10646)
+
+
+config EGLIBC_OPTION_EGLIBC_CRYPT
+ bool "Encryption library"
+ default y
+ help
+ This option group includes the `libcrypt' library which
+ provides functions for one-way encryption. Supported
+ encryption algorithms include MD5, SHA-256, SHA-512 and DES.
+
+
+config EGLIBC_OPTION_EGLIBC_CRYPT_UFC
+ bool "Ultra fast `crypt' implementation"
+ default y
+ select EGLIBC_OPTION_EGLIBC_CRYPT
+ help
+ This option group provides ultra fast DES-based implementation of
+ the `crypt' function. When this option group is disabled,
+ (a) the library will not provide the setkey[_r] and encrypt[_r]
+ functions and (b) the crypt[_r] function will return NULL and set the
+ errno to ENOSYS if /salt/ passed does not correspond to either MD5,
+ SHA-256 or SHA-512 algorithm.
+
+
+config EGLIBC_OPTION_EGLIBC_DB_ALIASES
+ bool "Functions for accessing the mail aliases database"
+ default y
+ help
+ This option group includes functions for looking up mail
+ aliases in '/etc/aliases' or using nsswitch. It includes the
+ following functions:
+
+ endaliasent
+ getaliasbyname
+ getaliasbyname_r
+ getaliasent
+ getaliasent_r
+ setaliasent
+
+ When this option group is disabled, the NSS service libraries
+ also lack support for querying their mail alias tables.
+
+
+config EGLIBC_OPTION_EGLIBC_ENVZ
+ bool "Functions for handling envz-style environment vectors."
+ default y
+ help
+ This option group contains functions for creating and operating
+ on envz vectors. An "envz vector" is a vector of strings in a
+ contiguous block of memory, where each element is a name-value
+ pair, and elements are separated from their neighbors by null
+ characters.
+
+ This option group includes the following functions:
+
+ envz_add envz_merge
+ envz_entry envz_remove
+ envz_get envz_strip
+
+
+config EGLIBC_OPTION_EGLIBC_FCVT
+ bool "Functions for converting floating-point numbers to strings"
+ default y
+ help
+ This option group includes functions for converting
+ floating-point numbers to strings.
+
+ This option group includes the following functions:
+
+ ecvt qecvt
+ ecvt_r qecvt_r
+ fcvt qfcvt
+ fcvt_r qfcvt_r
+ gcvt qgcvt
+
+
+config EGLIBC_OPTION_EGLIBC_FMTMSG
+ bool "Functions for formatting messages"
+ default y
+ help
+ This option group includes the following functions:
+
+ addseverity fmtmsg
+
+
+config EGLIBC_OPTION_EGLIBC_FSTAB
+ bool "Access functions for 'fstab'"
+ default y
+ help
+ This option group includes functions for reading the mount
+ point specification table, '/etc/fstab'. These functions are
+ not included in the POSIX standard, which provides the
+ 'getmntent' family of functions instead.
+
+ This option group includes the following functions:
+
+ endfsent getfsspec
+ getfsent setfsent
+ getfsfile
+
+
+config EGLIBC_OPTION_EGLIBC_FTRAVERSE
+ bool "Functions for traversing file hierarchies"
+ default y
+ help
+ This option group includes functions for traversing file
+ UNIX file hierachies.
+
+ This option group includes the following functions:
+
+ fts_open ftw
+ fts_read nftw
+ fts_children ftw64
+ fts_set nftw64
+ fts_close
+
+
+config EGLIBC_OPTION_EGLIBC_GETLOGIN
+ bool "The getlogin function"
+ default y
+ select EGLIBC_OPTION_EGLIBC_UTMP
+ help
+ This function group includes the 'getlogin' and 'getlogin_r'
+ functions, which return the user name associated by the login
+ activity with the current process's controlling terminal.
+
+ With this option group disabled, the 'glob' function will not
+ fall back on 'getlogin' to find the user's login name for tilde
+ expansion when the 'HOME' environment variable is not set.
+
+
+config EGLIBC_OPTION_EGLIBC_IDN
+ bool "International domain names support"
+ default y
+ help
+ This option group includes the `libcidn' library which
+ provides support for international domain names.
+
+
+config EGLIBC_OPTION_EGLIBC_INET
+ bool "Networking support"
+ default y
+ help
+ This option group includes networking-specific functions and
+ data. With EGLIBC_OPTION_EGLIBC_INET disabled, the EGLIBC
+ installation and API changes as follows:
+
+ - The following libraries are not installed:
+
+ libanl
+ libnsl
+ libnss_compat
+ libnss_dns
+ libnss_hesiod
+ libnss_nis
+ libnss_nisplus
+ libresolv
+
+ - The following functions and variables are omitted from libc:
+
+ authdes_create hstrerror svc_fdset
+ authdes_getucred htonl svc_getreq
+ authdes_pk_create htons svc_getreq_common
+ authnone_create if_freenameindex svc_getreq_poll
+ authunix_create if_indextoname svc_getreqset
+ authunix_create_default if_nameindex svc_max_pollfd
+ bindresvport if_nametoindex svc_pollfd
+ callrpc in6addr_any svcraw_create
+ cbc_crypt in6addr_loopback svc_register
+ clnt_broadcast inet6_opt_append svc_run
+ clnt_create inet6_opt_find svc_sendreply
+ clnt_pcreateerror inet6_opt_finish svctcp_create
+ clnt_perrno inet6_opt_get_val svcudp_bufcreate
+ clnt_perror inet6_opt_init svcudp_create
+ clntraw_create inet6_option_alloc svcudp_enablecache
+ clnt_spcreateerror inet6_option_append svcunix_create
+ clnt_sperrno inet6_option_find svcunixfd_create
+ clnt_sperror inet6_option_init svc_unregister
+ clnttcp_create inet6_option_next user2netname
+ clntudp_bufcreate inet6_option_space xdecrypt
+ clntudp_create inet6_opt_next xdr_accepted_reply
+ clntunix_create inet6_opt_set_val xdr_array
+ des_setparity inet6_rth_add xdr_authdes_cred
+ ecb_crypt inet6_rth_getaddr xdr_authdes_verf
+ endaliasent inet6_rth_init xdr_authunix_parms
+ endhostent inet6_rth_reverse xdr_bool
+ endnetent inet6_rth_segments xdr_bytes
+ endnetgrent inet6_rth_space xdr_callhdr
+ endprotoent inet_addr xdr_callmsg
+ endrpcent inet_aton xdr_char
+ endservent inet_lnaof xdr_cryptkeyarg
+ ether_aton inet_makeaddr xdr_cryptkeyarg2
+ ether_aton_r inet_netof xdr_cryptkeyres
+ ether_hostton inet_network xdr_des_block
+ ether_line inet_nsap_addr xdr_double
+ ether_ntoa inet_nsap_ntoa xdr_enum
+ ether_ntoa_r inet_ntoa xdr_float
+ ether_ntohost inet_ntop xdr_free
+ freeaddrinfo inet_pton xdr_getcredres
+ freeifaddrs innetgr xdr_hyper
+ gai_strerror iruserok xdr_int
+ getaddrinfo iruserok_af xdr_int16_t
+ getaliasbyname key_decryptsession xdr_int32_t
+ getaliasbyname_r key_decryptsession_pk xdr_int64_t
+ getaliasent key_encryptsession xdr_int8_t
+ getaliasent_r key_encryptsession_pk xdr_keybuf
+ gethostbyaddr key_gendes xdr_key_netstarg
+ gethostbyaddr_r key_get_conv xdr_key_netstres
+ gethostbyname key_secretkey_is_set xdr_keystatus
+ gethostbyname2 key_setnet xdr_long
+ gethostbyname2_r key_setsecret xdr_longlong_t
+ gethostbyname_r netname2host xdrmem_create
+ gethostent netname2user xdr_netnamestr
+ gethostent_r ntohl xdr_netobj
+ getifaddrs ntohs xdr_opaque
+ getipv4sourcefilter passwd2des xdr_opaque_auth
+ get_myaddress pmap_getmaps xdr_pmap
+ getnameinfo pmap_getport xdr_pmaplist
+ getnetbyaddr pmap_rmtcall xdr_pointer
+ getnetbyaddr_r pmap_set xdr_quad_t
+ getnetbyname pmap_unset xdrrec_create
+ getnetbyname_r rcmd xdrrec_endofrecord
+ getnetent rcmd_af xdrrec_eof
+ getnetent_r registerrpc xdrrec_skiprecord
+ getnetgrent res_init xdr_reference
+ getnetgrent_r rexec xdr_rejected_reply
+ getnetname rexec_af xdr_replymsg
+ getprotobyname rexecoptions xdr_rmtcall_args
+ getprotobyname_r rpc_createerr xdr_rmtcallres
+ getprotobynumber rresvport xdr_short
+ getprotobynumber_r rresvport_af xdr_sizeof
+ getprotoent rtime xdrstdio_create
+ getprotoent_r ruserok xdr_string
+ getpublickey ruserok_af xdr_u_char
+ getrpcbyname ruserpass xdr_u_hyper
+ getrpcbyname_r setaliasent xdr_u_int
+ getrpcbynumber sethostent xdr_uint16_t
+ getrpcbynumber_r setipv4sourcefilter xdr_uint32_t
+ getrpcent setnetent xdr_uint64_t
+ getrpcent_r setnetgrent xdr_uint8_t
+ getrpcport setprotoent xdr_u_long
+ getsecretkey setrpcent xdr_u_longlong_t
+ getservbyname setservent xdr_union
+ getservbyname_r setsourcefilter xdr_unixcred
+ getservbyport svcauthdes_stats xdr_u_quad_t
+ getservbyport_r svcerr_auth xdr_u_short
+ getservent svcerr_decode xdr_vector
+ getservent_r svcerr_noproc xdr_void
+ getsourcefilter svcerr_noprog xdr_wrapstring
+ h_errlist svcerr_progvers xencrypt
+ h_errno svcerr_systemerr xprt_register
+ herror svcerr_weakauth xprt_unregister
+ h_nerr svc_exit
+ host2netname svcfd_create
+
+ - The rpcgen, nscd, and rpcinfo commands are not installed.
+
+ - The 'rpc' file (a text file listing RPC services) is not installed.
+
+ Socket-related system calls do not fall in this option group,
+ because many are also used for other inter-process
+ communication mechanisms. For example, the 'syslog' routines
+ use Unix-domain sockets to communicate with the syslog daemon;
+ syslog is valuable in non-networked contexts.
+
+
+config EGLIBC_OPTION_EGLIBC_INET_ANL
+ bool "Asynchronous name lookup"
+ default y
+ select EGLIBC_OPTION_EGLIBC_INET
+ help
+ This option group includes the `libanl' library which
+ provides support for asynchronous name lookup.
+
+
+config EGLIBC_OPTION_EGLIBC_LIBM
+ bool "libm (math library)"
+ default y
+ help
+ This option group includes the 'libm' library, containing
+ mathematical functions. If this option group is omitted, then
+ an EGLIBC installation does not include shared or unshared versions
+ of the math library.
+
+ Note that this does not remove all floating-point related
+ functionality from EGLIBC; for example, 'printf' and 'scanf'
+ can still print and read floating-point values with this option
+ group disabled.
+
+ Note that the ISO Standard C++ library 'libstdc++' depends on
+ EGLIBC's math library 'libm'. If you disable this option
+ group, you will not be able to build 'libstdc++' against the
+ resulting EGLIBC installation.
+
+
+config EGLIBC_OPTION_EGLIBC_LIBM_BIG
+ bool "Math library size"
+ default y
+ help
+ This option group enables default configuration of the math library.
+ Not selecting this option group removes most of the extended and
+ double precision math functions and replaces them with wrappers
+ to the single precision couterparts.
+ Doing so greatly degrades quality of calculations carried
+ out by the functions of the math library, but also significantly
+ reduces the size of the libm.
+ This option group is useful for systems that do not rely on precise
+ floating point math.
+
+
+config EGLIBC_OPTION_EGLIBC_LOCALES
+ bool "Locale definitions"
+ default y
+ help
+ This option group includes all locale definitions other than
+ that for the "C" locale. If this option group is omitted, then
+ only the "C" locale is supported.
+
+
+config EGLIBC_OPTION_EGLIBC_LOCALE_CODE
+ bool "Locale functions"
+ default y
+ select EGLIBC_OPTION_POSIX_C_LANG_WIDE_CHAR
+ help
+ This option group includes locale support functions, programs,
+ and libraries. With EGLIBC_OPTION_EGLIBC_LOCALE_CODE disabled,
+ EGLIBC supports only the 'C' locale (also known as 'POSIX'),
+ and ignores the settings of the 'LANG' and 'LC_*' environment
+ variables.
+
+ With EGLIBC_OPTION_EGLIBC_LOCALE_CODE disabled, the following
+ functions are omitted from libc:
+
+ duplocale localeconv nl_langinfo rpmatch strfmon_l
+ freelocale newlocale nl_langinfo_l strfmon uselocale
+
+ Furthermore, only the LC_CTYPE and LC_TIME categories of the
+ standard "C" locale are available.
+
+ The EGLIBC_OPTION_EGLIBC_CATGETS option group depends on this option
+ group; if you disable EGLIBC_OPTION_EGLIBC_LOCALE_CODE, you must also
+ disable EGLIBC_OPTION_EGLIBC_CATGETS.
+
+
+config EGLIBC_OPTION_EGLIBC_MEMUSAGE
+ bool "Memory profiling library"
+ default y
+ help
+ This option group includes the `libmemusage' library and
+ the `memusage' and `memusagestat' utilities.
+ These components provide memory profiling functions.
+
+ EGLIBC_OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE
+
+ Libmemusage library buffers the profiling data in memory
+ before writing it out to disk. By default, the library
+ allocates 1.5M buffer, which can be substantial for some
+ systems. EGLIBC_OPTION_EGLIBC_MEMUSAGE_DEFAULT_BUFFER_SIZE option
+ allows to change the default buffer size. It specifies
+ the number of entries the buffer should have.
+ On most architectures one buffer entry amounts to 48 bytes,
+ so setting this option to the value of 512 will reduce the size of
+ the memory buffer to 24K.
+
+
+config EGLIBC_OPTION_EGLIBC_NIS
+ bool "Support for NIS, NIS+, and the special 'compat' services."
+ default n
+ select EGLIBC_OPTION_EGLIBC_INET
+ select EGLIBC_OPTION_EGLIBC_SUNRPC
+ help
+ This option group includes the NIS, NIS+, and 'compat' Name
+ Service Switch service libraries. When it is disabled, those
+ services libraries are not installed; you should remove any
+ references to them from your 'nsswitch.conf' file.
+
+ This option group depends on the EGLIBC_OPTION_EGLIBC_INET option
+ group; you must enable that to enable this option group.
+
+
+config EGLIBC_OPTION_EGLIBC_NSSWITCH
+ bool "Name service switch (nsswitch) support"
+ default y
+ select EGLIBC_OPTION_EGLIBC_INET
+ help
+
+ This option group includes support for the 'nsswitch' facility.
+ With this option group enabled, all EGLIBC functions for
+ accessing various system databases (passwords and groups;
+ networking; aliases; public keys; and so on) consult the
+ '/etc/nsswitch.conf' configuration file to decide how to handle
+ queries.
+
+ With this option group disabled, EGLIBC uses a fixed list of
+ services to satisfy queries on each database, as requested by
+ configuration files specified when EGLIBC is built. Your
+ 'option-groups.config' file must set the following two
+ variables:
+
+ EGLIBC_OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG
+
+ Set this to the name of a file whose contents observe the
+ same syntax as an ordinary '/etc/nsswitch.conf' file. The
+ EGLIBC build process parses this file just as EGLIBC would
+ at run time if EGLIBC_NSSWITCH were enabled, and
+ produces a C library that uses the nsswitch service
+ libraries to search for database entries as this file
+ specifies, instead of consulting '/etc/nsswitch.conf' at run
+ time.
+
+ This should be an absolute filename. The EGLIBC build
+ process may use it from several different working
+ directories. It may include references to Makefile
+ variables like 'common-objpfx' (the top of the build tree,
+ with a trailing slash), or '..' (the top of the source tree,
+ with a trailing slash).
+
+ The EGLIBC source tree includes a sample configuration file
+ named 'nss/fixed-nsswitch.conf'; for simple configurations,
+ you will probably want to delete references to databases not
+ needed on your system.
+
+ EGLIBC_OPTION_EGLIBC_NSSWITCH_FIXED_FUNCTIONS
+
+ The EGLIBC build process uses this file to decide which
+ functions to make available from which service libraries.
+ The file 'nss/fixed-nsswitch.functions' serves as a sample
+ configuration file for this setting, and explains its syntax
+ and meaning in more detail.
+
+ This should be an absolute file name. The EGLIBC build
+ process may use it from several different working
+ directories. It may include references to Makefile
+ variables like 'common-objpfx' (the top of the build tree,
+ with a trailing slash), or '..' (the top of the source tree,
+ with a trailing slash).
+
+ Be sure to mention each function in each service you wish to
+ use. If you do not mention a service's function here, the
+ EGLIBC database access functions will not find it, even if
+ it is listed in the EGLIBC_OPTION_EGLIBC_NSSWITCH_FIXED_CONFIG
+ file.
+
+ In this arrangement, EGLIBC will not use the 'dlopen' and
+ 'dlsym' functions to find database access functions. Instead,
+ libc hard-codes references to the service libraries' database
+ access functions. You must explicitly link your program
+ against the name service libraries (those whose names start
+ with 'libnss_', in the sysroot's '/lib' directory) whose
+ functions you intend to use. This arrangement helps
+ system-wide static analysis tools decide which functions a
+ system actually uses.
+
+ Note that some nsswitch service libraries require other option
+ groups to be enabled; for example, the EGLIBC_OPTION_EGLIBC_INET
+ option group must be enabled to use the 'libnss_dns.so.2'
+ service library, which uses the Domain Name System network
+ protocol to answer queries.
+
+
+config EGLIBC_OPTION_EGLIBC_RCMD
+ bool "Support for 'rcmd' and related library functions"
+ default y
+ select EGLIBC_OPTION_EGLIBC_INET
+ help
+ This option group includes functions for running commands on
+ remote machines via the 'rsh' protocol, and doing authentication
+ related to those functions. This also includes functions that
+ use the 'rexec' protocol.
+
+ This option group includes the following functions:
+
+ rcmd ruserok
+ rcmd_af ruserok_af
+ rexec iruserok
+ rexec_af iruserok_af
+ rresvport ruserpass
+ rresvport_af
+
+
+config EGLIBC_OPTION_EGLIBC_RTLD_DEBUG
+ bool "Runtime linker debug print outs"
+ default y
+ help
+ This option group enables debug output of the runtime linker
+ which is activated via LD_DEBUG and LD_TRACE_PRELINKING
+ environment variables. Disabling this option group yields
+ a smaller runtime linker binary.
+ BEWARE: Disabling this option group is likely to break
+ the `ldd' utility which may also be used by the prelinker.
+ In particular, the `--unused' ldd option will not work correctly.
+
+
+config EGLIBC_OPTION_EGLIBC_SPAWN
+ bool "Support for POSIX posix_spawn functions"
+ default y
+ help
+ This option group includes the POSIX functions for executing
+ programs in child processes without using 'fork' or 'vfork'.
+
+ This option group includes the following functions:
+
+ posix_spawn
+ posix_spawnattr_destroy
+ posix_spawnattr_getflags
+ posix_spawnattr_getpgroup
+ posix_spawnattr_getschedparam
+ posix_spawnattr_getschedpolicy
+ posix_spawnattr_getsigdefault
+ posix_spawnattr_getsigmask
+ posix_spawnattr_init
+ posix_spawnattr_setflags
+ posix_spawnattr_setpgroup
+ posix_spawnattr_setschedparam
+ posix_spawnattr_setschedpolicy
+ posix_spawnattr_setsigdefault
+ posix_spawnattr_setsigmask
+ posix_spawn_file_actions_addclose
+ posix_spawn_file_actions_adddup2
+ posix_spawn_file_actions_addopen
+ posix_spawn_file_actions_destroy
+ posix_spawn_file_actions_init
+ posix_spawnp
+
+ This option group also provides the ability for the iconv,
+ localedef, and locale programs to operate transparently on
+ compressed charset definitions. When this option group is
+ disabled, those programs will only operate on uncompressed
+ charmap files.
+
+
+config EGLIBC_OPTION_EGLIBC_STREAMS
+ bool "Support for accessing STREAMS."
+ default y
+ help
+ This option group includes functions for reading and writing
+ messages to and from STREAMS. The STREAMS interface provides a
+ uniform mechanism for implementing networking services and other
+ character-based I/O. (STREAMS are not to be confused with
+ <stdio.h> FILE objects, also called 'streams'.)
+
+ This option group includes the following functions:
+
+ getmsg putpmsg
+ getpmsg fattach
+ isastream fdetach
+ putmsg
+
+
+config EGLIBC_OPTION_EGLIBC_SUNRPC
+ bool "Support for the Sun 'RPC' protocol."
+ default n
+ select EGLIBC_OPTION_EGLIBC_INET
+ help
+ This option group includes support for the Sun RPC protocols,
+ including the 'rpcgen' and 'rpcinfo' programs.
+
+
+config EGLIBC_OPTION_EGLIBC_UTMP
+ bool "Older access functions for 'utmp' login records"
+ default y
+ help
+ This option group includes the older 'utent' family of
+ functions for accessing user login records in the 'utmp' file.
+ POSIX omits these functions in favor of the 'utxent' family,
+ and they are obsolete on systems other than Linux.
+
+ This option group includes the following functions:
+
+ endutent
+ getutent
+ getutent_r
+ getutid
+ getutid_r
+ getutline
+ getutline_r
+ logwtmp
+ pututline
+ setutent
+ updwtmp
+ utmpname
+
+ This option group includes the following libraries:
+
+ libutil.so (and libutil.a)
+
+
+config EGLIBC_OPTION_EGLIBC_UTMPX
+ bool "POSIX access functions for 'utmp' login records"
+ default y
+ select EGLIBC_OPTION_EGLIBC_UTMP
+ help
+ This option group includes the POSIX functions for reading and
+ writing user login records in the 'utmp' file (usually
+ '/var/run/utmp'). The POSIX functions operate on 'struct
+ utmpx' structures, as opposed to the family of older 'utent'
+ functions, which operate on 'struct utmp' structures.
+
+ This option group includes the following functions:
+
+ endutxent
+ getutmp
+ getutmpx
+ getutxent
+ getutxid
+ getutxline
+ pututxline
+ setutxent
+ updwtmpx
+ utmpxname
+
+
+config EGLIBC_OPTION_EGLIBC_WORDEXP
+ bool "Shell-style word expansion"
+ default y
+ help
+ This option group includes the 'wordexp' function for
+ performing word expansion in the manner of the shell, and the
+ accompanying 'wordfree' function.
+
+
+config EGLIBC_OPTION_POSIX_C_LANG_WIDE_CHAR
+ bool "ISO C library wide character functions, excluding I/O"
+ default y
+ help
+ This option group includes the functions defined by the ISO C
+ standard for working with wide and multibyte characters in
+ memory. Functions for reading and writing wide and multibyte
+ characters from and to files call in the
+ EGLIBC_OPTION_POSIX_WIDE_CHAR_DEVICE_IO option group.
+
+ This option group includes the following functions:
+
+ btowc mbsinit wcscspn wcstoll
+ iswalnum mbsrtowcs wcsftime wcstombs
+ iswalpha mbstowcs wcslen wcstoul
+ iswblank mbtowc wcsncat wcstoull
+ iswcntrl swprintf wcsncmp wcstoumax
+ iswctype swscanf wcsncpy wcsxfrm
+ iswdigit towctrans wcspbrk wctob
+ iswgraph towlower wcsrchr wctomb
+ iswlower towupper wcsrtombs wctrans
+ iswprint vswprintf wcsspn wctype
+ iswpunct vswscanf wcsstr wmemchr
+ iswspace wcrtomb wcstod wmemcmp
+ iswupper wcscat wcstof wmemcpy
+ iswxdigit wcschr wcstoimax wmemmove
+ mblen wcscmp wcstok wmemset
+ mbrlen wcscoll wcstol
+ mbrtowc wcscpy wcstold
+
+
+config EGLIBC_OPTION_POSIX_REGEXP
+ bool "Regular expressions"
+ default y
+ help
+ This option group includes the POSIX regular expression
+ functions, and the associated non-POSIX extensions and
+ compatibility functions.
+
+ With EGLIBC_OPTION_POSIX_REGEXP disabled, the following functions are
+ omitted from libc:
+
+ re_comp re_max_failures regcomp
+ re_compile_fastmap re_search regerror
+ re_compile_pattern re_search_2 regexec
+ re_exec re_set_registers regfree
+ re_match re_set_syntax rpmatch
+ re_match_2 re_syntax_options
+
+ Furthermore, the compatibility regexp interface defined in the
+ <regexp.h> header file, 'compile', 'step', and 'advance', is
+ omitted.
+
+
+config EGLIBC_OPTION_POSIX_REGEXP_GLIBC
+ bool "Regular expressions from GLIBC"
+ default y
+ select EGLIBC_OPTION_POSIX_REGEXP
+ help
+ This option group specifies which regular expression
+ library to use. The choice is between regex
+ implementation from GLIBC and regex implementation from
+ libiberty. The GLIBC variant is fully POSIX conformant and
+ optimized for speed; regex from libiberty is more than twice
+ as small while still is enough for most practical purposes.
+
+
+config EGLIBC_OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+ bool "Input and output functions for wide characters"
+ default y
+ select EGLIBC_OPTION_POSIX_C_LANG_WIDE_CHAR
+ help
+ This option group includes functions for reading and writing
+ wide characters to and from <stdio.h> streams.
+
+ This option group includes the following functions:
+
+ fgetwc fwprintf putwchar vwscanf
+ fgetws fwscanf ungetwc wprintf
+ fputwc getwc vfwprintf wscanf
+ fputws getwchar vfwscanf
+ fwide putwc vwprintf
+
+ This option group further includes the following unlocked
+ variants of the above functions:
+
+ fgetwc_unlocked getwc_unlocked
+ fgetws_unlocked getwchar_unlocked
+ fputwc_unlocked putwc_unlocked
+ fputws_unlocked putwchar_unlocked
+
+ Note that the GNU standard C++ library, 'libstdc++.so', uses
+ some of these functions; you will not be able to link or run
+ C++ programs if you disable this option group.
+
+ This option group also affects the behavior of the following
+ functions:
+
+ fdopen
+ fopen
+ fopen64
+ freopen
+ freopen64
+
+ These functions all take an OPENTYPE parameter which may
+ contain a string of the form ",ccs=CHARSET", indicating that
+ the underlying file uses the character set named CHARSET.
+ This produces a wide-oriented stream, which is only useful
+ when the functions included in this option group are present.
+ If the user attempts to open a file specifying a character set
+ in the OPENTYPE parameter, and EGLIBC was built with this
+ option group disabled, the function returns NULL, and sets
+ errno to EINVAL.
diff --git a/toolchain/glibc/headers/Makefile b/toolchain/glibc/headers/Makefile
new file mode 100644
index 0000000..f9f411b
--- /dev/null
+++ b/toolchain/glibc/headers/Makefile
@@ -0,0 +1,27 @@
+PATH_PREFIX:=..
+VARIANT:=headers
+
+include ../common.mk
+
+define Host/Compile
+
+endef
+
+define Host/Install
+ $(call Host/SetToolchainInfo)
+ mkdir -p $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/{include,lib}
+ $(MAKE) -C $(CUR_BUILD_DIR) \
+ BUILD_CFLAGS="$(HOST_CFLAGS)" \
+ install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
+ install-bootstrap-headers=yes \
+ install-headers
+ $(MAKE) -C $(CUR_BUILD_DIR) \
+ csu/subdir_lib
+ ( cd $(CUR_BUILD_DIR); \
+ $(CP) csu/crt1.o csu/crti.o csu/crtn.o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/lib/ \
+ )
+ $(TARGET_CC) -nostdlib -nostartfiles -shared -x c /dev/null \
+ -o $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/lib/libc.so
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/glibc/include/libintl.h b/toolchain/glibc/include/libintl.h
new file mode 100644
index 0000000..69cb887
--- /dev/null
+++ b/toolchain/glibc/include/libintl.h
@@ -0,0 +1,6 @@
+#ifndef __FAKE_LIBINTL_H
+#define __FAKE_LIBINTL_H
+
+#define _(X) (X)
+
+#endif
diff --git a/toolchain/glibc/patches/2.15/001-fix_autoconf_macro.patch b/toolchain/glibc/patches/2.15/001-fix_autoconf_macro.patch
new file mode 100644
index 0000000..55b26c7
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/001-fix_autoconf_macro.patch
@@ -0,0 +1,48 @@
+--- a/libc/aclocal.m4
++++ b/libc/aclocal.m4
+@@ -88,6 +88,12 @@
+ fi
+ rm -fr contest*])
+
++dnl Test a compiler option or options with an empty input file.
++dnl LIBC_TRY_CC_OPTION([options], [action-if-true], [action-if-false])
++AC_DEFUN([LIBC_TRY_CC_OPTION],
++[AS_IF([AC_TRY_COMMAND([${CC-cc} $1 -xc /dev/null -S -o /dev/null])],
++ [$2], [$3])])
++
+ AC_DEFUN([LIBC_PROG_BINUTILS],
+ [# Was a --with-binutils option given?
+ if test -n "$path_binutils"; then
+--- a/libc/configure
++++ b/libc/configure
+@@ -7404,7 +7404,14 @@
+ else
+ libc_cv_cc_nofma=
+ for opt in -ffp-contract=off -mno-fused-madd; do
+- LIBC_TRY_CC_OPTION($opt, libc_cv_cc_nofma=$opt; break)
++ if { ac_try='${CC-cc} $opt -xc /dev/null -S -o /dev/null'
++ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++ test $ac_status = 0; }; }; then :
++ libc_cv_cc_nofma=$opt; break
++fi
+ done
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_nofma" >&5
+--- a/libc/configure.in
++++ b/libc/configure.in
+@@ -2238,10 +2238,9 @@
+ libc_cv_cc_submachine, [dnl
+ libc_cv_cc_submachine=no
+ for opt in "-march=$submachine" "-mcpu=$submachine"; do
+- if AC_TRY_COMMAND([${CC-cc} $opt -xc /dev/null -S -o /dev/null]); then
++ LIBC_TRY_CC_OPTION([$opt], [
+ libc_cv_cc_submachine="$opt"
+- break
+- fi
++ break], [])
+ done])
+ if test "x$libc_cv_cc_submachine" = xno; then
+ AC_MSG_ERROR([${CC-cc} does not support $submachine])
diff --git a/toolchain/glibc/patches/2.15/005-versions.patch b/toolchain/glibc/patches/2.15/005-versions.patch
new file mode 100644
index 0000000..da9d2ba
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/005-versions.patch
@@ -0,0 +1,11 @@
+--- a/libc/configure.in
++++ b/libc/configure.in
+@@ -1037,7 +1037,7 @@
+ critic_missing="$critic_missing gcc")
+ AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
+ [GNU Make[^0-9]*\([0-9][0-9.]*\)],
+- [3.79* | 3.[89]*], critic_missing="$critic_missing make")
++ [3.79* | 3.[89]* | 4.* ], critic_missing="$critic_missing make")
+
+ AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
+ [GNU gettext.* \([0-9]*\.[0-9.]*\)],
diff --git a/toolchain/glibc/patches/2.15/050-all_glibc-2.14-leak-revert-crash.patch b/toolchain/glibc/patches/2.15/050-all_glibc-2.14-leak-revert-crash.patch
new file mode 100644
index 0000000..d1e19aa
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/050-all_glibc-2.14-leak-revert-crash.patch
@@ -0,0 +1,110 @@
+partially revert commit 4bff6e0175ed195871f4e01cc4c4c33274b8f6e3 - caused segmentation faults in dlopen
+
+References:
+http://comments.gmane.org/gmane.comp.lib.glibc.user/1227
+http://sourceware.org/ml/libc-alpha/2011-06/msg00006.html
+
+diff --git a/libc/elf/dl-close.c b/libc/elf/dl-close.c
+index 4b17bf8..733cc1b 100644
+--- a/libc/elf/dl-close.c
++++ b/libc/elf/dl-close.c
+@@ -119,17 +119,8 @@ _dl_close_worker (struct link_map *map)
+ if (map->l_direct_opencount > 0 || map->l_type != lt_loaded
+ || dl_close_state != not_pending)
+ {
+- if (map->l_direct_opencount == 0)
+- {
+- if (map->l_type == lt_loaded)
+- dl_close_state = rerun;
+- else if (map->l_type == lt_library)
+- {
+- struct link_map **oldp = map->l_initfini;
+- map->l_initfini = map->l_orig_initfini;
+- _dl_scope_free (oldp);
+- }
+- }
++ if (map->l_direct_opencount == 0 && map->l_type == lt_loaded)
++ dl_close_state = rerun;
+
+ /* There are still references to this object. Do nothing more. */
+ if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_FILES, 0))
+diff --git a/libc/elf/dl-deps.c b/libc/elf/dl-deps.c
+index 51cb2fa..eddcbf0 100644
+--- a/libc/elf/dl-deps.c
++++ b/libc/elf/dl-deps.c
+@@ -489,6 +489,7 @@ _dl_map_object_deps (struct link_map *map,
+ nneeded * sizeof needed[0]);
+ atomic_write_barrier ();
+ l->l_initfini = l_initfini;
++ l->l_free_initfini = 1;
+ }
+
+ /* If we have no auxiliary objects just go on to the next map. */
+@@ -689,6 +690,7 @@ Filters not supported with LD_TRACE_PRELINKING"));
+ l_initfini[nlist] = NULL;
+ atomic_write_barrier ();
+ map->l_initfini = l_initfini;
++ map->l_free_initfini = 1;
+ if (l_reldeps != NULL)
+ {
+ atomic_write_barrier ();
+@@ -697,7 +699,7 @@ Filters not supported with LD_TRACE_PRELINKING"));
+ _dl_scope_free (old_l_reldeps);
+ }
+ if (old_l_initfini != NULL)
+- map->l_orig_initfini = old_l_initfini;
++ _dl_scope_free (old_l_initfini);
+
+ if (errno_reason)
+ _dl_signal_error (errno_reason == -1 ? 0 : errno_reason, objname,
+diff --git a/libc/elf/dl-libc.c b/libc/elf/dl-libc.c
+index f44fa10..7563093 100644
+--- a/libc/elf/dl-libc.c
++++ b/libc/elf/dl-libc.c
+@@ -284,6 +284,10 @@ libc_freeres_fn (free_mem)
+ if (! old->dont_free)
+ free (old);
+ }
++
++ /* Free the initfini dependency list. */
++ if (l->l_free_initfini)
++ free (l->l_initfini);
+ }
+
+ if (__builtin_expect (GL(dl_ns)[ns]._ns_global_scope_alloc, 0) != 0
+diff --git a/libc/elf/rtld.c b/libc/elf/rtld.c
+index b93a01f..2fc83ce 100644
+--- a/libc/elf/rtld.c
++++ b/libc/elf/rtld.c
+@@ -2277,6 +2277,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
+ lnp->dont_free = 1;
+ lnp = lnp->next;
+ }
++ l->l_free_initfini = 0;
+
+ if (l != &GL(dl_rtld_map))
+ _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0,
+diff --git a/libc/include/link.h b/libc/include/link.h
+index e877104..b1b4065 100644
+--- a/libc/include/link.h
++++ b/libc/include/link.h
+@@ -192,6 +192,9 @@ struct link_map
+ during LD_TRACE_PRELINKING=1
+ contains any DT_SYMBOLIC
+ libraries. */
++ unsigned int l_free_initfini:1; /* Nonzero if l_initfini can be
++ freed, ie. not allocated with
++ the dummy malloc in ld.so. */
+
+ /* Collected information about own RPATH directories. */
+ struct r_search_path_struct l_rpath_dirs;
+@@ -240,9 +243,6 @@ struct link_map
+
+ /* List of object in order of the init and fini calls. */
+ struct link_map **l_initfini;
+- /* The init and fini list generated at startup, saved when the
+- object is also loaded dynamically. */
+- struct link_map **l_orig_initfini;
+
+ /* List of the dependencies introduced through symbol binding. */
+ struct link_map_reldeps
diff --git a/toolchain/glibc/patches/2.15/100-fix_cross_rpcgen.patch b/toolchain/glibc/patches/2.15/100-fix_cross_rpcgen.patch
new file mode 100644
index 0000000..8fe5cf3
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/100-fix_cross_rpcgen.patch
@@ -0,0 +1,71 @@
+--- a/libc/sunrpc/proto.h
++++ b/libc/sunrpc/proto.h
+@@ -56,12 +56,14 @@ void add_type(int len, const char *type)
+ $build's C library and $host's GLIBC. */
+ #ifdef _CROSS_RPCGEN_
+
++#undef stpcpy
++
+ /* Rather then defining _GNU_SOURCE before including $build's <string.h>
+ we just declare stpcpy here. */
+ extern char *stpcpy (char *, const char *);
+
+-/* Use $build's i18n support as we can't use $host's. */
+-#define _(X) (gettext (X))
++/* Do not use i18n support */
++#define _(X) (X)
+
+ /* rpcgen sources check for __GNU_LIBRARY__ to tweak for GLIBC code
+ that rpcgen generates. The proper fix would be to rename all those checks
+--- a/libc/sunrpc/rpc/types.h
++++ b/libc/sunrpc/rpc/types.h
+@@ -70,18 +70,23 @@ typedef unsigned long rpcport_t;
+ #endif
+
+ #ifndef __u_char_defined
+-typedef __u_char u_char;
+-typedef __u_short u_short;
+-typedef __u_int u_int;
+-typedef __u_long u_long;
+-typedef __quad_t quad_t;
+-typedef __u_quad_t u_quad_t;
+-typedef __fsid_t fsid_t;
++typedef unsigned char u_char;
++typedef unsigned short u_short;
++typedef unsigned int u_int;
++typedef unsigned long u_long;
++#if __WORDSIZE == 64
++typedef long int quad_t;
++typedef unsigned long int u_quad_t;
++#elif defined __GLIBC_HAVE_LONG_LONG
++typedef long long int quad_t;
++typedef unsigned long long int u_quad_t;
++#endif
++typedef u_quad_t fsid_t;
+ # define __u_char_defined
+ #endif
+-#ifndef __daddr_t_defined
+-typedef __daddr_t daddr_t;
+-typedef __caddr_t caddr_t;
++#if !defined(__daddr_t_defined) && defined(linux)
++typedef long int daddr_t;
++typedef char *caddr_t;
+ # define __daddr_t_defined
+ #endif
+
+--- a/libc/sunrpc/rpc_main.c
++++ b/libc/sunrpc/rpc_main.c
+@@ -997,9 +997,10 @@ mkfile_output (struct commandline *cmd)
+ abort ();
+ temp = rindex (cmd->infile, '.');
+ cp = stpcpy (mkfilename, "Makefile.");
+- if (temp != NULL)
+- *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0';
+- else
++ if (temp != NULL) {
++ strncpy(cp, cmd->infile, temp - cmd->infile);
++ cp[temp - cmd->infile - 1] = 0;
++ } else
+ stpcpy (cp, cmd->infile);
+
+ }
diff --git a/toolchain/glibc/patches/2.15/110-fix_cross_zic.patch b/toolchain/glibc/patches/2.15/110-fix_cross_zic.patch
new file mode 100644
index 0000000..221eb28
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/110-fix_cross_zic.patch
@@ -0,0 +1,27 @@
+--- a/libc/timezone/zic.c
++++ b/libc/timezone/zic.c
+@@ -8,6 +8,8 @@ static char elsieid[] = "@(#)zic.c 8.19"
+ #ifdef CROSS_ZIC
+ #define REPORT_BUGS_TO ""
+ #define PKGVERSION ""
++#undef _
++#define _(X) (X)
+ #else
+ #include "config.h"
+ #endif
+@@ -490,6 +492,7 @@ char * argv[];
+ #ifdef unix
+ (void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
+ #endif /* defined unix */
++#ifndef CROSS_ZIC
+ #if HAVE_GETTEXT
+ (void) setlocale(LC_ALL, "");
+ #ifdef TZ_DOMAINDIR
+@@ -497,6 +500,7 @@ char * argv[];
+ #endif /* defined TEXTDOMAINDIR */
+ (void) textdomain(TZ_DOMAIN);
+ #endif /* HAVE_GETTEXT */
++#endif
+ progname = argv[0];
+ if (TYPE_BIT(zic_t) < 64) {
+ (void) fprintf(stderr, "%s: %s\n", progname,
diff --git a/toolchain/glibc/patches/2.15/120-use_host_cflags.patch b/toolchain/glibc/patches/2.15/120-use_host_cflags.patch
new file mode 100644
index 0000000..4c58fb4
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/120-use_host_cflags.patch
@@ -0,0 +1,22 @@
+--- a/libc/sunrpc/Makefile
++++ b/libc/sunrpc/Makefile
+@@ -175,7 +175,7 @@ $(objpfx)rpcgen: $(addprefix $(objpfx),$
+ $(+link)
+
+ $(addprefix $(objpfx)cross-,$(rpcgen-objs)): $(objpfx)cross-%.o: %.c
+- gcc $< -c -D_RPC_THREAD_SAFE_ -D_CROSS_RPCGEN_ \
++ gcc $< -c -D_RPC_THREAD_SAFE_ -D_CROSS_RPCGEN_ $(HOST_CFLAGS) \
+ $(OUTPUT_OPTION) $(compile-mkdep-flags)
+
+ $(objpfx)cross-rpcgen: $(addprefix $(objpfx)cross-,$(rpcgen-objs))
+--- a/libc/timezone/Makefile
++++ b/libc/timezone/Makefile
+@@ -182,7 +182,7 @@ $(objpfx)zic: $(addprefix $(objpfx), $(z
+
+ $(addprefix $(objpfx)cross-,$(zic-objs)): $(objpfx)cross-%.o: %.c
+ gcc $< -c $(OUTPUT_OPTION) $(CFLAGS-$*.c) $(CPPFLAGS-$*) \
+- -DCROSS_ZIC $(compile-mkdep-flags)
++ -DCROSS_ZIC $(HOST_CFLAGS) $(compile-mkdep-flags)
+
+ $(objpfx)cross-zic: $(addprefix $(objpfx)cross-,$(zic-objs))
+ gcc $(addprefix $(objpfx)cross-,$(zic-objs)) -o $@
diff --git a/toolchain/glibc/patches/2.15/200-add-dl-search-paths.patch b/toolchain/glibc/patches/2.15/200-add-dl-search-paths.patch
new file mode 100644
index 0000000..70e7e60
--- /dev/null
+++ b/toolchain/glibc/patches/2.15/200-add-dl-search-paths.patch
@@ -0,0 +1,14 @@
+add /usr/lib to default search path for the dynamic linker
+
+--- a/libc/Makeconfig
++++ b/libc/Makeconfig
+@@ -539,6 +539,9 @@
+ default-rpath = $(libdir)
+ endif
+
++# Add /usr/lib to default search path for the dynamic linker
++user-defined-trusted-dirs := /usr/lib
++
+ ifndef link-extra-libs
+ link-extra-libs = $(LDLIBS-$(@F))
+ link-extra-libs-static = $(link-extra-libs)
diff --git a/toolchain/glibc/patches/2.19/100-fix_cross_rpcgen.patch b/toolchain/glibc/patches/2.19/100-fix_cross_rpcgen.patch
new file mode 100644
index 0000000..5c0d45b
--- /dev/null
+++ b/toolchain/glibc/patches/2.19/100-fix_cross_rpcgen.patch
@@ -0,0 +1,52 @@
+--- a/libc/sunrpc/rpc/types.h
++++ b/libc/sunrpc/rpc/types.h
+@@ -75,18 +75,23 @@ typedef unsigned long rpcport_t;
+ #endif
+
+ #ifndef __u_char_defined
+-typedef __u_char u_char;
+-typedef __u_short u_short;
+-typedef __u_int u_int;
+-typedef __u_long u_long;
+-typedef __quad_t quad_t;
+-typedef __u_quad_t u_quad_t;
+-typedef __fsid_t fsid_t;
++typedef unsigned char u_char;
++typedef unsigned short u_short;
++typedef unsigned int u_int;
++typedef unsigned long u_long;
++#if __WORDSIZE == 64
++typedef long int quad_t;
++typedef unsigned long int u_quad_t;
++#elif defined __GLIBC_HAVE_LONG_LONG
++typedef long long int quad_t;
++typedef unsigned long long int u_quad_t;
++#endif
++typedef u_quad_t fsid_t;
+ # define __u_char_defined
+ #endif
+-#ifndef __daddr_t_defined
+-typedef __daddr_t daddr_t;
+-typedef __caddr_t caddr_t;
++#if !defined(__daddr_t_defined) && defined(linux)
++typedef long int daddr_t;
++typedef char *caddr_t;
+ # define __daddr_t_defined
+ #endif
+
+--- a/libc/sunrpc/rpc_main.c
++++ b/libc/sunrpc/rpc_main.c
+@@ -958,9 +958,10 @@ mkfile_output (struct commandline *cmd)
+ abort ();
+ temp = rindex (cmd->infile, '.');
+ cp = stpcpy (mkfilename, "Makefile.");
+- if (temp != NULL)
+- *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0';
+- else
++ if (temp != NULL) {
++ strncpy(cp, cmd->infile, temp - cmd->infile);
++ cp[temp - cmd->infile - 1] = 0;
++ } else
+ stpcpy (cp, cmd->infile);
+
+ }
diff --git a/toolchain/glibc/patches/2.19/200-add-dl-search-paths.patch b/toolchain/glibc/patches/2.19/200-add-dl-search-paths.patch
new file mode 100644
index 0000000..fa192ca
--- /dev/null
+++ b/toolchain/glibc/patches/2.19/200-add-dl-search-paths.patch
@@ -0,0 +1,14 @@
+add /usr/lib to default search path for the dynamic linker
+
+--- a/libc/Makeconfig
++++ b/libc/Makeconfig
+@@ -501,6 +501,9 @@ else
+ default-rpath = $(libdir)
+ endif
+
++# Add /usr/lib to default search path for the dynamic linker
++user-defined-trusted-dirs := /usr/lib
++
+ ifndef link-extra-libs
+ link-extra-libs = $(LDLIBS-$(@F))
+ link-extra-libs-static = $(link-extra-libs)
diff --git a/toolchain/glibc/patches/2.19/300-require-autoconf-2.69.patch b/toolchain/glibc/patches/2.19/300-require-autoconf-2.69.patch
new file mode 100644
index 0000000..623885c
--- /dev/null
+++ b/toolchain/glibc/patches/2.19/300-require-autoconf-2.69.patch
@@ -0,0 +1,13 @@
+Index: eglibc-2.19-r25243/libc/aclocal.m4
+===================================================================
+--- eglibc-2.19-r25243.orig/libc/aclocal.m4 2013-11-06 15:03:08.000000000 -0800
++++ eglibc-2.19-r25243/libc/aclocal.m4 2014-11-22 15:43:05.343256863 -0800
+@@ -1,7 +1,7 @@
+ dnl We require that everyone use exactly the same Autoconf version so that
+ dnl the internal functions defined and used by the main configure script
+ dnl match those expected by the fragments.
+-m4_define([GLIBC_AUTOCONF_VERSION], [2.68])
++m4_define([GLIBC_AUTOCONF_VERSION], [2.69])
+ m4_if(m4_defn([AC_AUTOCONF_VERSION]), GLIBC_AUTOCONF_VERSION, [],
+ [m4_fatal(m4_flatten(
+ Exactly version GLIBC_AUTOCONF_VERSION of Autoconf is required but you have
diff --git a/toolchain/glibc/patches/2.21/100-fix_cross_rpcgen.patch b/toolchain/glibc/patches/2.21/100-fix_cross_rpcgen.patch
new file mode 100644
index 0000000..6a5e537
--- /dev/null
+++ b/toolchain/glibc/patches/2.21/100-fix_cross_rpcgen.patch
@@ -0,0 +1,52 @@
+--- a/sunrpc/rpc/types.h
++++ b/sunrpc/rpc/types.h
+@@ -75,18 +75,23 @@ typedef unsigned long rpcport_t;
+ #endif
+
+ #ifndef __u_char_defined
+-typedef __u_char u_char;
+-typedef __u_short u_short;
+-typedef __u_int u_int;
+-typedef __u_long u_long;
+-typedef __quad_t quad_t;
+-typedef __u_quad_t u_quad_t;
+-typedef __fsid_t fsid_t;
++typedef unsigned char u_char;
++typedef unsigned short u_short;
++typedef unsigned int u_int;
++typedef unsigned long u_long;
++#if __WORDSIZE == 64
++typedef long int quad_t;
++typedef unsigned long int u_quad_t;
++#elif defined __GLIBC_HAVE_LONG_LONG
++typedef long long int quad_t;
++typedef unsigned long long int u_quad_t;
++#endif
++typedef u_quad_t fsid_t;
+ # define __u_char_defined
+ #endif
+-#ifndef __daddr_t_defined
+-typedef __daddr_t daddr_t;
+-typedef __caddr_t caddr_t;
++#if !defined(__daddr_t_defined) && defined(linux)
++typedef long int daddr_t;
++typedef char *caddr_t;
+ # define __daddr_t_defined
+ #endif
+
+--- a/sunrpc/rpc_main.c
++++ b/sunrpc/rpc_main.c
+@@ -958,9 +958,10 @@ mkfile_output (struct commandline *cmd)
+ abort ();
+ temp = rindex (cmd->infile, '.');
+ cp = stpcpy (mkfilename, "Makefile.");
+- if (temp != NULL)
+- *((char *) stpncpy (cp, cmd->infile, temp - cmd->infile)) = '\0';
+- else
++ if (temp != NULL) {
++ strncpy(cp, cmd->infile, temp - cmd->infile);
++ cp[temp - cmd->infile - 1] = 0;
++ } else
+ stpcpy (cp, cmd->infile);
+
+ }
diff --git a/toolchain/glibc/patches/2.21/200-add-dl-search-paths.patch b/toolchain/glibc/patches/2.21/200-add-dl-search-paths.patch
new file mode 100644
index 0000000..a6200f7
--- /dev/null
+++ b/toolchain/glibc/patches/2.21/200-add-dl-search-paths.patch
@@ -0,0 +1,14 @@
+add /usr/lib to default search path for the dynamic linker
+
+--- a/Makeconfig
++++ b/Makeconfig
+@@ -501,6 +501,9 @@ else
+ default-rpath = $(libdir)
+ endif
+
++# Add /usr/lib to default search path for the dynamic linker
++user-defined-trusted-dirs := /usr/lib
++
+ ifndef link-extra-libs
+ link-extra-libs = $(LDLIBS-$(@F))
+ link-extra-libs-static = $(link-extra-libs)
diff --git a/toolchain/info.mk b/toolchain/info.mk
new file mode 100644
index 0000000..4f311c5
--- /dev/null
+++ b/toolchain/info.mk
@@ -0,0 +1,6 @@
+TARGET_CROSS=
+GCC_VERSION=unknown
+LIBC_TYPE=unknown
+LIBC_URL=unknown
+LIBC_VERSION=unknown
+LIBC_SO_VERSION=unknown
diff --git a/toolchain/insight/Makefile b/toolchain/insight/Makefile
new file mode 100644
index 0000000..3744f56
--- /dev/null
+++ b/toolchain/insight/Makefile
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=insight
+PKG_VERSION:=6.8-1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)a.tar.bz2
+PKG_MD5SUM:=f7dd764a102beb75c2bb6b8d83455f8e
+PKG_SOURCE_URL:=ftp://sourceware.org/pub/insight/releases
+PKG_CAT:=bzcat
+
+STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
+BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
+
+include $(INCLUDE_DIR)/host-build.mk
+
+define Host/Configure
+ (cd $(HOST_BUILD_DIR); \
+ gdb_cv_func_sigsetjmp=yes \
+ CFLAGS="-O2" \
+ $(HOST_BUILD_DIR)/configure \
+ --prefix=$(TOOLCHAIN_DIR) \
+ --build=$(GNU_HOST_NAME) \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --enable-threads \
+ --enable-werror=no \
+ );
+endef
+
+define Host/Compile
+ $(MAKE) -C $(HOST_BUILD_DIR)
+endef
+
+define Host/Install
+ mkdir -p $(TOOLCHAIN_DIR)/bin
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/gdb/insight $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)insight
+ ln -fs $(TARGET_CROSS)insight $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-insight
+ strip $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)insight
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)insight \
+ $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-insight
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/insight/patches/600-fix-compile-flag-mismatch.patch b/toolchain/insight/patches/600-fix-compile-flag-mismatch.patch
new file mode 100644
index 0000000..13b72bb
--- /dev/null
+++ b/toolchain/insight/patches/600-fix-compile-flag-mismatch.patch
@@ -0,0 +1,31 @@
+--- a/gdb/gdbserver/configure
++++ b/gdb/gdbserver/configure
+@@ -1239,7 +1239,7 @@
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+- if test "x$ac_old_val" != "x$ac_new_val"; then
++ if test "`echo x$ac_old_val`" != "`echo x$ac_new_val`"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+ echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+--- a/gdb/configure
++++ b/gdb/configure
+@@ -272,7 +272,7 @@
+ PACKAGE_BUGREPORT=
+
+ ac_unique_file="main.c"
+-ac_subdirs_all="$ac_subdirs_all doc testsuite"
++ac_subdirs_all="$ac_subdirs_all doc"
+ # Factoring default headers for most tests.
+ ac_includes_default="\
+ #include <stdio.h>
+@@ -3077,7 +3077,7 @@
+
+
+
+-subdirs="$subdirs doc testsuite"
++subdirs="$subdirs doc"
+
+
+ # Provide defaults for some variables set by the per-host and per-target
diff --git a/toolchain/kernel-headers/Makefile b/toolchain/kernel-headers/Makefile
new file mode 100644
index 0000000..90f8eb1
--- /dev/null
+++ b/toolchain/kernel-headers/Makefile
@@ -0,0 +1,100 @@
+#
+# Copyright (C) 2006-2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+KERNEL_BUILD_DIR := $(BUILD_DIR_TOOLCHAIN)
+BUILD_DIR := $(KERNEL_BUILD_DIR)
+
+override QUILT:=
+override HOST_QUILT:=
+
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=linux
+PKG_VERSION:=$(LINUX_VERSION)
+PKG_SOURCE:=$(LINUX_SOURCE)
+PKG_SOURCE_URL:=$(LINUX_SITE)
+HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
+PKG_MD5SUM:=$(LINUX_KERNEL_MD5SUM)
+LINUX_DIR := $(HOST_BUILD_DIR)
+FILES_DIR :=
+PATCH_DIR := ./patches$(if $(wildcard ./patches-$(LINUX_VERSION)),-$(LINUX_VERSION))
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+include $(INCLUDE_DIR)/kernel-defaults.mk
+
+ifeq ($(strip $(BOARD)),uml)
+ LINUX_KARCH:=$(subst x86_64,x86,$(subst i386,x86,$(ARCH)))
+endif
+
+HOST_EXTRACFLAGS=
+
+LINUX_HAS_HEADERS_INSTALL:=y
+
+KMAKE := $(MAKE) -C $(HOST_BUILD_DIR) \
+ HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \
+ ARCH=$(LINUX_KARCH) \
+ CC="$(KERNEL_CC)" \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ CROSS_COMPILE=$(TARGET_CROSS) \
+ KBUILD_HAVE_NLS=no \
+ CONFIG_SHELL=$(BASH)
+
+define Host/Configure/all
+ mkdir -p $(BUILD_DIR_TOOLCHAIN)/linux-dev
+ $(KMAKE) \
+ INSTALL_HDR_PATH="$(BUILD_DIR_TOOLCHAIN)/linux-dev/" \
+ headers_install
+endef
+
+# XXX: the following is needed to build lzma-loader
+ifneq ($(CONFIG_mips)$(CONFIG_mipsel),)
+ define Host/Configure/lzma
+ $(CP) \
+ $(HOST_BUILD_DIR)/arch/mips/include/asm/asm.h \
+ $(HOST_BUILD_DIR)/arch/mips/include/asm/regdef.h \
+ $(if $(call kernel_patchver_ge,3.15.0),$(HOST_BUILD_DIR)/arch/mips/include/asm/asm-eva.h) \
+ $(BUILD_DIR_TOOLCHAIN)/linux-dev/include/asm/
+ endef
+endif
+
+define Host/Configure/post/mips
+ $(call Host/Configure/lzma)
+endef
+
+define Host/Configure/post/mipsel
+ $(call Host/Configure/lzma)
+endef
+
+define Host/Prepare
+ $(call Kernel/Prepare/Default)
+ ln -sf linux-$(LINUX_VERSION) $(BUILD_DIR_TOOLCHAIN)/linux
+ $(SED) 's/@expr length/@-expr length/' $(HOST_BUILD_DIR)/Makefile
+endef
+
+define Host/Configure
+ env
+ yes '' | $(KMAKE) oldconfig
+ $(call Host/Configure/all)
+ $(call Host/Configure/post/$(ARCH))
+endef
+
+define Host/Compile
+endef
+
+define Host/Install
+ $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(TOOLCHAIN_DIR)/
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(BUILD_DIR_TOOLCHAIN)/linux \
+ $(BUILD_DIR_TOOLCHAIN)/linux-dev
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/musl/Config.in b/toolchain/musl/Config.in
new file mode 100644
index 0000000..05caa6a
--- /dev/null
+++ b/toolchain/musl/Config.in
@@ -0,0 +1,6 @@
+# Debug version.
+
+config MUSL_ENABLE_DEBUG
+ bool "Build with debug information"
+ depends on TOOLCHAINOPTS && USE_MUSL
+ default n
diff --git a/toolchain/musl/Config.version b/toolchain/musl/Config.version
new file mode 100644
index 0000000..72236db
--- /dev/null
+++ b/toolchain/musl/Config.version
@@ -0,0 +1,8 @@
+if USE_MUSL
+
+config MUSL_VERSION
+ string
+ depends on USE_MUSL
+ default "1.1.11"
+
+endif
diff --git a/toolchain/musl/Makefile b/toolchain/musl/Makefile
new file mode 100644
index 0000000..1533f51
--- /dev/null
+++ b/toolchain/musl/Makefile
@@ -0,0 +1,31 @@
+PATH_PREFIX=.
+
+include ./common.mk
+
+HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
+HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.musl_installed
+
+HOST_BUILD_PARALLEL:=1
+
+MUSL_MAKEOPTS = -C $(HOST_BUILD_DIR) \
+ DESTDIR="$(TOOLCHAIN_DIR)/" \
+ LIBCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))"
+
+define Host/SetToolchainInfo
+ $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.musl-libc.org/,' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(LIBC_SO_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+endef
+
+define Host/Compile
+ +$(MAKE) $(HOST_JOBS) $(MUSL_MAKEOPTS) all
+endef
+
+define Host/Install
+ $(call Host/SetToolchainInfo)
+ $(MAKE) $(MUSL_MAKEOPTS) DESTDIR="$(TOOLCHAIN_DIR)/" install
+ $(CP) ./include $(TOOLCHAIN_DIR)/
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/musl/common.mk b/toolchain/musl/common.mk
new file mode 100644
index 0000000..3045c63
--- /dev/null
+++ b/toolchain/musl/common.mk
@@ -0,0 +1,69 @@
+#
+# Copyright (C) 2012-2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/target.mk
+
+PKG_NAME:=musl
+PKG_VERSION:=$(call qstrip,$(CONFIG_MUSL_VERSION))
+PKG_RELEASE=1
+
+PKG_MD5SUM:=48be0777e32f374d387e9cf85e36ec4d
+
+PKG_SOURCE_URL:=http://www.musl-libc.org/releases
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+LIBC_SO_VERSION:=$(PKG_VERSION)
+PATCH_DIR:=$(PATH_PREFIX)/patches
+
+HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+include $(INCLUDE_DIR)/hardening.mk
+
+# Please see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67260
+ifeq ($(CONFIG_sh3),y)
+TARGET_CFLAGS+= \
+ -fno-optimize-sibling-calls
+endif
+
+MUSL_CONFIGURE:= \
+ $(TARGET_CONFIGURE_OPTS) \
+ CFLAGS="$(TARGET_CFLAGS)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ $(HOST_BUILD_DIR)/configure \
+ --prefix=/ \
+ --host=$(GNU_HOST_NAME) \
+ --target=$(REAL_GNU_TARGET_NAME) \
+ --disable-gcc-wrapper
+
+ifeq ($(CONFIG_MUSL_ENABLE_DEBUG),y)
+MUSL_CONFIGURE+= \
+ --enable-debug
+endif
+
+define Host/Prepare
+ $(call Host/Prepare/Default)
+ $(if $(strip $(QUILT)), \
+ cd $(HOST_BUILD_DIR); \
+ if $(QUILT_CMD) next >/dev/null 2>&1; then \
+ $(QUILT_CMD) push -a; \
+ fi
+ )
+ ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+endef
+
+define Host/Configure
+ ( cd $(HOST_BUILD_DIR); rm -f config.cache; \
+ $(MUSL_CONFIGURE) \
+ );
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
+ $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
+endef
diff --git a/toolchain/musl/headers/Makefile b/toolchain/musl/headers/Makefile
new file mode 100644
index 0000000..21e6b3b
--- /dev/null
+++ b/toolchain/musl/headers/Makefile
@@ -0,0 +1,16 @@
+PATH_PREFIX:=..
+
+include ../common.mk
+
+HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.headers_built
+HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc_headers_installed
+
+define Host/Compile
+
+endef
+
+define Host/Install
+endef
+
+$(eval $(call HostBuild))
+
diff --git a/toolchain/musl/include/bits/wordsize.h b/toolchain/musl/include/bits/wordsize.h
new file mode 100644
index 0000000..2d4cbe8
--- /dev/null
+++ b/toolchain/musl/include/bits/wordsize.h
@@ -0,0 +1 @@
+#include <sys/user.h>
diff --git a/toolchain/musl/include/features.h b/toolchain/musl/include/features.h
new file mode 100644
index 0000000..edb8cc7
--- /dev/null
+++ b/toolchain/musl/include/features.h
@@ -0,0 +1,48 @@
+#ifndef _FEATURES_H
+#define _FEATURES_H
+
+#ifdef _ALL_SOURCE
+#define _GNU_SOURCE 1
+#endif
+
+#if !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \
+ && !defined(_XOPEN_SOURCE) && !defined(_GNU_SOURCE) \
+ && !defined(_BSD_SOURCE) && !defined(__STRICT_ANSI__)
+#define _BSD_SOURCE 1
+#define _XOPEN_SOURCE 700
+#endif
+
+#if __STDC_VERSION__ >= 199901L
+#define __restrict restrict
+#elif !defined(__GNUC__)
+#define __restrict
+#endif
+
+#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
+#define __inline inline
+#endif
+
+#if __STDC_VERSION__ >= 201112L
+#elif defined(__GNUC__)
+#define _Noreturn __attribute__((__noreturn__))
+#else
+#define _Noreturn
+#endif
+
+/* Convenience macros to test the versions of glibc and gcc.
+ Use them like this:
+ #if __GNUC_PREREQ (2,8)
+ ... code requiring gcc 2.8 or later ...
+ #endif
+ Note - they won't work for gcc1 or glibc1, since the _MINOR macros
+ were not defined then. */
+#if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+# define __GNUC_PREREQ(maj, min) 0
+#endif
+
+#include <sys/glibc-types.h>
+
+#endif
diff --git a/toolchain/musl/include/sgidefs.h b/toolchain/musl/include/sgidefs.h
new file mode 100644
index 0000000..74509fd
--- /dev/null
+++ b/toolchain/musl/include/sgidefs.h
@@ -0,0 +1,73 @@
+/* Copyright (C) 1996, 1997, 1998, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ralf Baechle <ralf@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SGIDEFS_H
+#define _SGIDEFS_H 1
+
+/*
+ * A crude hack to stop <asm/sgidefs.h>
+ */
+#undef __ASM_SGIDEFS_H
+#define __ASM_SGIDEFS_H
+
+/*
+ * And remove any damage it might have already done
+ */
+#undef _MIPS_ISA_MIPS1
+#undef _MIPS_ISA_MIPS2
+#undef _MIPS_ISA_MIPS3
+#undef _MIPS_ISA_MIPS4
+#undef _MIPS_ISA_MIPS5
+#undef _MIPS_ISA_MIPS32
+#undef _MIPS_ISA_MIPS64
+
+#undef _MIPS_SIM_ABI32
+#undef _MIPS_SIM_NABI32
+#undef _MIPS_SIM_ABI64
+
+/*
+ * Definitions for the ISA level
+ */
+#define _MIPS_ISA_MIPS1 1
+#define _MIPS_ISA_MIPS2 2
+#define _MIPS_ISA_MIPS3 3
+#define _MIPS_ISA_MIPS4 4
+#define _MIPS_ISA_MIPS5 5
+#define _MIPS_ISA_MIPS32 6
+#define _MIPS_ISA_MIPS64 7
+
+/*
+ * Subprogram calling convention
+ */
+#ifndef _ABIO32
+# define _ABIO32 1
+#endif
+#define _MIPS_SIM_ABI32 _ABIO32
+
+#ifndef _ABIN32
+# define _ABIN32 2
+#endif
+#define _MIPS_SIM_NABI32 _ABIN32
+
+#ifndef _ABI64
+# define _ABI64 3
+#endif
+#define _MIPS_SIM_ABI64 _ABI64
+
+#endif /* sgidefs.h */
diff --git a/toolchain/musl/include/sys/cdefs.h b/toolchain/musl/include/sys/cdefs.h
new file mode 100644
index 0000000..e986670
--- /dev/null
+++ b/toolchain/musl/include/sys/cdefs.h
@@ -0,0 +1,378 @@
+/* Copyright (C) 1992-2002, 2004, 2005, 2006, 2007, 2009, 2011, 2012
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_CDEFS_H
+#define _SYS_CDEFS_H 1
+
+/* We are almost always included from features.h. */
+#ifndef _FEATURES_H
+# include <features.h>
+#endif
+
+/* The GNU libc does not support any K&R compilers or the traditional mode
+ of ISO C compilers anymore. Check for some of the combinations not
+ anymore supported. */
+#if defined __GNUC__ && !defined __STDC__
+# error "You need a ISO C conforming compiler to use the glibc headers"
+#endif
+
+/* Some user header file might have defined this before. */
+#undef __P
+#undef __PMT
+
+#ifdef __GNUC__
+
+/* All functions, except those with callbacks or those that
+ synchronize memory, are leaf functions. */
+# if __GNUC_PREREQ (4, 6) && !defined _LIBC
+# define __LEAF , __leaf__
+# define __LEAF_ATTR __attribute__ ((__leaf__))
+# else
+# define __LEAF
+# define __LEAF_ATTR
+# endif
+
+/* GCC can always grok prototypes. For C++ programs we add throw()
+ to help it optimize the function calls. But this works only with
+ gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
+ as non-throwing using a function attribute since programs can use
+ the -fexceptions options for C code as well. */
+# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
+# define __THROW __attribute__ ((__nothrow__ __LEAF))
+# define __THROWNL __attribute__ ((__nothrow__))
+# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
+# else
+# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# define __THROW throw ()
+# define __THROWNL throw ()
+# define __NTH(fct) __LEAF_ATTR fct throw ()
+# else
+# define __THROW
+# define __THROWNL
+# define __NTH(fct) fct
+# endif
+# endif
+
+#else /* Not GCC. */
+
+# define __inline /* No inline functions. */
+
+# define __THROW
+# define __THROWNL
+# define __NTH(fct) fct
+
+#endif /* GCC. */
+
+/* These two macros are not used in glibc anymore. They are kept here
+ only because some other projects expect the macros to be defined. */
+#define __P(args) args
+#define __PMT(args) args
+
+/* For these things, GCC behaves the ANSI way normally,
+ and the non-ANSI way under -traditional. */
+
+#define __CONCAT(x,y) x ## y
+#define __STRING(x) #x
+
+/* This is not a typedef so `const __ptr_t' does the right thing. */
+#define __ptr_t void *
+#define __long_double_t long double
+
+
+/* C++ needs to know that types and declarations are C, not C++. */
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+#else
+# define __BEGIN_DECLS
+# define __END_DECLS
+#endif
+
+
+/* The standard library needs the functions from the ISO C90 standard
+ in the std namespace. At the same time we want to be safe for
+ future changes and we include the ISO C99 code in the non-standard
+ namespace __c99. The C++ wrapper header take case of adding the
+ definitions to the global namespace. */
+#if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES
+# define __BEGIN_NAMESPACE_STD namespace std {
+# define __END_NAMESPACE_STD }
+# define __USING_NAMESPACE_STD(name) using std::name;
+# define __BEGIN_NAMESPACE_C99 namespace __c99 {
+# define __END_NAMESPACE_C99 }
+# define __USING_NAMESPACE_C99(name) using __c99::name;
+#else
+/* For compatibility we do not add the declarations into any
+ namespace. They will end up in the global namespace which is what
+ old code expects. */
+# define __BEGIN_NAMESPACE_STD
+# define __END_NAMESPACE_STD
+# define __USING_NAMESPACE_STD(name)
+# define __BEGIN_NAMESPACE_C99
+# define __END_NAMESPACE_C99
+# define __USING_NAMESPACE_C99(name)
+#endif
+
+
+/* Support for bounded pointers. */
+#ifndef __BOUNDED_POINTERS__
+# define __bounded /* nothing */
+# define __unbounded /* nothing */
+# define __ptrvalue /* nothing */
+#endif
+
+
+/* Fortify support. */
+#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
+#define __bos0(ptr) __builtin_object_size (ptr, 0)
+#define __fortify_function __extern_always_inline __attribute_artificial__
+
+#if __GNUC_PREREQ (4,3)
+# define __warndecl(name, msg) \
+ extern void name (void) __attribute__((__warning__ (msg)))
+# define __warnattr(msg) __attribute__((__warning__ (msg)))
+# define __errordecl(name, msg) \
+ extern void name (void) __attribute__((__error__ (msg)))
+#else
+# define __warndecl(name, msg) extern void name (void)
+# define __warnattr(msg)
+# define __errordecl(name, msg) extern void name (void)
+#endif
+
+/* Support for flexible arrays. */
+#if __GNUC_PREREQ (2,97)
+/* GCC 2.97 supports C99 flexible array members. */
+# define __flexarr []
+#else
+# ifdef __GNUC__
+# define __flexarr [0]
+# else
+# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define __flexarr []
+# else
+/* Some other non-C99 compiler. Approximate with [1]. */
+# define __flexarr [1]
+# endif
+# endif
+#endif
+
+
+/* __asm__ ("xyz") is used throughout the headers to rename functions
+ at the assembly language level. This is wrapped by the __REDIRECT
+ macro, in order to support compilers that can do this some other
+ way. When compilers don't support asm-names at all, we have to do
+ preprocessor tricks instead (which don't have exactly the right
+ semantics, but it's the best we can do).
+
+ Example:
+ int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
+
+#if defined __GNUC__ && __GNUC__ >= 2
+
+# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
+# ifdef __cplusplus
+# define __REDIRECT_NTH(name, proto, alias) \
+ name proto __THROW __asm__ (__ASMNAME (#alias))
+# define __REDIRECT_NTHNL(name, proto, alias) \
+ name proto __THROWNL __asm__ (__ASMNAME (#alias))
+# else
+# define __REDIRECT_NTH(name, proto, alias) \
+ name proto __asm__ (__ASMNAME (#alias)) __THROW
+# define __REDIRECT_NTHNL(name, proto, alias) \
+ name proto __asm__ (__ASMNAME (#alias)) __THROWNL
+# endif
+# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
+# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
+
+/*
+#elif __SOME_OTHER_COMPILER__
+
+# define __REDIRECT(name, proto, alias) name proto; \
+ _Pragma("let " #name " = " #alias)
+*/
+#endif
+
+/* GCC has various useful declarations that can be made with the
+ `__attribute__' syntax. All of the ways we use this do fine if
+ they are omitted for compilers that don't understand it. */
+#if !defined __GNUC__ || __GNUC__ < 2
+# define __attribute__(xyz) /* Ignore */
+#endif
+
+/* At some point during the gcc 2.96 development the `malloc' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (2,96)
+# define __attribute_malloc__ __attribute__ ((__malloc__))
+#else
+# define __attribute_malloc__ /* Ignore */
+#endif
+
+/* At some point during the gcc 2.96 development the `pure' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (2,96)
+# define __attribute_pure__ __attribute__ ((__pure__))
+#else
+# define __attribute_pure__ /* Ignore */
+#endif
+
+/* This declaration tells the compiler that the value is constant. */
+#if __GNUC_PREREQ (2,5)
+# define __attribute_const__ __attribute__ ((__const__))
+#else
+# define __attribute_const__ /* Ignore */
+#endif
+
+/* At some point during the gcc 3.1 development the `used' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (3,1)
+# define __attribute_used__ __attribute__ ((__used__))
+# define __attribute_noinline__ __attribute__ ((__noinline__))
+#else
+# define __attribute_used__ __attribute__ ((__unused__))
+# define __attribute_noinline__ /* Ignore */
+#endif
+
+/* gcc allows marking deprecated functions. */
+#if __GNUC_PREREQ (3,2)
+# define __attribute_deprecated__ __attribute__ ((__deprecated__))
+#else
+# define __attribute_deprecated__ /* Ignore */
+#endif
+
+/* At some point during the gcc 2.8 development the `format_arg' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings.
+ If several `format_arg' attributes are given for the same function, in
+ gcc-3.0 and older, all but the last one are ignored. In newer gccs,
+ all designated arguments are considered. */
+#if __GNUC_PREREQ (2,8)
+# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
+#else
+# define __attribute_format_arg__(x) /* Ignore */
+#endif
+
+/* At some point during the gcc 2.97 development the `strfmon' format
+ attribute for functions was introduced. We don't want to use it
+ unconditionally (although this would be possible) since it
+ generates warnings. */
+#if __GNUC_PREREQ (2,97)
+# define __attribute_format_strfmon__(a,b) \
+ __attribute__ ((__format__ (__strfmon__, a, b)))
+#else
+# define __attribute_format_strfmon__(a,b) /* Ignore */
+#endif
+
+/* The nonull function attribute allows to mark pointer parameters which
+ must not be NULL. */
+#if __GNUC_PREREQ (3,3)
+# define __nonnull(params) __attribute__ ((__nonnull__ params))
+#else
+# define __nonnull(params)
+#endif
+
+/* If fortification mode, we warn about unused results of certain
+ function calls which can lead to problems. */
+#if __GNUC_PREREQ (3,4)
+# define __attribute_warn_unused_result__ \
+ __attribute__ ((__warn_unused_result__))
+# if __USE_FORTIFY_LEVEL > 0
+# define __wur __attribute_warn_unused_result__
+# endif
+#else
+# define __attribute_warn_unused_result__ /* empty */
+#endif
+#ifndef __wur
+# define __wur /* Ignore */
+#endif
+
+/* Forces a function to be always inlined. */
+#if __GNUC_PREREQ (3,2)
+# define __always_inline __inline __attribute__ ((__always_inline__))
+#else
+# define __always_inline __inline
+#endif
+
+/* Associate error messages with the source location of the call site rather
+ than with the source location inside the function. */
+#if __GNUC_PREREQ (4,3)
+# define __attribute_artificial__ __attribute__ ((__artificial__))
+#else
+# define __attribute_artificial__ /* Ignore */
+#endif
+
+/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
+ inline semantics, unless -fgnu89-inline is used. */
+#if !defined __cplusplus || __GNUC_PREREQ (4,3)
+# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
+# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
+# define __extern_always_inline \
+ extern __always_inline __attribute__ ((__gnu_inline__))
+# else
+# define __extern_inline extern __inline
+# define __extern_always_inline extern __always_inline
+# endif
+#endif
+
+/* GCC 4.3 and above allow passing all anonymous arguments of an
+ __extern_always_inline function to some other vararg function. */
+#if __GNUC_PREREQ (4,3)
+# define __va_arg_pack() __builtin_va_arg_pack ()
+# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
+#endif
+
+/* It is possible to compile containing GCC extensions even if GCC is
+ run in pedantic mode if the uses are carefully marked using the
+ `__extension__' keyword. But this is not generally available before
+ version 2.8. */
+#if !__GNUC_PREREQ (2,8)
+# define __extension__ /* Ignore */
+#endif
+
+/* __restrict is known in EGCS 1.2 and above. */
+#if !__GNUC_PREREQ (2,92)
+# define __restrict /* Ignore */
+#endif
+
+/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
+ array_name[restrict]
+ GCC 3.1 supports this. */
+#if __GNUC_PREREQ (3,1) && !defined __GNUG__
+# define __restrict_arr __restrict
+#else
+# ifdef __GNUC__
+# define __restrict_arr /* Not supported in old GCC. */
+# else
+# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define __restrict_arr restrict
+# else
+/* Some other non-C99 compiler. */
+# define __restrict_arr /* Not supported. */
+# endif
+# endif
+#endif
+
+#if __GNUC__ >= 3
+# define __glibc_unlikely(cond) __builtin_expect((cond), 0)
+#else
+# define __glibc_unlikely(cond) (cond)
+#endif
+
+#endif /* sys/cdefs.h */
diff --git a/toolchain/musl/include/sys/glibc-types.h b/toolchain/musl/include/sys/glibc-types.h
new file mode 100644
index 0000000..fa0684c
--- /dev/null
+++ b/toolchain/musl/include/sys/glibc-types.h
@@ -0,0 +1,35 @@
+#ifndef __MUSL_GLIBC_TYPES_H
+#define __MUSL_GLIBC_TYPES_H
+
+#include <sys/cdefs.h>
+
+/* Convenience types. */
+typedef unsigned char __u_char;
+typedef unsigned short int __u_short;
+typedef unsigned int __u_int;
+typedef unsigned long int __u_long;
+
+/* Fixed-size types, underlying types depend on word size and compiler. */
+typedef signed char __int8_t;
+typedef unsigned char __uint8_t;
+typedef signed short int __int16_t;
+typedef unsigned short int __uint16_t;
+typedef signed int __int32_t;
+typedef unsigned int __uint32_t;
+#if __WORDSIZE == 64
+typedef signed long int __int64_t;
+typedef unsigned long int __uint64_t;
+#else
+__extension__ typedef signed long long int __int64_t;
+__extension__ typedef unsigned long long int __uint64_t;
+#endif
+
+#define __off64_t off_t
+#define __loff_t off_t
+typedef char *__caddr_t;
+#define __locale_t locale_t
+
+#define __gid_t gid_t
+#define __uid_t uid_t
+
+#endif
diff --git a/toolchain/musl/include/sys/queue.h b/toolchain/musl/include/sys/queue.h
new file mode 100644
index 0000000..daf4553
--- /dev/null
+++ b/toolchain/musl/include/sys/queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)queue.h 8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef _SYS_QUEUE_H_
+#define _SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list. Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction. Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define LIST_HEAD(name, type) \
+struct name { \
+ struct type *lh_first; /* first element */ \
+}
+
+#define LIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#define LIST_ENTRY(type) \
+struct { \
+ struct type *le_next; /* next element */ \
+ struct type **le_prev; /* address of previous next element */ \
+}
+
+/*
+ * List functions.
+ */
+#define LIST_INIT(head) do { \
+ (head)->lh_first = NULL; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_INSERT_AFTER(listelm, elm, field) do { \
+ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
+ (listelm)->field.le_next->field.le_prev = \
+ &(elm)->field.le_next; \
+ (listelm)->field.le_next = (elm); \
+ (elm)->field.le_prev = &(listelm)->field.le_next; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.le_prev = (listelm)->field.le_prev; \
+ (elm)->field.le_next = (listelm); \
+ *(listelm)->field.le_prev = (elm); \
+ (listelm)->field.le_prev = &(elm)->field.le_next; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.le_next = (head)->lh_first) != NULL) \
+ (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+ (head)->lh_first = (elm); \
+ (elm)->field.le_prev = &(head)->lh_first; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_REMOVE(elm, field) do { \
+ if ((elm)->field.le_next != NULL) \
+ (elm)->field.le_next->field.le_prev = \
+ (elm)->field.le_prev; \
+ *(elm)->field.le_prev = (elm)->field.le_next; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_FOREACH(var, head, field) \
+ for ((var) = ((head)->lh_first); \
+ (var); \
+ (var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define LIST_EMPTY(head) ((head)->lh_first == NULL)
+#define LIST_FIRST(head) ((head)->lh_first)
+#define LIST_NEXT(elm, field) ((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define SLIST_HEAD(name, type) \
+struct name { \
+ struct type *slh_first; /* first element */ \
+}
+
+#define SLIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#define SLIST_ENTRY(type) \
+struct { \
+ struct type *sle_next; /* next element */ \
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define SLIST_INIT(head) do { \
+ (head)->slh_first = NULL; \
+} while (/*CONSTCOND*/0)
+
+#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
+ (elm)->field.sle_next = (slistelm)->field.sle_next; \
+ (slistelm)->field.sle_next = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define SLIST_INSERT_HEAD(head, elm, field) do { \
+ (elm)->field.sle_next = (head)->slh_first; \
+ (head)->slh_first = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define SLIST_REMOVE_HEAD(head, field) do { \
+ (head)->slh_first = (head)->slh_first->field.sle_next; \
+} while (/*CONSTCOND*/0)
+
+#define SLIST_REMOVE(head, elm, type, field) do { \
+ if ((head)->slh_first == (elm)) { \
+ SLIST_REMOVE_HEAD((head), field); \
+ } \
+ else { \
+ struct type *curelm = (head)->slh_first; \
+ while(curelm->field.sle_next != (elm)) \
+ curelm = curelm->field.sle_next; \
+ curelm->field.sle_next = \
+ curelm->field.sle_next->field.sle_next; \
+ } \
+} while (/*CONSTCOND*/0)
+
+#define SLIST_FOREACH(var, head, field) \
+ for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
+#define SLIST_FIRST(head) ((head)->slh_first)
+#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define STAILQ_HEAD(name, type) \
+struct name { \
+ struct type *stqh_first; /* first element */ \
+ struct type **stqh_last; /* addr of last next element */ \
+}
+
+#define STAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).stqh_first }
+
+#define STAILQ_ENTRY(type) \
+struct { \
+ struct type *stqe_next; /* next element */ \
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define STAILQ_INIT(head) do { \
+ (head)->stqh_first = NULL; \
+ (head)->stqh_last = &(head)->stqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \
+ (head)->stqh_last = &(elm)->field.stqe_next; \
+ (head)->stqh_first = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.stqe_next = NULL; \
+ *(head)->stqh_last = (elm); \
+ (head)->stqh_last = &(elm)->field.stqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+ (head)->stqh_last = &(elm)->field.stqe_next; \
+ (listelm)->field.stqe_next = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_REMOVE_HEAD(head, field) do { \
+ if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+ (head)->stqh_last = &(head)->stqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_REMOVE(head, elm, type, field) do { \
+ if ((head)->stqh_first == (elm)) { \
+ STAILQ_REMOVE_HEAD((head), field); \
+ } else { \
+ struct type *curelm = (head)->stqh_first; \
+ while (curelm->field.stqe_next != (elm)) \
+ curelm = curelm->field.stqe_next; \
+ if ((curelm->field.stqe_next = \
+ curelm->field.stqe_next->field.stqe_next) == NULL) \
+ (head)->stqh_last = &(curelm)->field.stqe_next; \
+ } \
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->stqh_first); \
+ (var); \
+ (var) = ((var)->field.stqe_next))
+
+#define STAILQ_CONCAT(head1, head2) do { \
+ if (!STAILQ_EMPTY((head2))) { \
+ *(head1)->stqh_last = (head2)->stqh_first; \
+ (head1)->stqh_last = (head2)->stqh_last; \
+ STAILQ_INIT((head2)); \
+ } \
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
+#define STAILQ_FIRST(head) ((head)->stqh_first)
+#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define SIMPLEQ_HEAD(name, type) \
+struct name { \
+ struct type *sqh_first; /* first element */ \
+ struct type **sqh_last; /* addr of last next element */ \
+}
+
+#define SIMPLEQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).sqh_first }
+
+#define SIMPLEQ_ENTRY(type) \
+struct { \
+ struct type *sqe_next; /* next element */ \
+}
+
+/*
+ * Simple queue functions.
+ */
+#define SIMPLEQ_INIT(head) do { \
+ (head)->sqh_first = NULL; \
+ (head)->sqh_last = &(head)->sqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
+ (head)->sqh_last = &(elm)->field.sqe_next; \
+ (head)->sqh_first = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.sqe_next = NULL; \
+ *(head)->sqh_last = (elm); \
+ (head)->sqh_last = &(elm)->field.sqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+ (head)->sqh_last = &(elm)->field.sqe_next; \
+ (listelm)->field.sqe_next = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
+ if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+ (head)->sqh_last = &(head)->sqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_REMOVE(head, elm, type, field) do { \
+ if ((head)->sqh_first == (elm)) { \
+ SIMPLEQ_REMOVE_HEAD((head), field); \
+ } else { \
+ struct type *curelm = (head)->sqh_first; \
+ while (curelm->field.sqe_next != (elm)) \
+ curelm = curelm->field.sqe_next; \
+ if ((curelm->field.sqe_next = \
+ curelm->field.sqe_next->field.sqe_next) == NULL) \
+ (head)->sqh_last = &(curelm)->field.sqe_next; \
+ } \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->sqh_first); \
+ (var); \
+ (var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL)
+#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
+#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define _TAILQ_HEAD(name, type, qual) \
+struct name { \
+ qual type *tqh_first; /* first element */ \
+ qual type *qual *tqh_last; /* addr of last next element */ \
+}
+#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,)
+
+#define TAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).tqh_first }
+
+#define _TAILQ_ENTRY(type, qual) \
+struct { \
+ qual type *tqe_next; /* next element */ \
+ qual type *qual *tqe_prev; /* address of previous next element */\
+}
+#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define TAILQ_INIT(head) do { \
+ (head)->tqh_first = NULL; \
+ (head)->tqh_last = &(head)->tqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
+ (head)->tqh_first->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (head)->tqh_first = (elm); \
+ (elm)->field.tqe_prev = &(head)->tqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.tqe_next = NULL; \
+ (elm)->field.tqe_prev = (head)->tqh_last; \
+ *(head)->tqh_last = (elm); \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+ (elm)->field.tqe_next->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (listelm)->field.tqe_next = (elm); \
+ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
+ (elm)->field.tqe_next = (listelm); \
+ *(listelm)->field.tqe_prev = (elm); \
+ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_REMOVE(head, elm, field) do { \
+ if (((elm)->field.tqe_next) != NULL) \
+ (elm)->field.tqe_next->field.tqe_prev = \
+ (elm)->field.tqe_prev; \
+ else \
+ (head)->tqh_last = (elm)->field.tqe_prev; \
+ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define TAILQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->tqh_first); \
+ (var); \
+ (var) = ((var)->field.tqe_next))
+
+#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
+ for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
+ (var); \
+ (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define TAILQ_CONCAT(head1, head2, field) do { \
+ if (!TAILQ_EMPTY(head2)) { \
+ *(head1)->tqh_last = (head2)->tqh_first; \
+ (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
+ (head1)->tqh_last = (head2)->tqh_last; \
+ TAILQ_INIT((head2)); \
+ } \
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
+#define TAILQ_FIRST(head) ((head)->tqh_first)
+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+
+#define TAILQ_LAST(head, headname) \
+ (*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define TAILQ_PREV(elm, headname, field) \
+ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define CIRCLEQ_HEAD(name, type) \
+struct name { \
+ struct type *cqh_first; /* first element */ \
+ struct type *cqh_last; /* last element */ \
+}
+
+#define CIRCLEQ_HEAD_INITIALIZER(head) \
+ { (void *)&head, (void *)&head }
+
+#define CIRCLEQ_ENTRY(type) \
+struct { \
+ struct type *cqe_next; /* next element */ \
+ struct type *cqe_prev; /* previous element */ \
+}
+
+/*
+ * Circular queue functions.
+ */
+#define CIRCLEQ_INIT(head) do { \
+ (head)->cqh_first = (void *)(head); \
+ (head)->cqh_last = (void *)(head); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ (elm)->field.cqe_next = (listelm)->field.cqe_next; \
+ (elm)->field.cqe_prev = (listelm); \
+ if ((listelm)->field.cqe_next == (void *)(head)) \
+ (head)->cqh_last = (elm); \
+ else \
+ (listelm)->field.cqe_next->field.cqe_prev = (elm); \
+ (listelm)->field.cqe_next = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
+ (elm)->field.cqe_next = (listelm); \
+ (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
+ if ((listelm)->field.cqe_prev == (void *)(head)) \
+ (head)->cqh_first = (elm); \
+ else \
+ (listelm)->field.cqe_prev->field.cqe_next = (elm); \
+ (listelm)->field.cqe_prev = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
+ (elm)->field.cqe_next = (head)->cqh_first; \
+ (elm)->field.cqe_prev = (void *)(head); \
+ if ((head)->cqh_last == (void *)(head)) \
+ (head)->cqh_last = (elm); \
+ else \
+ (head)->cqh_first->field.cqe_prev = (elm); \
+ (head)->cqh_first = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.cqe_next = (void *)(head); \
+ (elm)->field.cqe_prev = (head)->cqh_last; \
+ if ((head)->cqh_first == (void *)(head)) \
+ (head)->cqh_first = (elm); \
+ else \
+ (head)->cqh_last->field.cqe_next = (elm); \
+ (head)->cqh_last = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_REMOVE(head, elm, field) do { \
+ if ((elm)->field.cqe_next == (void *)(head)) \
+ (head)->cqh_last = (elm)->field.cqe_prev; \
+ else \
+ (elm)->field.cqe_next->field.cqe_prev = \
+ (elm)->field.cqe_prev; \
+ if ((elm)->field.cqe_prev == (void *)(head)) \
+ (head)->cqh_first = (elm)->field.cqe_next; \
+ else \
+ (elm)->field.cqe_prev->field.cqe_next = \
+ (elm)->field.cqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->cqh_first); \
+ (var) != (const void *)(head); \
+ (var) = ((var)->field.cqe_next))
+
+#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
+ for ((var) = ((head)->cqh_last); \
+ (var) != (const void *)(head); \
+ (var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head))
+#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
+#define CIRCLEQ_LAST(head) ((head)->cqh_last)
+#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
+#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field) \
+ (((elm)->field.cqe_next == (void *)(head)) \
+ ? ((head)->cqh_first) \
+ : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field) \
+ (((elm)->field.cqe_prev == (void *)(head)) \
+ ? ((head)->cqh_last) \
+ : (elm->field.cqe_prev))
+
+#endif /* sys/queue.h */
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 <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
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 <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(); }
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..635437f
--- /dev/null
+++ b/toolchain/musl/patches/901-crypt_size_hack.patch
@@ -0,0 +1,110 @@
+--- 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
diff --git a/toolchain/uClibc/Config.in b/toolchain/uClibc/Config.in
new file mode 100644
index 0000000..08ea00a
--- /dev/null
+++ b/toolchain/uClibc/Config.in
@@ -0,0 +1,21 @@
+# Choose uclibc version.
+
+choice
+ prompt "uClibc Version"
+ depends on TOOLCHAINOPTS && USE_UCLIBC
+ default UCLIBC_USE_VERSION_0_9_33
+ help
+ Select the version of uClibc you wish to use.
+
+ config UCLIBC_USE_VERSION_0_9_33
+ select UCLIBC_VERSION_0_9_33
+ bool "uClibc 0.9.33.2"
+
+endchoice
+
+# Debug version.
+
+config UCLIBC_ENABLE_DEBUG
+ bool "Build with debug information"
+ depends on TOOLCHAINOPTS && USE_UCLIBC
+ default n
diff --git a/toolchain/uClibc/Config.version b/toolchain/uClibc/Config.version
new file mode 100644
index 0000000..dd302f2
--- /dev/null
+++ b/toolchain/uClibc/Config.version
@@ -0,0 +1,9 @@
+config UCLIBC_VERSION
+ string
+ depends on USE_UCLIBC
+ default "0.9.33.2" if UCLIBC_VERSION_0_9_33
+ default "0.9.33.2"
+
+config UCLIBC_VERSION_0_9_33
+ default y if !TOOLCHAINOPTS && USE_UCLIBC
+ bool
diff --git a/toolchain/uClibc/Makefile b/toolchain/uClibc/Makefile
new file mode 100644
index 0000000..a5fb54b
--- /dev/null
+++ b/toolchain/uClibc/Makefile
@@ -0,0 +1,41 @@
+PATH_PREFIX=.
+
+include ./common.mk
+
+HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.built
+HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc_installed
+
+HOST_BUILD_PARALLEL:=1
+
+define Host/SetToolchainInfo
+ $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.uclibc.org/,' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+ $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(LIBC_SO_VERSION),' $(TOOLCHAIN_DIR)/info.mk
+endef
+
+define Host/Compile
+ $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(HOST_BUILD_DIR)/Rules.mak
+ $(UCLIBC_MAKE) PREFIX= all
+endef
+
+define Host/Install
+ $(call Host/SetToolchainInfo)
+ $(UCLIBC_MAKE) PREFIX="$(TOOLCHAIN_DIR)/" install_runtime install_dev
+ $(CP) $(HOST_BUILD_DIR)/libc/libc_so.a $(TOOLCHAIN_DIR)/lib/
+ $(CP) $(HOST_BUILD_DIR)/libpthread/*/libpthread_so.a $(TOOLCHAIN_DIR)/lib/
+ ( cd $(TOOLCHAIN_DIR) ; \
+ for d in lib usr/lib ; do \
+ for f in libc.so libpthread.so libgcc_s.so ; do \
+ if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
+ $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
+ fi \
+ done \
+ done \
+ )
+ rm -f \
+ $(TOOLCHAIN_DIR)/lib/libresolv*.so* \
+ $(TOOLCHAIN_DIR)/lib/libnsl*.so*
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/uClibc/common.mk b/toolchain/uClibc/common.mk
new file mode 100644
index 0000000..53a8443
--- /dev/null
+++ b/toolchain/uClibc/common.mk
@@ -0,0 +1,96 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/target.mk
+
+PKG_NAME:=uClibc
+PKG_VERSION:=$(call qstrip,$(CONFIG_UCLIBC_VERSION))
+PKG_SOURCE_URL:=http://www.uclibc.org/downloads
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+LIBC_SO_VERSION:=$(PKG_VERSION)
+PATCH_DIR:=$(PATH_PREFIX)/patches-$(PKG_VERSION)
+CONFIG_DIR:=$(PATH_PREFIX)/config-$(PKG_VERSION)
+
+PKG_MD5SUM_0.9.33.2 = a338aaffc56f0f5040e6d9fa8a12eda1
+PKG_MD5SUM=$(PKG_MD5SUM_$(PKG_VERSION))
+
+HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
+ -e 's/i.86/i386/' \
+ -e 's/sparc.*/sparc/' \
+ -e 's/arm.*/arm/g' \
+ -e 's/m68k.*/m68k/' \
+ -e 's/ppc/powerpc/g' \
+ -e 's/v850.*/v850/g' \
+ -e 's/sh64/sh/' \
+ -e 's/sh[234].*/sh/' \
+ -e 's/mips.*/mips/' \
+ -e 's/mipsel.*/mips/' \
+)
+
+GEN_CONFIG=$(SCRIPT_DIR)/kconfig.pl -n \
+ $(if $(wildcard $(CONFIG_DIR)/common),'+' $(CONFIG_DIR)/common) \
+ $(if $(CONFIG_UCLIBC_ENABLE_DEBUG),$(if $(wildcard $(CONFIG_DIR)/debug),'+' $(CONFIG_DIR)/debug)) \
+ $(CONFIG_DIR)/$(ARCH)$(strip \
+ $(if $(wildcard $(CONFIG_DIR)/$(ARCH).$(BOARD)),.$(BOARD), \
+ $(if $(CONFIG_MIPS64_ABI),.$(subst ",,$(CONFIG_MIPS64_ABI)), \
+ $(if $(CONFIG_HAS_SPE_FPU),$(if $(wildcard $(CONFIG_DIR)/$(ARCH).e500),.e500)))))
+
+CPU_CFLAGS = \
+ -funsigned-char -fno-builtin -fno-asm \
+ --std=gnu99 -ffunction-sections -fdata-sections \
+ -Wno-unused-but-set-variable \
+ $(TARGET_CFLAGS) -ggdb
+
+UCLIBC_MAKE = PATH='$(TOOLCHAIN_DIR)/initial/bin:$(TARGET_PATH)' $(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ DEVEL_PREFIX=/ \
+ RUNTIME_PREFIX=/ \
+ HOSTCC="$(HOSTCC)" \
+ CPU_CFLAGS="$(CPU_CFLAGS)" \
+ ARCH="$(CONFIG_ARCH)" \
+ LIBGCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))" \
+ DOSTRIP=""
+
+define Host/Prepare
+ $(call Host/Prepare/Default)
+ $(if $(strip $(QUILT)), \
+ cd $(HOST_BUILD_DIR); \
+ if $(QUILT_CMD) next >/dev/null 2>&1; then \
+ $(QUILT_CMD) push -a; \
+ fi
+ )
+ ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+endef
+
+define Host/Configure
+ $(GEN_CONFIG) > $(HOST_BUILD_DIR)/.config.new
+ $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/include\",g' \
+ -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
+ -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \
+ -e 's,^.*UCLIBC_HAS_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),y,n),g' \
+ -e 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \
+ -e 's,^.*UCLIBC_BUILD_ALL_LOCALE.*,UCLIBC_BUILD_ALL_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \
+ -e 's,^.*UCLIBC_HAS_SSP[^_].*,UCLIBC_HAS_SSP=$(if $(or $(CONFIG_PKG_CC_STACKPROTECTOR_REGULAR),$(CONFIG_PKG_CC_STACKPROTECTOR_STRONG)),y,n),g' \
+ $(HOST_BUILD_DIR)/.config.new
+ cmp -s $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config.last || { \
+ cp $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config && \
+ $(MAKE) -C $(HOST_BUILD_DIR) oldconfig KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS" && \
+ $(MAKE) -C $(HOST_BUILD_DIR)/extra/config conf KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS" && \
+ cp $(HOST_BUILD_DIR)/.config.new $(HOST_BUILD_DIR)/.config.last; \
+ }
+endef
+
+define Host/Clean
+ rm -rf \
+ $(HOST_BUILD_DIR) \
+ $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
+ $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
+endef
diff --git a/toolchain/uClibc/config-0.9.33.2/arm b/toolchain/uClibc/config-0.9.33.2/arm
new file mode 100644
index 0000000..b68617b
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/arm
@@ -0,0 +1,7 @@
+ARCH_ANY_ENDIAN=y
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# COMPILE_IN_THUMB_MODE is not set
+TARGET_ARCH="arm"
+TARGET_arm=y
+# USE_BX is not set
diff --git a/toolchain/uClibc/config-0.9.33.2/armeb b/toolchain/uClibc/config-0.9.33.2/armeb
new file mode 100644
index 0000000..d4932e8
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/armeb
@@ -0,0 +1,7 @@
+ARCH_ANY_ENDIAN=y
+ARCH_BIG_ENDIAN=y
+ARCH_WANTS_BIG_ENDIAN=y
+# COMPILE_IN_THUMB_MODE is not set
+TARGET_ARCH="arm"
+TARGET_arm=y
+# USE_BX is not set
diff --git a/toolchain/uClibc/config-0.9.33.2/common b/toolchain/uClibc/config-0.9.33.2/common
new file mode 100644
index 0000000..b948d4b
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/common
@@ -0,0 +1,214 @@
+# ARCH_ANY_ENDIAN is not set
+ARCH_HAS_MMU=y
+# ARCH_HAS_NO_LDSO is not set
+# ARCH_HAS_NO_SHARED is not set
+# ARCH_LITTLE_ENDIAN is not set
+ARCH_USE_MMU=y
+# ARCH_WANTS_BIG_ENDIAN is not set
+# ARCH_WANTS_LITTLE_ENDIAN is not set
+ASSUME_DEVPTS=y
+# COMPAT_ATEXIT is not set
+CROSS_COMPILER_PREFIX=""
+DEVEL_PREFIX="/usr/"
+# DOASSERTS is not set
+# DODEBUG is not set
+# DODEBUG_PT is not set
+# DOMULTI is not set
+DOPIC=y
+DOSTRIP=y
+DO_C99_MATH=y
+# DO_XSI_MATH is not set
+# EXTRA_WARNINGS is not set
+FORCE_OPTIONS_FOR_ARCH=y
+# FORCE_SHAREABLE_TEXT_SEGMENTS is not set
+# HARDWIRED_ABSPATH is not set
+# HAS_NO_THREADS is not set
+HAVE_DOT_CONFIG=y
+# HAVE_NO_PIC is not set
+# HAVE_NO_SSP is not set
+HAVE_SHARED=y
+KERNEL_HEADERS="."
+LDSO_BASE_FILENAME="ld.so"
+LDSO_CACHE_SUPPORT=y
+# LDSO_GNU_HASH_SUPPORT is not set
+LDSO_LD_LIBRARY_PATH=y
+LDSO_LDD_SUPPORT=y
+# LDSO_NO_CLEANUP is not set
+# LDSO_PRELINK_SUPPORT is not set
+# LDSO_PRELOAD_FILE_SUPPORT is not set
+LDSO_PRELOAD_ENV_SUPPORT=y
+LDSO_RUNPATH=y
+# LDSO_SEARCH_INTERP_PATH is not set
+# LDSO_STANDALONE_SUPPORT is not set
+# LINUXTHREADS_NEW is not set
+# LINUXTHREADS_OLD is not set
+# UCLIBC_HAS_BACKTRACE is not set
+UCLIBC_HAS_THREADS_NATIVE=y
+# MALLOC is not set
+MALLOC_GLIBC_COMPAT=y
+# MALLOC_SIMPLE is not set
+MALLOC_STANDARD=y
+MULTILIB_DIR="lib"
+PTHREADS_DEBUG_SUPPORT=y
+RUNTIME_PREFIX="/"
+# SUPPORT_LD_DEBUG is not set
+# SUPPORT_LD_DEBUG_EARLY is not set
+TARGET_SUBARCH=""
+# TARGET_alpha is not set
+# TARGET_arm is not set
+# TARGET_avr32 is not set
+# TARGET_bfin is not set
+# TARGET_c6x is not set
+# TARGET_cris is not set
+# TARGET_e1 is not set
+# TARGET_frv is not set
+# TARGET_h8300 is not set
+# TARGET_hppa is not set
+# TARGET_i386 is not set
+# TARGET_i960 is not set
+# TARGET_ia64 is not set
+# TARGET_m68k is not set
+# TARGET_microblaze is not set
+# TARGET_mips is not set
+# TARGET_nios is not set
+# TARGET_nios2 is not set
+# TARGET_powerpc is not set
+# TARGET_sh is not set
+# TARGET_sh64 is not set
+# TARGET_sparc is not set
+# TARGET_v850 is not set
+# TARGET_vax is not set
+# TARGET_x86_64 is not set
+# TARGET_xtensa is not set
+UCLIBC_BSD_SPECIFIC=y
+UCLIBC_BUILD_NOEXECSTACK=y
+# UCLIBC_BUILD_NOW is not set
+# UCLIBC_BUILD_PIE is not set
+UCLIBC_BUILD_RELRO=y
+UCLIBC_CTOR_DTOR=y
+UCLIBC_DYNAMIC_ATEXIT=y
+UCLIBC_EXTRA_CFLAGS=""
+UCLIBC_GRP_BUFFER_SIZE=256
+UCLIBC_HAS_ADVANCED_REALTIME=y
+# UCLIBC_HAS_ARC4RANDOM is not set
+UCLIBC_HAS_BSD_ERR=y
+UCLIBC_HAS_BSD_RES_CLOSE=y
+# UCLIBC_HAS_COMPAT_RES_STATE is not set
+UCLIBC_HAS_CRYPT=y
+UCLIBC_HAS_CRYPT_IMPL=y
+UCLIBC_HAS_CTYPE_CHECKED=y
+# UCLIBC_HAS_CTYPE_ENFORCED is not set
+UCLIBC_HAS_CTYPE_SIGNED=y
+UCLIBC_HAS_CTYPE_TABLES=y
+# UCLIBC_HAS_CTYPE_UNSAFE is not set
+UCLIBC_HAS_EPOLL=y
+UCLIBC_HAS_ERRNO_MESSAGES=y
+# UCLIBC_HAS_EXTRA_COMPAT_RES_STATE is not set
+# UCLIBC_HAS_FENV is not set
+UCLIBC_HAS_FLOATS=y
+UCLIBC_HAS_FNMATCH=y
+UCLIBC_HAS_FNMATCH_OLD=y
+# UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE is not set
+UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y
+# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set
+# UCLIBC_HAS_FPU is not set
+UCLIBC_HAS_FTS=y
+UCLIBC_HAS_FTW=y
+# UCLIBC_HAS_FULL_RPC is not set
+UCLIBC_HAS_GETPT=y
+UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+# UCLIBC_HAS_GLIBC_DIGIT_GROUPING is not set
+UCLIBC_HAS_GLOB=y
+UCLIBC_HAS_GNU_ERROR=y
+UCLIBC_HAS_GNU_GETOPT=y
+UCLIBC_HAS_GNU_GETSUBOPT=y
+UCLIBC_HAS_GNU_GLOB=y
+UCLIBC_HAS_HEXADECIMAL_FLOATS=y
+UCLIBC_HAS_IPV4=y
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_LFS=y
+UCLIBC_HAS_LIBNSL_STUB=y
+UCLIBC_HAS_LIBRESOLV_STUB=y
+UCLIBC_HAS_LIBUTIL=y
+# UCLIBC_HAS_LOCALE is not set
+# UCLIBC_BUILD_ALL_LOCALE is not set
+# UCLIBC_BUILD_MINIMAL_LOCALE is not set
+# UCLIBC_PREGENERATED_LOCALE_DATA is not set
+UCLIBC_HAS_LONG_DOUBLE_MATH=y
+UCLIBC_HAS_NETWORK_SUPPORT=y
+UCLIBC_HAS_NFTW=y
+# UCLIBC_HAS_OBSOLETE_BSD_SIGNAL is not set
+# UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL is not set
+UCLIBC_HAS_PRINTF_M_SPEC=y
+# UCLIBC_HAS_PROFILING is not set
+UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y
+UCLIBC_HAS_PTY=y
+UCLIBC_HAS_REALTIME=y
+# UCLIBC_HAS_REENTRANT_RPC is not set
+UCLIBC_HAS_REGEX=y
+UCLIBC_HAS_REGEX_OLD=y
+UCLIBC_HAS_RESOLVER_SUPPORT=y
+# UCLIBC_HAS_RPC is not set
+UCLIBC_HAS_SCANF_GLIBC_A_FLAG=y
+# UCLIBC_HAS_SHA256_CRYPT_IMPL is not set
+# UCLIBC_HAS_SHA512_CRYPT_IMPL is not set
+UCLIBC_HAS_SHADOW=y
+UCLIBC_HAS_SIGNUM_MESSAGES=y
+UCLIBC_HAS_SOCKET=y
+UCLIBC_HAS_SOFT_FLOAT=y
+# UCLIBC_HAS_SSP is not set
+# UCLIBC_HAS_SSP_COMPAT is not set
+UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
+# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set
+UCLIBC_HAS_STDIO_BUFSIZ_4096=y
+# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set
+UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
+UCLIBC_HAS_STDIO_GETC_MACRO=y
+UCLIBC_HAS_STDIO_PUTC_MACRO=y
+# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set
+UCLIBC_HAS_STRING_ARCH_OPT=y
+UCLIBC_HAS_STRING_GENERIC_OPT=y
+# UCLIBC_HAS_STUBS is not set
+UCLIBC_HAS_SYSLOG=y
+# UCLIBC_HAS_SYS_ERRLIST is not set
+# UCLIBC_HAS_SYS_SIGLIST is not set
+UCLIBC_HAS_THREADS=y
+UCLIBC_HAS_TM_EXTENSIONS=y
+UCLIBC_HAS_TZ_CACHING=y
+UCLIBC_HAS_TZ_FILE=y
+UCLIBC_HAS_TZ_FILE_READ_MANY=y
+# UCLIBC_HAS_UTMPX is not set
+UCLIBC_HAS_WCHAR=y
+UCLIBC_HAS_WORDEXP=y
+# UCLIBC_HAS_XATTR is not set
+# UCLIBC_HAS_XLOCALE is not set
+UCLIBC_HAS___PROGNAME=y
+# UCLIBC_LINUX_MODULE_24 is not set
+UCLIBC_LINUX_MODULE_26=y
+UCLIBC_LINUX_SPECIFIC=y
+# UCLIBC_MALLOC_DEBUGGING is not set
+# UCLIBC_MJN3_ONLY is not set
+# UCLIBC_NTP_LEGACY is not set
+# USE_OLD_VFPRINTF is not set
+UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
+UCLIBC_PWD_BUFFER_SIZE=256
+# UCLIBC_STATIC_LDCONFIG is not set
+# UCLIBC_STRICT_HEADERS is not set
+UCLIBC_SUPPORT_AI_ADDRCONFIG=y
+UCLIBC_SUSV3_LEGACY=y
+UCLIBC_SUSV3_LEGACY_MACROS=y
+UCLIBC_SUSV4_LEGACY=y
+# UCLIBC_SV4_DEPRECATED is not set
+UCLIBC_TZ_FILE_PATH="/etc/TZ"
+# UCLIBC_FALLBACK_TO_ETC_LOCALTIME is not set
+UCLIBC_USE_NETLINK=y
+# UNIX98PTY_ONLY is not set
+USE_BX=y
+WARNINGS="-Wall"
diff --git a/toolchain/uClibc/config-0.9.33.2/debug b/toolchain/uClibc/config-0.9.33.2/debug
new file mode 100644
index 0000000..b366e66
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/debug
@@ -0,0 +1,6 @@
+DODEBUG=y
+DODEBUG_PT=y
+PTHREADS_DEBUG_SUPPORT=y
+SUPPORT_LD_DEBUG=y
+SUPPORT_LD_DEBUG_EARLY=y
+UCLIBC_MALLOC_DEBUGGING=y
diff --git a/toolchain/uClibc/config-0.9.33.2/i386 b/toolchain/uClibc/config-0.9.33.2/i386
new file mode 100644
index 0000000..5ef264c
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/i386
@@ -0,0 +1,21 @@
+ARCH_LITTLE_ENDIAN=y
+# CONFIG_386 is not set
+CONFIG_486=y
+# CONFIG_586 is not set
+# CONFIG_586MMX is not set
+# CONFIG_686 is not set
+# CONFIG_CRUSOE is not set
+# CONFIG_CYRIXIII is not set
+# CONFIG_ELAN is not set
+# CONFIG_GENERIC_386 is not set
+# CONFIG_K6 is not set
+# CONFIG_K7 is not set
+# CONFIG_NEHEMIAH is not set
+# CONFIG_PENTIUM4 is not set
+# CONFIG_PENTIUMII is not set
+# CONFIG_PENTIUMIII is not set
+# CONFIG_WINCHIP2 is not set
+# CONFIG_WINCHIPC6 is not set
+TARGET_ARCH="i386"
+TARGET_i386=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/i686 b/toolchain/uClibc/config-0.9.33.2/i686
new file mode 100644
index 0000000..ba615f6
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/i686
@@ -0,0 +1,21 @@
+ARCH_LITTLE_ENDIAN=y
+# CONFIG_386 is not set
+# CONFIG_486 is not set
+# CONFIG_586 is not set
+# CONFIG_586MMX is not set
+CONFIG_686=y
+# CONFIG_CRUSOE is not set
+# CONFIG_CYRIXIII is not set
+# CONFIG_ELAN is not set
+# CONFIG_GENERIC_386 is not set
+# CONFIG_K6 is not set
+# CONFIG_K7 is not set
+# CONFIG_NEHEMIAH is not set
+# CONFIG_PENTIUM4 is not set
+# CONFIG_PENTIUMII is not set
+# CONFIG_PENTIUMIII is not set
+# CONFIG_WINCHIP2 is not set
+# CONFIG_WINCHIPC6 is not set
+TARGET_ARCH="i386"
+TARGET_i386=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/m68k b/toolchain/uClibc/config-0.9.33.2/m68k
new file mode 100644
index 0000000..14ce5ae
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/m68k
@@ -0,0 +1,6 @@
+ARCH_BIG_ENDIAN=y
+LINUXTHREADS_OLD=y
+TARGET_ARCH="m68k"
+TARGET_SUBARCH=""
+TARGET_m68k=y
+# UCLIBC_HAS_THREADS_NATIVE is not set
diff --git a/toolchain/uClibc/config-0.9.33.2/mips b/toolchain/uClibc/config-0.9.33.2/mips
new file mode 100644
index 0000000..7398c66
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/mips
@@ -0,0 +1,17 @@
+ARCH_ANY_ENDIAN=y
+ARCH_BIG_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_WANTS_BIG_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+CONFIG_MIPS_ISA_MIPS32=y
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+# CONFIG_MIPS_ISA_MIPS64 is not set
+# CONFIG_MIPS_N32_ABI is not set
+# CONFIG_MIPS_N64_ABI is not set
+CONFIG_MIPS_O32_ABI=y
+TARGET_ARCH="mips"
+TARGET_mips=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/mips64 b/toolchain/uClibc/config-0.9.33.2/mips64
new file mode 100644
index 0000000..fa5bee3
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/mips64
@@ -0,0 +1,17 @@
+ARCH_ANY_ENDIAN=y
+ARCH_BIG_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_WANTS_BIG_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_N32_ABI is not set
+CONFIG_MIPS_N64_ABI=y
+# CONFIG_MIPS_O32_ABI is not set
+TARGET_ARCH="mips"
+TARGET_mips=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/mips64.32 b/toolchain/uClibc/config-0.9.33.2/mips64.32
new file mode 100644
index 0000000..03f7fba
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/mips64.32
@@ -0,0 +1,18 @@
+ARCH_ANY_ENDIAN=y
+ARCH_BIG_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_WANTS_BIG_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_N32_ABI is not set
+# CONFIG_MIPS_N64_ABI is not set
+CONFIG_MIPS_O32_ABI=y
+TARGET_ARCH="mips"
+TARGET_mips=y
+TARGET_SUBARCH="mips64"
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/mips64.64 b/toolchain/uClibc/config-0.9.33.2/mips64.64
new file mode 100644
index 0000000..7b66c2f
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/mips64.64
@@ -0,0 +1,18 @@
+ARCH_ANY_ENDIAN=y
+ARCH_BIG_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_WANTS_BIG_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_N32_ABI is not set
+CONFIG_MIPS_N64_ABI=y
+# CONFIG_MIPS_O32_ABI is not set
+TARGET_ARCH="mips"
+TARGET_mips=y
+TARGET_SUBARCH="mips64"
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/mips64.n32 b/toolchain/uClibc/config-0.9.33.2/mips64.n32
new file mode 100644
index 0000000..84a5de6
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/mips64.n32
@@ -0,0 +1,18 @@
+ARCH_ANY_ENDIAN=y
+ARCH_BIG_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_WANTS_BIG_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+CONFIG_MIPS_N32_ABI=y
+# CONFIG_MIPS_N64_ABI is not set
+# CONFIG_MIPS_O32_ABI is not set
+TARGET_ARCH="mips"
+TARGET_mips=y
+TARGET_SUBARCH="mips64"
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/mips64el b/toolchain/uClibc/config-0.9.33.2/mips64el
new file mode 100644
index 0000000..1ca764f
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/mips64el
@@ -0,0 +1,17 @@
+ARCH_ANY_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_N32_ABI is not set
+CONFIG_MIPS_N64_ABI=y
+# CONFIG_MIPS_O32_ABI is not set
+TARGET_ARCH="mips"
+TARGET_mips=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/mips64el.32 b/toolchain/uClibc/config-0.9.33.2/mips64el.32
new file mode 100644
index 0000000..73b1f9f
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/mips64el.32
@@ -0,0 +1,18 @@
+ARCH_ANY_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_N32_ABI is not set
+# CONFIG_MIPS_N64_ABI is not set
+CONFIG_MIPS_O32_ABI=y
+TARGET_ARCH="mips"
+TARGET_mips=y
+TARGET_SUBARCH="mips64"
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/mips64el.64 b/toolchain/uClibc/config-0.9.33.2/mips64el.64
new file mode 100644
index 0000000..790f210
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/mips64el.64
@@ -0,0 +1,18 @@
+ARCH_ANY_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+# CONFIG_MIPS_N32_ABI is not set
+CONFIG_MIPS_N64_ABI=y
+# CONFIG_MIPS_O32_ABI is not set
+TARGET_ARCH="mips"
+TARGET_mips=y
+TARGET_SUBARCH="mips64"
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/mips64el.n32 b/toolchain/uClibc/config-0.9.33.2/mips64el.n32
new file mode 100644
index 0000000..c2929bf
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/mips64el.n32
@@ -0,0 +1,18 @@
+ARCH_ANY_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+CONFIG_MIPS_ISA_MIPS64=y
+CONFIG_MIPS_N32_ABI=y
+# CONFIG_MIPS_N64_ABI is not set
+# CONFIG_MIPS_O32_ABI is not set
+TARGET_ARCH="mips"
+TARGET_mips=y
+TARGET_SUBARCH="mips64"
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/mipsel b/toolchain/uClibc/config-0.9.33.2/mipsel
new file mode 100644
index 0000000..7648f39
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/mipsel
@@ -0,0 +1,17 @@
+ARCH_ANY_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+# CONFIG_MIPS_ISA_3 is not set
+# CONFIG_MIPS_ISA_4 is not set
+CONFIG_MIPS_ISA_MIPS32=y
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+# CONFIG_MIPS_ISA_MIPS64 is not set
+# CONFIG_MIPS_N32_ABI is not set
+# CONFIG_MIPS_N64_ABI is not set
+CONFIG_MIPS_O32_ABI=y
+TARGET_ARCH="mips"
+TARGET_mips=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/mipsel.cobalt b/toolchain/uClibc/config-0.9.33.2/mipsel.cobalt
new file mode 100644
index 0000000..323b0aa
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/mipsel.cobalt
@@ -0,0 +1,17 @@
+ARCH_ANY_ENDIAN=y
+ARCH_CFLAGS="-mno-split-addresses"
+ARCH_LITTLE_ENDIAN=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# CONFIG_MIPS_ISA_1 is not set
+# CONFIG_MIPS_ISA_2 is not set
+CONFIG_MIPS_ISA_3=y
+# CONFIG_MIPS_ISA_4 is not set
+# CONFIG_MIPS_ISA_MIPS32 is not set
+# CONFIG_MIPS_ISA_MIPS32R2 is not set
+# CONFIG_MIPS_ISA_MIPS64 is not set
+# CONFIG_MIPS_N32_ABI is not set
+# CONFIG_MIPS_N64_ABI is not set
+CONFIG_MIPS_O32_ABI=y
+TARGET_ARCH="mips"
+TARGET_mips=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/config-0.9.33.2/powerpc b/toolchain/uClibc/config-0.9.33.2/powerpc
new file mode 100644
index 0000000..5b1292d
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/powerpc
@@ -0,0 +1,6 @@
+ARCH_BIG_ENDIAN=y
+CONFIG_CLASSIC=y
+# CONFIG_E500 is not set
+TARGET_ARCH="powerpc"
+TARGET_SUBARCH="classic"
+TARGET_powerpc=y
diff --git a/toolchain/uClibc/config-0.9.33.2/powerpc.e500 b/toolchain/uClibc/config-0.9.33.2/powerpc.e500
new file mode 100644
index 0000000..a835c3d
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/powerpc.e500
@@ -0,0 +1,6 @@
+ARCH_BIG_ENDIAN=y
+# CONFIG_CLASSIC is not set
+CONFIG_E500=y
+TARGET_ARCH="powerpc"
+TARGET_SUBARCH="classic"
+TARGET_powerpc=y
diff --git a/toolchain/uClibc/config-0.9.33.2/sparc b/toolchain/uClibc/config-0.9.33.2/sparc
new file mode 100644
index 0000000..e1596c4
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/sparc
@@ -0,0 +1,8 @@
+ARCH_BIG_ENDIAN=y
+# CONFIG_SPARC_V7 is not set
+# CONFIG_SPARC_V8 is not set
+CONFIG_SPARC_V9=y
+# CONFIG_SPARC_V9B is not set
+TARGET_ARCH="sparc"
+TARGET_sparc=y
+UCLIBC_HAS_LONG_DOUBLE_MATH=y
diff --git a/toolchain/uClibc/config-0.9.33.2/sparc.leon b/toolchain/uClibc/config-0.9.33.2/sparc.leon
new file mode 100644
index 0000000..eb725ac
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/sparc.leon
@@ -0,0 +1,8 @@
+ARCH_BIG_ENDIAN=y
+# CONFIG_SPARC_V7 is not set
+CONFIG_SPARC_V8=y
+# CONFIG_SPARC_V9 is not set
+# CONFIG_SPARC_V9B is not set
+TARGET_ARCH="sparc"
+TARGET_sparc=y
+UCLIBC_HAS_LONG_DOUBLE_MATH=y
diff --git a/toolchain/uClibc/config-0.9.33.2/x86_64 b/toolchain/uClibc/config-0.9.33.2/x86_64
new file mode 100644
index 0000000..92f0e65
--- /dev/null
+++ b/toolchain/uClibc/config-0.9.33.2/x86_64
@@ -0,0 +1,6 @@
+ARCH_LITTLE_ENDIAN=y
+# LINUXTHREADS_NEW is not set
+TARGET_ARCH="x86_64"
+TARGET_x86_64=y
+UCLIBC_BSD_SPECIFIC=y
+UCLIBC_HAS_FPU=y
diff --git a/toolchain/uClibc/headers/Makefile b/toolchain/uClibc/headers/Makefile
new file mode 100644
index 0000000..67a2d95
--- /dev/null
+++ b/toolchain/uClibc/headers/Makefile
@@ -0,0 +1,26 @@
+PATH_PREFIX:=..
+
+include ../common.mk
+
+HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.headers_built
+HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc_headers_installed
+
+define Host/Compile
+
+endef
+
+define Host/Install
+ PATH='$(TARGET_PATH)' $(MAKE) -C $(HOST_BUILD_DIR) \
+ PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
+ DEVEL_PREFIX=/ \
+ RUNTIME_PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
+ HOSTCC="$(HOSTCC)" \
+ CC="$(TARGET_CC)" \
+ CPU_CFLAGS="$(TARGET_CFLAGS)" \
+ ARCH="$(CONFIG_ARCH)" \
+ pregen \
+ install_headers
+endef
+
+$(eval $(call HostBuild))
+
diff --git a/toolchain/uClibc/patches-0.9.33.2/009_backport_mount.h-update.patch b/toolchain/uClibc/patches-0.9.33.2/009_backport_mount.h-update.patch
new file mode 100644
index 0000000..47fb624
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/009_backport_mount.h-update.patch
@@ -0,0 +1,91 @@
+From 76ff037059f6d387bde9d540f7e27a2b376d7cd7 Mon Sep 17 00:00:00 2001
+From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+Date: Fri, 18 Jan 2013 11:12:49 +0100
+Subject: [PATCH] mount.h: update
+
+Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+---
+ include/sys/mount.h | 45 +++++++++++++++++++++++++++++++++++----------
+ 1 file changed, 35 insertions(+), 10 deletions(-)
+
+diff --git a/include/sys/mount.h b/include/sys/mount.h
+index fbd61fd..c0e7b84 100644
+--- a/include/sys/mount.h
++++ b/include/sys/mount.h
+@@ -1,5 +1,5 @@
+ /* Header file for mounting/unmount Linux filesystems.
+- Copyright (C) 1996,1997,1998,1999,2000,2004 Free Software Foundation, Inc.
++ Copyright (C) 1996-2000, 2004, 2010, 2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+@@ -46,23 +46,46 @@ enum
+ #define MS_REMOUNT MS_REMOUNT
+ MS_MANDLOCK = 64, /* Allow mandatory locks on an FS. */
+ #define MS_MANDLOCK MS_MANDLOCK
+- S_WRITE = 128, /* Write on file/directory/symlink. */
+-#define S_WRITE S_WRITE
+- S_APPEND = 256, /* Append-only file. */
+-#define S_APPEND S_APPEND
+- S_IMMUTABLE = 512, /* Immutable file. */
+-#define S_IMMUTABLE S_IMMUTABLE
++ MS_DIRSYNC = 128, /* Directory modifications are synchronous. */
++#define MS_DIRSYNC MS_DIRSYNC
+ MS_NOATIME = 1024, /* Do not update access times. */
+ #define MS_NOATIME MS_NOATIME
+ MS_NODIRATIME = 2048, /* Do not update directory access times. */
+ #define MS_NODIRATIME MS_NODIRATIME
+ MS_BIND = 4096, /* Bind directory at different place. */
+ #define MS_BIND MS_BIND
++ MS_MOVE = 8192,
++#define MS_MOVE MS_MOVE
++ MS_REC = 16384,
++#define MS_REC MS_REC
++ MS_SILENT = 32768,
++#define MS_SILENT MS_SILENT
++ MS_POSIXACL = 1 << 16, /* VFS does not apply the umask. */
++#define MS_POSIXACL MS_POSIXACL
++ MS_UNBINDABLE = 1 << 17, /* Change to unbindable. */
++#define MS_UNBINDABLE MS_UNBINDABLE
++ MS_PRIVATE = 1 << 18, /* Change to private. */
++#define MS_PRIVATE MS_PRIVATE
++ MS_SLAVE = 1 << 19, /* Change to slave. */
++#define MS_SLAVE MS_SLAVE
++ MS_SHARED = 1 << 20, /* Change to shared. */
++#define MS_SHARED MS_SHARED
++ MS_RELATIME = 1 << 21, /* Update atime relative to mtime/ctime. */
++#define MS_RELATIME MS_RELATIME
++ MS_KERNMOUNT = 1 << 22, /* This is a kern_mount call. */
++#define MS_KERNMOUNT MS_KERNMOUNT
++ MS_I_VERSION = 1 << 23, /* Update inode I_version field. */
++#define MS_I_VERSION MS_I_VERSION
++ MS_STRICTATIME = 1 << 24, /* Always perform atime updates. */
++#define MS_STRICTATIME MS_STRICTATIME
++ MS_ACTIVE = 1 << 30,
++#define MS_ACTIVE MS_ACTIVE
++ MS_NOUSER = 1 << 31
++#define MS_NOUSER MS_NOUSER
+ };
+
+ /* Flags that can be altered by MS_REMOUNT */
+-#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME \
+- |MS_NODIRATIME)
++#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION)
+
+
+ /* Magic mount flag number. Has to be or-ed to the flag values. */
+@@ -99,8 +122,10 @@ enum
+ #define MNT_FORCE MNT_FORCE
+ MNT_DETACH = 2, /* Just detach from the tree. */
+ #define MNT_DETACH MNT_DETACH
+- MNT_EXPIRE = 4 /* Mark for expiry. */
++ MNT_EXPIRE = 4, /* Mark for expiry. */
+ #define MNT_EXPIRE MNT_EXPIRE
++ UMOUNT_NOFOLLOW = 8 /* Don't follow symlink on umount. */
++#define UMOUNT_NOFOLLOW UMOUNT_NOFOLLOW
+ };
+
+
+--
+1.9.1
+
diff --git a/toolchain/uClibc/patches-0.9.33.2/010-backport_sscanf_alloc.patch b/toolchain/uClibc/patches-0.9.33.2/010-backport_sscanf_alloc.patch
new file mode 100644
index 0000000..b5ce091
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/010-backport_sscanf_alloc.patch
@@ -0,0 +1,184 @@
+From 8cfb43de636faa401634340d1a18404844f9ba5a Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier@gentoo.org>
+Date: Sun, 6 May 2012 03:50:44 -0400
+Subject: [PATCH] stdio: implement assignment-allocation "m" character
+
+The latest POSIX spec introduces a "m" character to allocate buffers for
+the user when using scanf type functions. This is like the old glibc "a"
+flag, but now standardized. With packages starting to use these, we need
+to implement it.
+
+for example:
+ char *s;
+ sscanf("foo", "%ms", &s);
+ printf("%s\n", s);
+ free(s);
+This will automatically allocate storage for "s", read in "foo" to it,
+and then display it.
+
+I'm not terribly familiar with the stdio layer, so this could be wrong.
+But it seems to work for me.
+
+Signed-off-by: Mike Frysinger <vapier@gentoo.org>
+Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+---
+ extra/Configs/Config.in | 13 ----------
+ libc/stdio/_scanf.c | 68 ++++++++++++++++++++++++++++---------------------
+ 2 files changed, 39 insertions(+), 42 deletions(-)
+
+--- a/extra/Configs/Config.in
++++ b/extra/Configs/Config.in
+@@ -1590,19 +1590,6 @@ config UCLIBC_PRINTF_SCANF_POSITIONAL_AR
+
+ Most people will answer 9.
+
+-
+-config UCLIBC_HAS_SCANF_GLIBC_A_FLAG
+- bool "Support glibc's 'a' flag for scanf string conversions (not implemented)"
+- help
+- NOTE!!! Currently Not Implemented!!! Just A Place Holder!! NOTE!!!
+- NOTE!!! Conflicts with an ANSI/ISO C99 scanf flag!! NOTE!!!
+-
+- Answer Y to enable support for glibc's 'a' flag for the scanf string
+- conversions '%s', '%[', '%ls', '%l[', and '%S'. This is used to
+- auto-allocate sufficient memory to hold the data retrieved.
+-
+- Most people will answer N.
+-
+ choice
+ prompt "Stdio buffer size"
+ default UCLIBC_HAS_STDIO_BUFSIZ_4096
+--- a/libc/stdio/_scanf.c
++++ b/libc/stdio/_scanf.c
+@@ -77,14 +77,6 @@
+ #include <bits/uClibc_fpmax.h>
+ #endif /* __UCLIBC_HAS_FLOATS__ */
+
+-#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
+-#ifdef L_vfscanf
+-/* only emit this once */
+-#warning Forcing undef of __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ until implemented!
+-#endif
+-#undef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
+-#endif
+-
+ #undef __STDIO_HAS_VSSCANF
+ #if defined(__STDIO_BUFFERS) || !defined(__UCLIBC_HAS_WCHAR__) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
+ #define __STDIO_HAS_VSSCANF 1
+@@ -433,8 +425,9 @@ libc_hidden_def(vswscanf)
+
+
+ /* float layout 0123456789012345678901 repeat n for "l[" */
+-#define SPEC_CHARS "npxXoudifFeEgGaACSncs["
+-/* npxXoudif eEgG CS cs[ */
++#define SPEC_CHARS "npxXoudifFeEgGaACSnmcs["
++/* npxXoudif eEgG CS cs[ */
++/* NOTE: the 'm' flag must come before any convs that support it */
+
+ /* NOTE: Ordering is important! In particular, CONV_LEFTBRACKET
+ * must immediately precede CONV_c. */
+@@ -444,7 +437,7 @@ enum {
+ CONV_p,
+ CONV_x, CONV_X, CONV_o, CONV_u, CONV_d, CONV_i,
+ CONV_f, CONV_F, CONV_e, CONV_E, CONV_g, CONV_G, CONV_a, CONV_A,
+- CONV_C, CONV_S, CONV_LEFTBRACKET, CONV_c, CONV_s, CONV_leftbracket,
++ CONV_C, CONV_S, CONV_LEFTBRACKET, CONV_m, CONV_c, CONV_s, CONV_leftbracket,
+ CONV_percent, CONV_whitespace /* not in SPEC_* and no flags */
+ };
+
+@@ -474,7 +467,7 @@ enum {
+ FLAG_SURPRESS = 0x10, /* MUST BE 1ST!! See DO_FLAGS. */
+ FLAG_THOUSANDS = 0x20,
+ FLAG_I18N = 0x40, /* only works for d, i, u */
+- FLAG_MALLOC = 0x80, /* only works for s, S, and [ (and l[)*/
++ FLAG_MALLOC = 0x80, /* only works for c, s, S, and [ (and l[)*/
+ };
+
+
+@@ -491,7 +484,7 @@ enum {
+ /* fFeEgGaA */ (0x0c|FLAG_SURPRESS|FLAG_THOUSANDS|FLAG_I18N), \
+ /* C */ ( 0|FLAG_SURPRESS), \
+ /* S and l[ */ ( 0|FLAG_SURPRESS|FLAG_MALLOC), \
+- /* c */ (0x04|FLAG_SURPRESS), \
++ /* c */ (0x04|FLAG_SURPRESS|FLAG_MALLOC), \
+ /* s and [ */ (0x04|FLAG_SURPRESS|FLAG_MALLOC), \
+ }
+
+@@ -904,17 +897,17 @@ int attribute_hidden __psfs_parse_spec(r
+ if (*psfs->fmt == *p) {
+ int p_m_spec_chars = p - spec_chars;
+
+-#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
+-#error implement gnu a flag
+- if ((*p == 'a')
+- && ((psfs->fmt[1] == '[') || ((psfs->fmt[1]|0x20) == 's'))
+- ) { /* Assumes ascii for 's' and 'S' test. */
+- psfs->flags |= FLAG_MALLOC;
++ if (*p == 'm' &&
++ (psfs->fmt[1] == '[' || psfs->fmt[1] == 'c' ||
++ /* Assumes ascii for 's' and 'S' test. */
++ (psfs->fmt[1] | 0x20) == 's'))
++ {
++ if (psfs->store)
++ psfs->flags |= FLAG_MALLOC;
+ ++psfs->fmt;
+ ++p;
+- continue; /* The related conversions follow 'a'. */
++ continue; /* The related conversions follow 'm'. */
+ }
+-#endif /* __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ */
+
+ for (p = spec_ranges; p_m_spec_chars > *p ; ++p) {}
+ if (((psfs->dataargtype >> 8) | psfs->flags)
+@@ -1265,12 +1258,6 @@ int VFSCANF (FILE *__restrict fp, const
+ while (*wf && __isascii(*wf) && (b < buf + sizeof(buf) - 1)) {
+ *b++ = *wf++;
+ }
+-#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
+-#error this is wrong... we need to ched in __psfs_parse_spec instead since this checks last char in buffer and conversion my have stopped before it.
+- if ((*b == 'a') && ((*wf == '[') || ((*wf|0x20) == 's'))) {
+- goto DONE; /* Spec was excessively long. */
+- }
+-#endif /* __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ */
+ *b = 0;
+ if (b == buf) { /* Bad conversion specifier! */
+ goto DONE;
+@@ -1390,13 +1377,36 @@ int VFSCANF (FILE *__restrict fp, const
+ }
+
+ if (psfs.conv_num == CONV_s) {
++ /* We might have to handle the allocation ourselves */
++ int len;
++ /* With 'm', we actually got a pointer to a pointer */
++ unsigned char **ptr = (void *)b;
++
++ i = 0;
++ if (psfs.flags & FLAG_MALLOC) {
++ len = 0;
++ b = NULL;
++ } else
++ len = -1;
++
+ /* Yes, believe it or not, a %s conversion can store nuls. */
+ while ((__scan_getc(&sc) >= 0) && !isspace(sc.cc)) {
+ zero_conversions = 0;
+- *b = sc.cc;
+- b += psfs.store;
++ if (i == len) {
++ /* Pick a size that won't trigger a lot of
++ * mallocs early on ... */
++ len += 256;
++ b = realloc(b, len + 1);
++ }
++ b[i] = sc.cc;
++ i += psfs.store;
+ fail = 0;
+ }
++
++ if (psfs.flags & FLAG_MALLOC)
++ *ptr = b;
++ /* The code below takes care of terminating NUL */
++ b += i;
+ } else {
+ #ifdef __UCLIBC_HAS_WCHAR__
+ assert((psfs.conv_num == CONV_LEFTBRACKET) || \
diff --git a/toolchain/uClibc/patches-0.9.33.2/011-dlsym_rtld_next_fix.patch b/toolchain/uClibc/patches-0.9.33.2/011-dlsym_rtld_next_fix.patch
new file mode 100644
index 0000000..f1a8ff5
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/011-dlsym_rtld_next_fix.patch
@@ -0,0 +1,25 @@
+--- a/ldso/libdl/libdl.c
++++ b/ldso/libdl/libdl.c
+@@ -671,7 +671,7 @@ static void *do_dlsym(void *vhandle, con
+ {
+ struct elf_resolve *tpnt, *tfrom;
+ struct dyn_elf *handle;
+- ElfW(Addr) from;
++ ElfW(Addr) from = 0;
+ struct dyn_elf *rpnt;
+ void *ret;
+ struct symbol_ref sym_ref = { NULL, NULL };
+@@ -729,7 +729,12 @@ static void *do_dlsym(void *vhandle, con
+ tpnt = NULL;
+ if (handle == _dl_symbol_tables)
+ tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */
+- ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref);
++ do {
++ ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref);
++ if (ret != NULL)
++ break;
++ handle = handle->next;
++ } while (from && handle);
+
+ #if defined(USE_TLS) && USE_TLS && defined SHARED
+ if (sym_ref.sym && (ELF_ST_TYPE(sym_ref.sym->st_info) == STT_TLS) && (sym_ref.tpnt)) {
diff --git a/toolchain/uClibc/patches-0.9.33.2/012-elf-Add-STT_GNU_IFUNC-from-glibc.patch b/toolchain/uClibc/patches-0.9.33.2/012-elf-Add-STT_GNU_IFUNC-from-glibc.patch
new file mode 100644
index 0000000..6cecfaa
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/012-elf-Add-STT_GNU_IFUNC-from-glibc.patch
@@ -0,0 +1,37 @@
+From be58779614b2fe9aa57a9315be9dc004dfd77b3b Mon Sep 17 00:00:00 2001
+From: Vineet Gupta <vgupta@synopsys.com>
+Date: Fri, 20 Feb 2015 15:27:08 +0530
+Subject: [PATCH] elf: Add STT_GNU_IFUNC from glibc
+
+perf in upstream Linux kernel 3.17 onwards expects STT_GNU_IFUNC
+replicate it from glibc
+
+Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
+Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+---
+ include/elf.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/include/elf.h b/include/elf.h
+index facf09c..917930b 100644
+--- a/include/elf.h
++++ b/include/elf.h
+@@ -566,6 +566,7 @@ typedef struct
+ #define STB_WEAK 2 /* Weak symbol */
+ #define STB_NUM 3 /* Number of defined types. */
+ #define STB_LOOS 10 /* Start of OS-specific */
++#define STB_GNU_UNIQUE 10 /* Unique symbol. */
+ #define STB_HIOS 12 /* End of OS-specific */
+ #define STB_LOPROC 13 /* Start of processor-specific */
+ #define STB_HIPROC 15 /* End of processor-specific */
+@@ -581,6 +582,7 @@ typedef struct
+ #define STT_TLS 6 /* Symbol is thread-local data object*/
+ #define STT_NUM 7 /* Number of defined types. */
+ #define STT_LOOS 10 /* Start of OS-specific */
++#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */
+ #define STT_HIOS 12 /* End of OS-specific */
+ #define STT_LOPROC 13 /* Start of processor-specific */
+ #define STT_HIPROC 15 /* End of processor-specific */
+--
+2.1.4
+
diff --git a/toolchain/uClibc/patches-0.9.33.2/020-endian.h-add-some-handy-macros-to-be-used-in-syscall.patch b/toolchain/uClibc/patches-0.9.33.2/020-endian.h-add-some-handy-macros-to-be-used-in-syscall.patch
new file mode 100644
index 0000000..7201041
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/020-endian.h-add-some-handy-macros-to-be-used-in-syscall.patch
@@ -0,0 +1,28 @@
+From: "Peter S. Mazinger" <ps.m@gmx.net>
+Date: Thu, 21 Apr 2011 21:20:55 +0200
+Subject: [PATCH] endian.h: add some handy macros to be used in syscalls
+
+Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
+Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+---
+
+--- a/include/endian.h
++++ b/include/endian.h
+@@ -55,6 +55,17 @@
+ # define __LONG_LONG_PAIR(HI, LO) HI, LO
+ #endif
+
++#ifdef _LIBC
++# ifndef __ASSEMBLER__
++# include <stdint.h>
++# define OFF_HI(offset) (offset >> 31)
++# define OFF_LO(offset) (offset)
++# define OFF64_HI(offset) (uint32_t)(offset >> 32)
++# define OFF64_LO(offset) (uint32_t)(offset & 0xffffffff)
++# define OFF_HI_LO(offset) __LONG_LONG_PAIR(OFF_HI(offset), OFF_LO(offset))
++# define OFF64_HI_LO(offset) __LONG_LONG_PAIR(OFF64_HI(offset), OFF64_LO(offset))
++# endif
++#endif
+
+ #ifdef __USE_BSD
+ /* Conversion interfaces. */
diff --git a/toolchain/uClibc/patches-0.9.33.2/021-add-posix_madvise.c.patch b/toolchain/uClibc/patches-0.9.33.2/021-add-posix_madvise.c.patch
new file mode 100644
index 0000000..2b18c25
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/021-add-posix_madvise.c.patch
@@ -0,0 +1,48 @@
+From: "Peter S. Mazinger" <ps.m@gmx.net>
+Date: Tue, 26 Apr 2011 23:03:44 +0200
+Subject: [PATCH] add posix_madvise.c
+
+Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
+Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+---
+ create mode 100644 libc/sysdeps/linux/common/posix_madvise.c
+
+--- a/libc/sysdeps/linux/common/Makefile.in
++++ b/libc/sysdeps/linux/common/Makefile.in
+@@ -81,7 +81,7 @@ CSRC-$(UCLIBC_HAS_REALTIME) += clock_get
+ sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c \
+ sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c sigqueue.c
+ # clock_getcpuclockid|clock_nanosleep|mq_timedreceive|mq_timedsend|posix_fadvise|posix_fallocate|posix_madvise|posix_memalign|posix_mem_offset|posix_spawnattr_destroy|posix_spawnattr_init|posix_spawnattr_getflags|posix_spawnattr_setflags|posix_spawnattr_getpgroup|posix_spawnattr_setpgroup|posix_spawnattr_getschedparam|posix_spawnattr_setschedparam|posix_spawnattr_getschedpolicy|posix_spawnattr_setschedpolicy|posix_spawnattr_getsigdefault|posix_spawnattr_setsigdefault|posix_spawnattr_getsigmask|posix_spawnattr_setsigmask|posix_spawnattr_init|posix_spawnattr_setflags|posix_spawnattr_setpgroup|posix_spawnattr_setschedparam|posix_spawnattr_setschedpolicy|posix_spawnattr_setsigdefault|posix_spawnattr_setsigmask|posix_spawn_file_actions_addclose|posix_spawn_file_actions_addopen|posix_spawn_file_actions_adddup2|posix_spawn_file_actions_addopen|posix_spawn_file_actions_destroy|posix_spawn_file_actions_init|posix_spawn_file_actions_init|posix_spawn|posix_spawnp|posix_spawnp|posix_typed_mem_get_info|pthread_mutex_timedlock|sem_timedwait
+-CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c
++CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c
+ CSRC-$(UCLIBC_SUSV4_LEGACY) += utime.c
+ CSRC-$(UCLIBC_HAS_EPOLL) += epoll.c
+ CSRC-$(UCLIBC_HAS_XATTR) += xattr.c
+--- /dev/null
++++ b/libc/sysdeps/linux/common/posix_madvise.c
+@@ -0,0 +1,25 @@
++/* vi: set sw=4 ts=4: */
++/* Licensed under the LGPL v2.1, see the file LICENSE in this tarball. */
++
++#include <sys/mman.h>
++#include <sys/syscall.h>
++
++#if defined __NR_madvise && defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
++int posix_madvise(void *addr, size_t len, int advice)
++{
++ int result;
++ /* We have one problem: the kernel's MADV_DONTNEED does not
++ * correspond to POSIX's POSIX_MADV_DONTNEED. The former simply
++ * discards changes made to the memory without writing it back to
++ * disk, if this would be necessary. The POSIX behaviour does not
++ * allow this. There is no functionality mapping for the POSIX
++ * behaviour so far so we ignore that advice for now. */
++ if (advice == POSIX_MADV_DONTNEED)
++ return 0;
++
++ /* this part might use madvise function */
++ INTERNAL_SYSCALL_DECL (err);
++ result = INTERNAL_SYSCALL (madvise, err, 3, addr, len, advice);
++ return INTERNAL_SYSCALL_ERRNO (result, err);
++}
++#endif
diff --git a/toolchain/uClibc/patches-0.9.33.2/022-libc-add-posix_fallocate.patch b/toolchain/uClibc/patches-0.9.33.2/022-libc-add-posix_fallocate.patch
new file mode 100644
index 0000000..504405a
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/022-libc-add-posix_fallocate.patch
@@ -0,0 +1,301 @@
+From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+Date: Tue, 17 Apr 2012 09:30:15 +0200
+Subject: [PATCH] libc: add posix_fallocate()
+
+Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+---
+ create mode 100644 libc/sysdeps/linux/common/posix_fallocate.c
+ create mode 100644 libc/sysdeps/linux/common/posix_fallocate64.c
+ create mode 100644 test/unistd/tst-posix_fallocate.c
+ create mode 100644 test/unistd/tst-posix_fallocate64.c
+
+--- a/include/fcntl.h
++++ b/include/fcntl.h
+@@ -210,9 +210,7 @@ extern int posix_fadvise64 (int __fd, __
+
+ #endif
+
+-#if 0 /* && defined __UCLIBC_HAS_ADVANCED_REALTIME__ */
+-
+-/* FIXME -- uClibc should probably implement these... */
++#if defined __UCLIBC_HAS_ADVANCED_REALTIME__
+
+ /* Reserve storage for the data of the file associated with FD.
+
+--- a/libc/sysdeps/linux/common/Makefile.in
++++ b/libc/sysdeps/linux/common/Makefile.in
+@@ -81,7 +81,8 @@ CSRC-$(UCLIBC_HAS_REALTIME) += clock_get
+ sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c \
+ sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c sigqueue.c
+ # clock_getcpuclockid|clock_nanosleep|mq_timedreceive|mq_timedsend|posix_fadvise|posix_fallocate|posix_madvise|posix_memalign|posix_mem_offset|posix_spawnattr_destroy|posix_spawnattr_init|posix_spawnattr_getflags|posix_spawnattr_setflags|posix_spawnattr_getpgroup|posix_spawnattr_setpgroup|posix_spawnattr_getschedparam|posix_spawnattr_setschedparam|posix_spawnattr_getschedpolicy|posix_spawnattr_setschedpolicy|posix_spawnattr_getsigdefault|posix_spawnattr_setsigdefault|posix_spawnattr_getsigmask|posix_spawnattr_setsigmask|posix_spawnattr_init|posix_spawnattr_setflags|posix_spawnattr_setpgroup|posix_spawnattr_setschedparam|posix_spawnattr_setschedpolicy|posix_spawnattr_setsigdefault|posix_spawnattr_setsigmask|posix_spawn_file_actions_addclose|posix_spawn_file_actions_addopen|posix_spawn_file_actions_adddup2|posix_spawn_file_actions_addopen|posix_spawn_file_actions_destroy|posix_spawn_file_actions_init|posix_spawn_file_actions_init|posix_spawn|posix_spawnp|posix_spawnp|posix_typed_mem_get_info|pthread_mutex_timedlock|sem_timedwait
+-CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c
++CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c \
++ posix_fallocate.c posix_fallocate64.c
+ CSRC-$(UCLIBC_SUSV4_LEGACY) += utime.c
+ CSRC-$(UCLIBC_HAS_EPOLL) += epoll.c
+ CSRC-$(UCLIBC_HAS_XATTR) += xattr.c
+--- a/libc/sysdeps/linux/common/bits/kernel-features.h
++++ b/libc/sysdeps/linux/common/bits/kernel-features.h
+@@ -494,6 +494,14 @@
+ # define __ASSUME_PRIVATE_FUTEX 1
+ #endif
+
++/* Support for fallocate was added in 2.6.23,
++ on s390 only after 2.6.23-rc1, on alpha only after 2.6.33-rc1. */
++#if __LINUX_KERNEL_VERSION >= 0x020617 \
++ && (!defined __s390__ || __LINUX_KERNEL_VERSION >= 0x020618) \
++ && (!defined __alpha__ || __LINUX_KERNEL_VERSION >= 0x020621)
++# define __ASSUME_FALLOCATE 1
++#endif
++
+ /* getcpu is a syscall for x86-64 since 3.1. */
+ #if defined __x86_64__ && __LINUX_KERNEL_VERSION >= 0x030100
+ # define __ASSUME_GETCPU_SYSCALL 1
+--- /dev/null
++++ b/libc/sysdeps/linux/common/posix_fallocate.c
+@@ -0,0 +1,43 @@
++/* vi: set sw=4 ts=4: */
++/*
++ * posix_fallocate() for uClibc
++ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
++ *
++ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
++ *
++ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
++ */
++
++#include <sys/syscall.h>
++#include <fcntl.h>
++#include <bits/kernel-features.h>
++#include <stdint.h>
++
++#if defined __NR_fallocate
++int posix_fallocate(int fd, __off_t offset, __off_t len)
++{
++ int ret;
++
++# if __WORDSIZE == 32
++ uint32_t off_low = offset;
++ uint32_t len_low = len;
++ /* may assert that these >>31 are 0 */
++ uint32_t zero = 0;
++ INTERNAL_SYSCALL_DECL(err);
++ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0,
++ __LONG_LONG_PAIR (zero, off_low),
++ __LONG_LONG_PAIR (zero, len_low)));
++# elif __WORDSIZE == 64
++ INTERNAL_SYSCALL_DECL(err);
++ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 4, fd, 0, offset, len));
++# else
++# error your machine is neither 32 bit or 64 bit ... it must be magical
++#endif
++ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err)))
++ return INTERNAL_SYSCALL_ERRNO (ret, err);
++ return 0;
++}
++# if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
++strong_alias(posix_fallocate,posix_fallocate64)
++# endif
++#endif
+--- /dev/null
++++ b/libc/sysdeps/linux/common/posix_fallocate64.c
+@@ -0,0 +1,39 @@
++/* vi: set sw=4 ts=4: */
++/*
++ * posix_fallocate() for uClibc
++ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
++ *
++ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
++ *
++ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
++ */
++
++#include <sys/syscall.h>
++#include <fcntl.h>
++#include <bits/kernel-features.h>
++#include <stdint.h>
++
++#if defined __NR_fallocate
++
++# if __WORDSIZE == 64
++/* Can use normal posix_fallocate() */
++# elif __WORDSIZE == 32
++int posix_fallocate64(int fd, __off64_t offset, __off64_t len)
++{
++ int ret;
++ uint32_t off_low = offset & 0xffffffff;
++ uint32_t off_high = offset >> 32;
++ uint32_t len_low = len & 0xffffffff;
++ uint32_t len_high = len >> 32;
++ INTERNAL_SYSCALL_DECL(err);
++ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0,
++ __LONG_LONG_PAIR (off_high, off_low),
++ __LONG_LONG_PAIR (len_high, len_low)));
++ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err)))
++ return INTERNAL_SYSCALL_ERRNO (ret, err);
++ return 0;
++}
++# else
++# error your machine is neither 32 bit or 64 bit ... it must be magical
++# endif
++#endif
+--- a/test/.gitignore
++++ b/test/.gitignore
+@@ -302,6 +302,8 @@ unistd/getcwd
+ unistd/getopt
+ unistd/getopt_long
+ unistd/tstgetopt
++unistd/tst-posix_fallocate
++unistd/tst-posix_fallocate64
+ unistd/tst-preadwrite
+ unistd/tst-preadwrite64
+ unistd/vfork
+--- a/test/unistd/Makefile.in
++++ b/test/unistd/Makefile.in
+@@ -2,7 +2,10 @@
+ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+ ifeq ($(UCLIBC_HAS_LFS),)
+-TESTS_DISABLED := tst-preadwrite64
++TESTS_DISABLED := tst-preadwrite64 tst-posix_fallocate64
++endif
++ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),)
++TESTS_DISABLED := tst-posix_fallocate
+ endif
+ OPTS_getopt := -abcXXX -9
+ OPTS_getopt_long := --add XXX --delete YYY --verbose
+--- /dev/null
++++ b/test/unistd/tst-posix_fallocate.c
+@@ -0,0 +1,127 @@
++#include <fcntl.h>
++#include <sys/stat.h>
++
++#ifndef TST_POSIX_FALLOCATE64
++# define stat64 stat
++# define fstat64 fstat
++# else
++# ifndef O_LARGEFILE
++# error no O_LARGEFILE but you want to test with LFS enabled
++# endif
++#endif
++
++static void do_prepare (void);
++#define PREPARE(argc, argv) do_prepare ()
++static int do_test (void);
++#define TEST_FUNCTION do_test ()
++#include <test-skeleton.c>
++
++static int fd;
++static void
++do_prepare (void)
++{
++ fd = create_temp_file ("tst-posix_fallocate.", NULL);
++ if (fd == -1)
++ {
++ printf ("cannot create temporary file: %m\n");
++ exit (1);
++ }
++}
++
++
++static int
++do_test (void)
++{
++ struct stat64 st;
++
++ if (fstat64 (fd, &st) != 0)
++ {
++ puts ("1st fstat failed");
++ return 1;
++ }
++
++ if (st.st_size != 0)
++ {
++ puts ("file not created with size 0");
++ return 1;
++ }
++
++ if (posix_fallocate (fd, 512, 768) != 0)
++ {
++ puts ("1st posix_fallocate call failed");
++ return 1;
++ }
++
++ if (fstat64 (fd, &st) != 0)
++ {
++ puts ("2nd fstat failed");
++ return 1;
++ }
++
++ if (st.st_size != 512 + 768)
++ {
++ printf ("file size after 1st posix_fallocate call is %llu, expected %u\n",
++ (unsigned long long int) st.st_size, 512u + 768u);
++ return 1;
++ }
++
++ if (posix_fallocate (fd, 0, 1024) != 0)
++ {
++ puts ("2nd posix_fallocate call failed");
++ return 1;
++ }
++
++ if (fstat64 (fd, &st) != 0)
++ {
++ puts ("3rd fstat failed");
++ return 1;
++ }
++
++ if (st.st_size != 512 + 768)
++ {
++ puts ("file size changed in 2nd posix_fallocate");
++ return 1;
++ }
++
++ if (posix_fallocate (fd, 2048, 64) != 0)
++ {
++ puts ("3rd posix_fallocate call failed");
++ return 1;
++ }
++
++ if (fstat64 (fd, &st) != 0)
++ {
++ puts ("4th fstat failed");
++ return 1;
++ }
++
++ if (st.st_size != 2048 + 64)
++ {
++ printf ("file size after 3rd posix_fallocate call is %llu, expected %u\n",
++ (unsigned long long int) st.st_size, 2048u + 64u);
++ return 1;
++ }
++#ifdef TST_POSIX_FALLOCATE64
++ if (posix_fallocate64 (fd, 4097ULL, 4294967295ULL + 2ULL) != 0)
++ {
++ puts ("4th posix_fallocate call failed");
++ return 1;
++ }
++
++ if (fstat64 (fd, &st) != 0)
++ {
++ puts ("5th fstat failed");
++ return 1;
++ }
++
++ if (st.st_size != 4097ULL + 4294967295ULL + 2ULL)
++ {
++ printf ("file size after 4th posix_fallocate call is %llu, expected %llu\n",
++ (unsigned long long int) st.st_size, 4097ULL + 4294967295ULL + 2ULL);
++ return 1;
++ }
++#endif
++ close (fd);
++
++ return 0;
++}
+--- /dev/null
++++ b/test/unistd/tst-posix_fallocate64.c
+@@ -0,0 +1,2 @@
++#define TST_POSIX_FALLOCATE64
++#include "tst-posix_fallocate.c"
diff --git a/toolchain/uClibc/patches-0.9.33.2/023-libc-add-fallocate-and-fallocate64.patch b/toolchain/uClibc/patches-0.9.33.2/023-libc-add-fallocate-and-fallocate64.patch
new file mode 100644
index 0000000..282b64f
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/023-libc-add-fallocate-and-fallocate64.patch
@@ -0,0 +1,447 @@
+From: "Anthony G. Basile" <blueness@gentoo.org>
+Date: Sun, 7 Sep 2014 15:33:46 -0400
+Subject: [PATCH] libc: add fallocate() and fallocate64()
+
+We add the Linux-specific function fallocate() which allows the user to
+directly manipulate allocate space for a file. fallocate() can operate
+in different modes, but the default mode is equivalent to posix_fallocate()
+which is specified in POSIX.1.
+
+Recent releases of e2fsprogs 1.42.11 and above expect fallocate64() to be
+available.
+
+Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
+Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+---
+ create mode 100644 libc/sysdeps/linux/common/fallocate.c
+ create mode 100644 libc/sysdeps/linux/common/fallocate64.c
+ create mode 100644 test/unistd/tst-fallocate.c
+ create mode 100644 test/unistd/tst-fallocate64.c
+
+--- a/extra/Configs/Config.in
++++ b/extra/Configs/Config.in
+@@ -952,8 +952,8 @@ config UCLIBC_LINUX_SPECIFIC
+ default y
+ help
+ accept4(), bdflush(),
+- capget(), capset(), eventfd(), fstatfs(),
+- inotify_*(), ioperm(), iopl(),
++ capget(), capset(), eventfd(), fallocate(),
++ fstatfs(), inotify_*(), ioperm(), iopl(),
+ madvise(), modify_ldt(), pipe2(), personality(),
+ prctl()/arch_prctl(), pivot_root(), modify_ldt(),
+ ppoll(), readahead(), reboot(), remap_file_pages(),
+--- a/include/fcntl.h
++++ b/include/fcntl.h
+@@ -237,6 +237,38 @@ extern int __fcntl_nocancel (int fd, int
+ libc_hidden_proto(__fcntl_nocancel)
+ #endif
+
++#if (defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU) || defined _LIBC
++/* Reserve storage for the data of a file associated with FD. This function
++ is Linux-specific. For the portable version, use posix_fallocate().
++ Unlike the latter, fallocate can operate in different modes. The default
++ mode = 0 is equivalent to posix_fallocate().
++
++ Note: These declarations are used in posix_fallocate.c and
++ posix_fallocate64.c, so we expose them internally.
++ */
++
++/* Flags for fallocate's mode. */
++# define FALLOC_FL_KEEP_SIZE 1 /* Don't extend size of file
++ even if offset + len is
++ greater than file size. */
++# define FALLOC_FL_PUNCH_HOLE 2 /* Create a hole in the file. */
++
++# ifndef __USE_FILE_OFFSET64
++extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len);
++# else
++# ifdef __REDIRECT
++extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset,
++ __off64_t __len),
++ fallocate64);
++# else
++# define fallocate fallocate64
++# endif
++# endif
++# ifdef __USE_LARGEFILE64
++extern int fallocate64 (int __fd, int __mode, __off64_t __offset, __off64_t __len);
++# endif
++#endif
++
+ __END_DECLS
+
+ #endif /* fcntl.h */
+--- a/libc/sysdeps/linux/common/Makefile.in
++++ b/libc/sysdeps/linux/common/Makefile.in
+@@ -61,6 +61,10 @@ CSRC-$(UCLIBC_LINUX_SPECIFIC) += \
+ vmsplice.c
+ CSRC-$(if $(findstring yy,$(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_LFS)),y) += \
+ sendfile64.c
++# posix_fallocate() needs __libc_fallocate() from fallocate.c
++# posix_fallocate64() needs __libc_fallocate64() from fallocate64.c
++CSRC-$(if $(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_ADVANCED_REALTIME),y,) += \
++ fallocate.c $(filter fallocate64.c,$(CSRC-y))
+ # NPTL needs these internally: madvise.c
+ CSRC-$(findstring y,$(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_THREADS_NATIVE)) += madvise.c
+ ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+--- /dev/null
++++ b/libc/sysdeps/linux/common/fallocate.c
+@@ -0,0 +1,48 @@
++/* vi: set sw=4 ts=4: */
++/*
++ * fallocate() for uClibc - Based off of posix_fallocate() by Erik Andersen
++ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
++ *
++ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
++ *
++ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
++ */
++
++#include <sys/syscall.h>
++#include <fcntl.h>
++#include <bits/kernel-features.h>
++#include <stdint.h>
++
++#if defined __NR_fallocate
++extern __typeof(fallocate) __libc_fallocate attribute_hidden;
++int attribute_hidden __libc_fallocate(int fd, int mode, __off_t offset, __off_t len)
++{
++ int ret;
++
++# if __WORDSIZE == 32
++ uint32_t off_low = offset;
++ uint32_t len_low = len;
++ /* may assert that these >>31 are 0 */
++ uint32_t zero = 0;
++ INTERNAL_SYSCALL_DECL(err);
++ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, mode,
++ __LONG_LONG_PAIR (zero, off_low),
++ __LONG_LONG_PAIR (zero, len_low)));
++# elif __WORDSIZE == 64
++ INTERNAL_SYSCALL_DECL(err);
++ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 4, fd, mode, offset, len));
++# else
++# error your machine is neither 32 bit or 64 bit ... it must be magical
++# endif
++ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err)))
++ return INTERNAL_SYSCALL_ERRNO (ret, err);
++ return 0;
++}
++
++# if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
++strong_alias(__libc_fallocate,fallocate)
++# if __WORDSIZE == 64
++strong_alias(__libc_fallocate,fallocate64)
++# endif
++# endif
++#endif
+--- /dev/null
++++ b/libc/sysdeps/linux/common/fallocate64.c
+@@ -0,0 +1,42 @@
++/* vi: set sw=4 ts=4: */
++/*
++ * fallocate() for uClibc - based off posix_fallocate() by Erik Andersen
++ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
++ *
++ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
++ *
++ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
++ */
++
++#include <sys/syscall.h>
++
++#include <fcntl.h>
++#include <bits/kernel-features.h>
++#include <stdint.h>
++
++#if defined __NR_fallocate
++
++# if __WORDSIZE == 64
++/* Can use normal fallocate() */
++# elif __WORDSIZE == 32
++extern __typeof(fallocate64) __libc_fallocate64 attribute_hidden;
++int attribute_hidden __libc_fallocate64(int fd, int mode, __off64_t offset,
++ __off64_t len)
++{
++ int ret;
++ INTERNAL_SYSCALL_DECL(err);
++ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, mode,
++ OFF64_HI_LO (offset), OFF64_HI_LO (len)));
++ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err)))
++ return INTERNAL_SYSCALL_ERRNO (ret, err);
++ return 0;
++}
++
++# if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
++strong_alias(__libc_fallocate64,fallocate64)
++# endif
++
++# else
++# error your machine is neither 32 bit or 64 bit ... it must be magical
++# endif
++#endif
+--- a/libc/sysdeps/linux/common/posix_fallocate.c
++++ b/libc/sysdeps/linux/common/posix_fallocate.c
+@@ -14,28 +14,10 @@
+ #include <stdint.h>
+
+ #if defined __NR_fallocate
++extern __typeof(fallocate) __libc_fallocate attribute_hidden;
+ int posix_fallocate(int fd, __off_t offset, __off_t len)
+ {
+- int ret;
+-
+-# if __WORDSIZE == 32
+- uint32_t off_low = offset;
+- uint32_t len_low = len;
+- /* may assert that these >>31 are 0 */
+- uint32_t zero = 0;
+- INTERNAL_SYSCALL_DECL(err);
+- ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0,
+- __LONG_LONG_PAIR (zero, off_low),
+- __LONG_LONG_PAIR (zero, len_low)));
+-# elif __WORDSIZE == 64
+- INTERNAL_SYSCALL_DECL(err);
+- ret = (int) (INTERNAL_SYSCALL(fallocate, err, 4, fd, 0, offset, len));
+-# else
+-# error your machine is neither 32 bit or 64 bit ... it must be magical
+-#endif
+- if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err)))
+- return INTERNAL_SYSCALL_ERRNO (ret, err);
+- return 0;
++ return __libc_fallocate(fd, 0, offset, len);
+ }
+ # if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
+ strong_alias(posix_fallocate,posix_fallocate64)
+--- a/libc/sysdeps/linux/common/posix_fallocate64.c
++++ b/libc/sysdeps/linux/common/posix_fallocate64.c
+@@ -18,22 +18,12 @@
+ # if __WORDSIZE == 64
+ /* Can use normal posix_fallocate() */
+ # elif __WORDSIZE == 32
++extern __typeof(fallocate64) __libc_fallocate64 attribute_hidden;
+ int posix_fallocate64(int fd, __off64_t offset, __off64_t len)
+ {
+- int ret;
+- uint32_t off_low = offset & 0xffffffff;
+- uint32_t off_high = offset >> 32;
+- uint32_t len_low = len & 0xffffffff;
+- uint32_t len_high = len >> 32;
+- INTERNAL_SYSCALL_DECL(err);
+- ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0,
+- __LONG_LONG_PAIR (off_high, off_low),
+- __LONG_LONG_PAIR (len_high, len_low)));
+- if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err)))
+- return INTERNAL_SYSCALL_ERRNO (ret, err);
+- return 0;
++ return __libc_fallocate64(fd, 0, offset, len);
+ }
+ # else
+-# error your machine is neither 32 bit or 64 bit ... it must be magical
++# error your machine is neither 32 bit or 64 bit ... it must be magical
+ # endif
+ #endif
+--- a/test/.gitignore
++++ b/test/.gitignore
+@@ -302,6 +302,8 @@ unistd/getcwd
+ unistd/getopt
+ unistd/getopt_long
+ unistd/tstgetopt
++unistd/tst-fallocate
++unistd/tst-fallocate64
+ unistd/tst-posix_fallocate
+ unistd/tst-posix_fallocate64
+ unistd/tst-preadwrite
+--- /dev/null
++++ b/test/unistd/tst-fallocate.c
+@@ -0,0 +1,166 @@
++#include <fcntl.h>
++#include <sys/stat.h>
++
++#ifndef TST_FALLOCATE64
++# define stat64 stat
++# define fstat64 fstat
++# else
++# ifndef O_LARGEFILE
++# error no O_LARGEFILE but you want to test with LFS enabled
++# endif
++#endif
++
++static void do_prepare(void);
++static int do_test(void);
++#define PREPARE(argc, argv) do_prepare ()
++#define TEST_FUNCTION do_test ()
++#include <test-skeleton.c>
++
++static int fd;
++static void
++do_prepare (void)
++{
++ fd = create_temp_file ("tst-fallocate.", NULL);
++ if (fd == -1)
++ {
++ printf ("cannot create temporary file: %m\n");
++ exit (1);
++ }
++}
++
++
++static int
++do_test (void)
++{
++ struct stat64 st;
++ int c;
++ char garbage[4096];
++ blkcnt_t blksb4;
++
++ if (fstat64 (fd, &st) != 0)
++ {
++ puts ("1st fstat failed");
++ return 1;
++ }
++
++ if (st.st_size != 0)
++ {
++ puts ("file not created with size 0");
++ return 1;
++ }
++
++ /* This is the default mode which is identical to posix_fallocate().
++ Note: we need a few extra blocks for FALLOC_FL_PUNCH_HOLE below.
++ While block sizes vary, we'll assume eight 4K blocks for good measure. */
++ if (fallocate (fd, 0, 8 * 4096, 128) != 0)
++ {
++ puts ("1st fallocate call failed");
++ return 1;
++ }
++
++ if (fstat64 (fd, &st) != 0)
++ {
++ puts ("2nd fstat failed");
++ return 1;
++ }
++
++ if (st.st_size != 8 * 4096 + 128)
++ {
++ printf ("file size after 1st fallocate call is %llu, expected %u\n",
++ (unsigned long long int) st.st_size, 8u * 4096u + 128u);
++ return 1;
++ }
++
++ /* Without FALLOC_FL_KEEP_SIZE, this would increaste the size of the file. */
++ if (fallocate (fd, FALLOC_FL_KEEP_SIZE, 0, 16 * 4096) != 0)
++ {
++ puts ("2nd fallocate call failed");
++ return 1;
++ }
++
++ if (fstat64 (fd, &st) != 0)
++ {
++ puts ("3rd fstat failed");
++ return 1;
++ }
++
++ if (st.st_size != 8 * 4096 + 128)
++ {
++ printf ("file size changed in 2nd fallocate call to %llu, expected %u\n",
++ (unsigned long long int) st.st_size, 8u * 4096u + 128u);
++ return 1;
++ }
++
++ /* Let's fill up the first eight 4k blocks with 'x' to force some allocations. */
++
++ memset(garbage, 'x', 4096);
++ for(c=0; c < 8; c++)
++ if(write(fd, garbage, 4096) == -1)
++ {
++ puts ("write failed");
++ return 1;
++ }
++
++ if (fstat64 (fd, &st) != 0)
++ {
++ puts ("4th fstat failed");
++ return 1;
++ }
++
++ blksb4 = st.st_blocks;
++
++ /* Let's punch a hole in the entire file, turning it effectively into a sparse file. */
++ if (fallocate (fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 8 * 4096 + 128) != 0)
++ {
++ puts ("3rd fallocate call failed");
++ return 1;
++ }
++
++ if (fstat64 (fd, &st) != 0)
++ {
++ puts ("5th fstat failed");
++ return 1;
++ }
++
++ if (st.st_size != 8 * 4096 + 128)
++ {
++ printf ("file size after 3rd fallocate call is %llu, expected %u\n",
++ (unsigned long long int) st.st_size, 8u * 4096u + 128u);
++ return 1;
++ }
++
++ /* The number of allocated blocks should decrease. I hope this works on
++ all filesystems! */
++ if (st.st_blocks >= blksb4)
++ {
++ printf ("number of blocks after 3rd fallocate call is %lu, expected less than %lu\n",
++ (unsigned long int) st.st_blocks, blksb4);
++ return 1;
++ }
++
++#ifdef TST_FALLOCATE64
++ /* We'll just do a mode = 0 test for fallocate64() */
++ if (fallocate64 (fd, 0, 4097ULL, 4294967295ULL + 2ULL) != 0)
++ {
++ puts ("1st fallocate64 call failed");
++ return 1;
++ }
++
++ if (fstat64 (fd, &st) != 0)
++ {
++ puts ("6th fstat failed");
++ return 1;
++ }
++
++ if (st.st_size != 4097ULL + 4294967295ULL + 2ULL)
++ {
++ printf ("file size after 1st fallocate64 call is %llu, expected %llu\n",
++ (unsigned long long int) st.st_size, 4097ULL + 4294967295ULL + 2ULL);
++ return 1;
++ }
++#endif
++ close (fd);
++
++ return 0;
++}
++
+--- /dev/null
++++ b/test/unistd/tst-fallocate64.c
+@@ -0,0 +1,2 @@
++#define TST_FALLOCATE64
++#include "tst-fallocate.c"
+--- a/test/unistd/Makefile.in
++++ b/test/unistd/Makefile.in
+@@ -2,10 +2,13 @@
+ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+ ifeq ($(UCLIBC_HAS_LFS),)
+-TESTS_DISABLED := tst-preadwrite64 tst-posix_fallocate64
++TESTS_DISABLED := tst-preadwrite64 tst-posix_fallocate64 tst-fallocate64
+ endif
+ ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),)
+-TESTS_DISABLED := tst-posix_fallocate
++TESTS_DISABLED := tst-posix_fallocate tst-fallocate64
++endif
++ifeq ($(UCLIBC_LINUX_SPECIFIC),)
++TESTS_DISABLED += tst-fallocate
+ endif
+ OPTS_getopt := -abcXXX -9
+ OPTS_getopt_long := --add XXX --delete YYY --verbose
diff --git a/toolchain/uClibc/patches-0.9.33.2/024-i386-bits-syscalls.h-allow-immediate-values-as-6th-s.patch b/toolchain/uClibc/patches-0.9.33.2/024-i386-bits-syscalls.h-allow-immediate-values-as-6th-s.patch
new file mode 100644
index 0000000..2f75fbe
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/024-i386-bits-syscalls.h-allow-immediate-values-as-6th-s.patch
@@ -0,0 +1,25 @@
+From: Natanael Copa <natanael.copa@gmail.com>
+Date: Thu, 5 Jul 2012 11:55:19 +0000
+Subject: [PATCH] i386/bits/syscalls.h: allow immediate values as 6th syscall
+ arg
+
+Allow use of immedate values as the 6th syscall argument. Otherwise we must
+store the arg on memory. This gives gcc more options to optimize better.
+
+This also works around an issue with posix_fallocate.
+
+Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
+Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+---
+
+--- a/libc/sysdeps/linux/i386/bits/syscalls.h
++++ b/libc/sysdeps/linux/i386/bits/syscalls.h
+@@ -136,7 +136,7 @@ __asm__ (
+ #define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
+ , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)
+ #define ASMFMT_6(arg1, arg2, arg3, arg4, arg5, arg6) \
+- , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5), "m" (arg6)
++ , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5), "g" (arg6)
+
+ #else /* !PIC */
+
diff --git a/toolchain/uClibc/patches-0.9.33.2/025-libc-sync_file_range.patch b/toolchain/uClibc/patches-0.9.33.2/025-libc-sync_file_range.patch
new file mode 100644
index 0000000..e7efb93
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/025-libc-sync_file_range.patch
@@ -0,0 +1,57 @@
+Index: uClibc-0.9.33.2/libc/sysdeps/linux/common/sync_file_range.c
+===================================================================
+--- uClibc-0.9.33.2.orig/libc/sysdeps/linux/common/sync_file_range.c 2012-05-15 09:20:09.000000000 +0200
++++ uClibc-0.9.33.2/libc/sysdeps/linux/common/sync_file_range.c 2015-04-03 00:27:47.701221722 +0200
+@@ -4,24 +4,39 @@
+ *
+ * Copyright (C) 2008 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
++ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+ #include <sys/syscall.h>
+-#if defined __USE_GNU
+-#include <fcntl.h>
++#if defined __UCLIBC_HAS_LFS__ && defined __USE_GNU
++# include <bits/wordsize.h>
++# include <endian.h>
++# include <fcntl.h>
+
+-#if defined __NR_sync_file_range && defined __UCLIBC_HAS_LFS__
+-#define __NR___syscall_sync_file_range __NR_sync_file_range
+-static __inline__ _syscall6(int, __syscall_sync_file_range, int, fd,
+- off_t, offset_hi, off_t, offset_lo,
+- off_t, nbytes_hi, off_t, nbytes_lo, unsigned int, flags)
++# ifdef __NR_sync_file_range2
++# undef __NR_sync_file_range
++# define __NR_sync_file_range __NR_sync_file_range2
++# endif
++
++# ifdef __NR_sync_file_range
+ int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
+ {
+- return __syscall_sync_file_range(fd,
+- __LONG_LONG_PAIR((long)(offset >> 32), (long)(offset & 0xffffffff)),
+- __LONG_LONG_PAIR((long)(nbytes >> 32), (long)(nbytes & 0xffffffff)),
+- flags);
++# if defined __powerpc__ && __WORDSIZE == 64
++ return INLINE_SYSCALL(sync_file_range, 4, fd, flags, offset, nbytes);
++# elif (defined __mips__ && _MIPS_SIM == _ABIO32) || \
++ (defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) && !(defined(__powerpc__) || defined(__xtensa__)))
++ /* arch with 64-bit data in even reg alignment #2: [arcv2/others-in-future]
++ * stock syscall handler in kernel (reg hole punched)
++ * see libc/sysdeps/linux/common/posix_fadvise.c for more details */
++ return INLINE_SYSCALL(sync_file_range, 7, fd, 0,
++ OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
++# elif defined __NR_sync_file_range2
++ return INLINE_SYSCALL(sync_file_range, 6, fd, flags,
++ OFF64_HI_LO(offset), OFF64_HI_LO(nbytes));
++# else
++ return INLINE_SYSCALL(sync_file_range, 6, fd,
++ OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
++# endif
+ }
+-#endif
++# endif
+ #endif
diff --git a/toolchain/uClibc/patches-0.9.33.2/100-fix_unifdef.patch b/toolchain/uClibc/patches-0.9.33.2/100-fix_unifdef.patch
new file mode 100644
index 0000000..3d75b6e
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/100-fix_unifdef.patch
@@ -0,0 +1,11 @@
+--- a/extra/scripts/unifdef.c
++++ b/extra/scripts/unifdef.c
+@@ -78,8 +78,6 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/
+ #define errx(exit_code, fmt, args...) ({ warnx(fmt, ## args); exit(exit_code); })
+ #define err(exit_code, fmt, args...) errx(exit_code, fmt ": %s", ## args, strerror(errno))
+
+-size_t strlcpy(char *dst, const char *src, size_t siz);
+-
+ /* types of input lines: */
+ typedef enum {
+ LT_TRUEI, /* a true #if with ignore flag */
diff --git a/toolchain/uClibc/patches-0.9.33.2/110-compat_macros.patch b/toolchain/uClibc/patches-0.9.33.2/110-compat_macros.patch
new file mode 100644
index 0000000..a7538b1
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/110-compat_macros.patch
@@ -0,0 +1,51 @@
+--- a/include/string.h
++++ b/include/string.h
+@@ -355,18 +355,40 @@ extern char *index (__const char *__s, i
+ /* Find the last occurrence of C in S (same as strrchr). */
+ extern char *rindex (__const char *__s, int __c)
+ __THROW __attribute_pure__ __nonnull ((1));
+-# else
+-# ifdef __UCLIBC_SUSV3_LEGACY_MACROS__
++# elif defined(__UCLIBC_SUSV3_LEGACY_MACROS__) && !defined(_STRINGS_H)
+ /* bcopy/bzero/bcmp/index/rindex are marked LEGACY in SuSv3.
+ * They are replaced as proposed by SuSv3. Don't sync this part
+ * with glibc and keep it in sync with strings.h. */
+
+-# define bcopy(src,dest,n) (memmove((dest), (src), (n)), (void) 0)
+-# define bzero(s,n) (memset((s), '\0', (n)), (void) 0)
+-# define bcmp(s1,s2,n) memcmp((s1), (s2), (size_t)(n))
+-# define index(s,c) strchr((s), (c))
+-# define rindex(s,c) strrchr((s), (c))
+-# endif
++/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
++static __inline__ void bcopy (__const void *__src, void *__dest, size_t __n)
++{
++ memmove(__dest, __src, __n);
++}
++
++/* Set N bytes of S to 0. */
++static __inline__ void bzero (void *__s, size_t __n)
++{
++ memset(__s, 0, __n);
++}
++
++/* Compare N bytes of S1 and S2 (same as memcmp). */
++static __inline__ int bcmp (__const void *__s1, __const void *__s2, size_t __n)
++{
++ return memcmp(__s1, __s2, __n);
++}
++
++/* Find the first occurrence of C in S (same as strchr). */
++static __inline__ char *index (__const char *__s, int __c)
++{
++ return strchr(__s, __c);
++}
++
++/* Find the last occurrence of C in S (same as strrchr). */
++static __inline__ char *rindex (__const char *__s, int __c)
++{
++ return strrchr(__s, __c);
++}
+ # endif
+
+ /* Return the position of the first bit set in I, or 0 if none are set.
diff --git a/toolchain/uClibc/patches-0.9.33.2/120-adjtimex.patch b/toolchain/uClibc/patches-0.9.33.2/120-adjtimex.patch
new file mode 100644
index 0000000..dcf9c9b
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/120-adjtimex.patch
@@ -0,0 +1,14 @@
+--- a/include/sys/timex.h
++++ b/include/sys/timex.h
+@@ -116,9 +116,8 @@ struct timex
+
+ __BEGIN_DECLS
+
+-#if 0
+-extern int __adjtimex (struct timex *__ntx) __THROW;
+-#endif
++#undef __adjtimex
++#define __adjtimex adjtimex
+ extern int adjtimex (struct timex *__ntx) __THROW;
+ libc_hidden_proto(adjtimex)
+
diff --git a/toolchain/uClibc/patches-0.9.33.2/131-inet-fix-__read_etc_hosts_r-segfault.patch b/toolchain/uClibc/patches-0.9.33.2/131-inet-fix-__read_etc_hosts_r-segfault.patch
new file mode 100644
index 0000000..bd9ed38
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/131-inet-fix-__read_etc_hosts_r-segfault.patch
@@ -0,0 +1,10 @@
+--- a/libc/inet/resolv.c
++++ b/libc/inet/resolv.c
+@@ -1631,6 +1631,7 @@ int attribute_hidden __read_etc_hosts_r(
+ * struct in[6]_addr
+ * char line_buffer[BUFSZ+];
+ */
++ memset(buf, 0, buflen);
+ parser->data = buf;
+ parser->data_len = aliaslen;
+ parser->line_len = buflen - aliaslen;
diff --git a/toolchain/uClibc/patches-0.9.33.2/132-inet_fix_res_init.patch b/toolchain/uClibc/patches-0.9.33.2/132-inet_fix_res_init.patch
new file mode 100644
index 0000000..c935821
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/132-inet_fix_res_init.patch
@@ -0,0 +1,15 @@
+--- a/libc/inet/resolv.c
++++ b/libc/inet/resolv.c
+@@ -3654,11 +3654,11 @@ res_init(void)
+ */
+ if (!_res.id)
+ _res.id = res_randomid();
+- __res_sync = res_sync_func;
+
+ __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+
+ __res_vinit(&_res, 1);
++ __res_sync = res_sync_func;
+
+ return 0;
+ }
diff --git a/toolchain/uClibc/patches-0.9.33.2/133-inet6-scoped-getnameinfo.patch b/toolchain/uClibc/patches-0.9.33.2/133-inet6-scoped-getnameinfo.patch
new file mode 100644
index 0000000..390e06d
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/133-inet6-scoped-getnameinfo.patch
@@ -0,0 +1,26 @@
+--- a/libc/inet/resolv.c
++++ b/libc/inet/resolv.c
+@@ -317,6 +317,7 @@ Domain name in a message can be represen
+ #include <sys/utsname.h>
+ #include <sys/un.h>
+ #include <sys/stat.h>
++#include <net/if.h>
+ #include <bits/uClibc_mutex.h>
+ #include "internal/parse_config.h"
+
+@@ -1861,7 +1862,6 @@ int getnameinfo(const struct sockaddr *s
+ c = inet_ntop(AF_INET6,
+ (const void *) &sin6p->sin6_addr,
+ host, hostlen);
+-#if 0
+ /* Does scope id need to be supported? */
+ uint32_t scopeid;
+ scopeid = sin6p->sin6_scope_id;
+@@ -1898,7 +1898,6 @@ int getnameinfo(const struct sockaddr *s
+ return EAI_SYSTEM;
+ memcpy(host + real_hostlen, scopebuf, scopelen + 1);
+ }
+-#endif
+ }
+ #endif /* __UCLIBC_HAS_IPV6__ */
+ #if defined __UCLIBC_HAS_IPV4__
diff --git a/toolchain/uClibc/patches-0.9.33.2/135-inet_fix_threaded_use_of_res_functions.patch b/toolchain/uClibc/patches-0.9.33.2/135-inet_fix_threaded_use_of_res_functions.patch
new file mode 100644
index 0000000..6732d54
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/135-inet_fix_threaded_use_of_res_functions.patch
@@ -0,0 +1,126 @@
+--- a/libc/inet/resolv.c
++++ b/libc/inet/resolv.c
+@@ -3536,6 +3536,61 @@ __res_vinit(res_state rp, int preinit)
+ return 0;
+ }
+
++static unsigned int
++res_randomid(void)
++{
++ return 0xffff & getpid();
++}
++
++/* Our res_init never fails (always returns 0) */
++int
++res_init(void)
++{
++ /*
++ * These three fields used to be statically initialized. This made
++ * it hard to use this code in a shared library. It is necessary,
++ * now that we're doing dynamic initialization here, that we preserve
++ * the old semantics: if an application modifies one of these three
++ * fields of _res before res_init() is called, res_init() will not
++ * alter them. Of course, if an application is setting them to
++ * _zero_ before calling res_init(), hoping to override what used
++ * to be the static default, we can't detect it and unexpected results
++ * will follow. Zero for any of these fields would make no sense,
++ * so one can safely assume that the applications were already getting
++ * unexpected results.
++ *
++ * _res.options is tricky since some apps were known to diddle the bits
++ * before res_init() was first called. We can't replicate that semantic
++ * with dynamic initialization (they may have turned bits off that are
++ * set in RES_DEFAULT). Our solution is to declare such applications
++ * "broken". They could fool us by setting RES_INIT but none do (yet).
++ */
++
++ __UCLIBC_MUTEX_LOCK(__resolv_lock);
++
++ if (!_res.retrans)
++ _res.retrans = RES_TIMEOUT;
++ if (!_res.retry)
++ _res.retry = 4;
++ if (!(_res.options & RES_INIT))
++ _res.options = RES_DEFAULT;
++
++ /*
++ * This one used to initialize implicitly to zero, so unless the app
++ * has set it to something in particular, we can randomize it now.
++ */
++ if (!_res.id)
++ _res.id = res_randomid();
++
++ __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
++
++ __res_vinit(&_res, 1);
++ __res_sync = res_sync_func;
++
++ return 0;
++}
++libc_hidden_def(res_init)
++
+ static void
+ __res_iclose(void)
+ {
+@@ -3608,61 +3663,6 @@ struct __res_state *__resp = &_res;
+ # endif
+ #endif /* !__UCLIBC_HAS_THREADS__ */
+
+-static unsigned int
+-res_randomid(void)
+-{
+- return 0xffff & getpid();
+-}
+-
+-/* Our res_init never fails (always returns 0) */
+-int
+-res_init(void)
+-{
+- /*
+- * These three fields used to be statically initialized. This made
+- * it hard to use this code in a shared library. It is necessary,
+- * now that we're doing dynamic initialization here, that we preserve
+- * the old semantics: if an application modifies one of these three
+- * fields of _res before res_init() is called, res_init() will not
+- * alter them. Of course, if an application is setting them to
+- * _zero_ before calling res_init(), hoping to override what used
+- * to be the static default, we can't detect it and unexpected results
+- * will follow. Zero for any of these fields would make no sense,
+- * so one can safely assume that the applications were already getting
+- * unexpected results.
+- *
+- * _res.options is tricky since some apps were known to diddle the bits
+- * before res_init() was first called. We can't replicate that semantic
+- * with dynamic initialization (they may have turned bits off that are
+- * set in RES_DEFAULT). Our solution is to declare such applications
+- * "broken". They could fool us by setting RES_INIT but none do (yet).
+- */
+-
+- __UCLIBC_MUTEX_LOCK(__resolv_lock);
+-
+- if (!_res.retrans)
+- _res.retrans = RES_TIMEOUT;
+- if (!_res.retry)
+- _res.retry = 4;
+- if (!(_res.options & RES_INIT))
+- _res.options = RES_DEFAULT;
+-
+- /*
+- * This one used to initialize implicitly to zero, so unless the app
+- * has set it to something in particular, we can randomize it now.
+- */
+- if (!_res.id)
+- _res.id = res_randomid();
+-
+- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+-
+- __res_vinit(&_res, 1);
+- __res_sync = res_sync_func;
+-
+- return 0;
+-}
+-libc_hidden_def(res_init)
+-
+ /*
+ * Set up default settings. If the configuration file exist, the values
+ * there will have precedence. Otherwise, the server address is set to
diff --git a/toolchain/uClibc/patches-0.9.33.2/136-inet_make_res_init_thread_safe.patch b/toolchain/uClibc/patches-0.9.33.2/136-inet_make_res_init_thread_safe.patch
new file mode 100644
index 0000000..0627889
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/136-inet_make_res_init_thread_safe.patch
@@ -0,0 +1,53 @@
+--- a/libc/inet/resolv.c
++++ b/libc/inet/resolv.c
+@@ -3432,6 +3432,7 @@ static void res_sync_func(void)
+ */
+ }
+
++/* has to be called under __resolv_lock */
+ static int
+ __res_vinit(res_state rp, int preinit)
+ {
+@@ -3440,7 +3441,6 @@ __res_vinit(res_state rp, int preinit)
+ int m = 0;
+ #endif
+
+- __UCLIBC_MUTEX_LOCK(__resolv_lock);
+ __close_nameservers();
+ __open_nameservers();
+
+@@ -3532,7 +3532,6 @@ __res_vinit(res_state rp, int preinit)
+
+ rp->options |= RES_INIT;
+
+- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+ return 0;
+ }
+
+@@ -3582,11 +3581,11 @@ res_init(void)
+ if (!_res.id)
+ _res.id = res_randomid();
+
+- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+-
+ __res_vinit(&_res, 1);
+ __res_sync = res_sync_func;
+
++ __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
++
+ return 0;
+ }
+ libc_hidden_def(res_init)
+@@ -3687,7 +3686,11 @@ struct __res_state *__resp = &_res;
+ int
+ res_ninit(res_state statp)
+ {
+- return __res_vinit(statp, 0);
++ int ret;
++ __UCLIBC_MUTEX_LOCK(__resolv_lock);
++ ret = __res_vinit(statp, 0);
++ __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
++ return ret;
+ }
+
+ #endif /* L_res_init */
diff --git a/toolchain/uClibc/patches-0.9.33.2/137-inet_fix_threaded_res_init.patch b/toolchain/uClibc/patches-0.9.33.2/137-inet_fix_threaded_res_init.patch
new file mode 100644
index 0000000..ce8448a
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/137-inet_fix_threaded_res_init.patch
@@ -0,0 +1,10 @@
+--- a/libc/inet/resolv.c
++++ b/libc/inet/resolv.c
+@@ -3581,6 +3581,7 @@ res_init(void)
+ if (!_res.id)
+ _res.id = res_randomid();
+
++ __res_sync = NULL;
+ __res_vinit(&_res, 1);
+ __res_sync = res_sync_func;
+
diff --git a/toolchain/uClibc/patches-0.9.33.2/150-vasprintf_size_reduce.patch b/toolchain/uClibc/patches-0.9.33.2/150-vasprintf_size_reduce.patch
new file mode 100644
index 0000000..7853c1a
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/150-vasprintf_size_reduce.patch
@@ -0,0 +1,37 @@
+Reduce the initial buffer size for open_memstream (used by vasprintf),
+as most strings are usually smaller than that.
+Realloc the buffer after finishing the string to further reduce size.
+
+Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+
+--- a/libc/stdio/vasprintf.c
++++ b/libc/stdio/vasprintf.c
+@@ -39,6 +39,8 @@ int vasprintf(char **__restrict buf, con
+ if (rv < 0) {
+ free(*buf);
+ *buf = NULL;
++ } else {
++ *buf = realloc(*buf, rv + 1);
+ }
+ }
+
+--- a/libc/stdio/open_memstream.c
++++ b/libc/stdio/open_memstream.c
+@@ -17,6 +17,8 @@
+
+ #define COOKIE ((__oms_cookie *) cookie)
+
++#define MEMSTREAM_BUFSIZ 256
++
+ typedef struct {
+ char *buf;
+ size_t len;
+@@ -134,7 +136,7 @@ FILE *open_memstream(char **__restrict b
+ register FILE *fp;
+
+ if ((cookie = malloc(sizeof(__oms_cookie))) != NULL) {
+- if ((cookie->buf = malloc(cookie->len = BUFSIZ)) == NULL) {
++ if ((cookie->buf = malloc(cookie->len = MEMSTREAM_BUFSIZ)) == NULL) {
+ goto EXIT_cookie;
+ }
+ *cookie->buf = 0; /* Set nul terminator for buffer. */
diff --git a/toolchain/uClibc/patches-0.9.33.2/170-math_finite.patch b/toolchain/uClibc/patches-0.9.33.2/170-math_finite.patch
new file mode 100644
index 0000000..b0ae333
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/170-math_finite.patch
@@ -0,0 +1,23 @@
+--- a/include/math.h
++++ b/include/math.h
+@@ -195,7 +195,7 @@ extern int signgam;
+
+
+ /* ISO C99 defines some generic macros which work on any data type. */
+-#ifdef __USE_ISOC99
++#if defined(__USE_ISOC99) || defined(__USE_BSD)
+
+ /* Get the architecture specific values describing the floating-point
+ evaluation. The following symbols will get defined:
+@@ -315,6 +315,11 @@ enum
+
+ #endif /* Use ISO C99. */
+
++/* BSD compat */
++#define finite(x) __finite(x)
++#define finitef(x) __finitef(x)
++#define finitel(x) __finitel(x)
++
+ #ifdef __USE_MISC
+ /* Support for various different standard error handling behaviors. */
+ typedef enum
diff --git a/toolchain/uClibc/patches-0.9.33.2/180-pthread_cleanup_fix.patch b/toolchain/uClibc/patches-0.9.33.2/180-pthread_cleanup_fix.patch
new file mode 100644
index 0000000..ae36018
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/180-pthread_cleanup_fix.patch
@@ -0,0 +1,45 @@
+--- a/libpthread/nptl/cleanup_defer_compat.c
++++ b/libpthread/nptl/cleanup_defer_compat.c
+@@ -22,7 +22,7 @@
+
+ void
+ attribute_protected
+-_pthread_cleanup_push_defer (
++__pthread_cleanup_push_defer (
+ struct _pthread_cleanup_buffer *buffer,
+ void (*routine) (void *),
+ void *arg)
+@@ -57,12 +57,12 @@ _pthread_cleanup_push_defer (
+
+ THREAD_SETMEM (self, cleanup, buffer);
+ }
+-strong_alias (_pthread_cleanup_push_defer, __pthread_cleanup_push_defer)
++strong_alias (__pthread_cleanup_push_defer, _pthread_cleanup_push_defer)
+
+
+ void
+ attribute_protected
+-_pthread_cleanup_pop_restore (
++__pthread_cleanup_pop_restore (
+ struct _pthread_cleanup_buffer *buffer,
+ int execute)
+ {
+@@ -97,4 +97,4 @@ _pthread_cleanup_pop_restore (
+ if (execute)
+ buffer->__routine (buffer->__arg);
+ }
+-strong_alias (_pthread_cleanup_pop_restore, __pthread_cleanup_pop_restore)
++strong_alias (__pthread_cleanup_pop_restore, _pthread_cleanup_pop_restore)
+--- a/libpthread/nptl/init.c
++++ b/libpthread/nptl/init.c
+@@ -112,8 +112,8 @@ static const struct pthread_functions pt
+ .ptr___pthread_key_create = __pthread_key_create_internal,
+ .ptr___pthread_getspecific = __pthread_getspecific_internal,
+ .ptr___pthread_setspecific = __pthread_setspecific_internal,
+- .ptr__pthread_cleanup_push_defer = _pthread_cleanup_push_defer,
+- .ptr__pthread_cleanup_pop_restore = _pthread_cleanup_pop_restore,
++ .ptr__pthread_cleanup_push_defer = __pthread_cleanup_push_defer,
++ .ptr__pthread_cleanup_pop_restore = __pthread_cleanup_pop_restore,
+ .ptr_nthreads = &__nptl_nthreads,
+ .ptr___pthread_unwind = &__pthread_unwind,
+ .ptr__nptl_deallocate_tsd = __nptl_deallocate_tsd,
diff --git a/toolchain/uClibc/patches-0.9.33.2/190-nptl_use_arch_default_stack_limit.patch b/toolchain/uClibc/patches-0.9.33.2/190-nptl_use_arch_default_stack_limit.patch
new file mode 100644
index 0000000..b7f5c82
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/190-nptl_use_arch_default_stack_limit.patch
@@ -0,0 +1,13 @@
+--- a/libpthread/nptl/init.c
++++ b/libpthread/nptl/init.c
+@@ -402,6 +402,10 @@ __pthread_initialize_minimal_internal (v
+ Use the minimal size acceptable. */
+ limit.rlim_cur = PTHREAD_STACK_MIN;
+
++ /* Do not exceed architecture specific default */
++ if (limit.rlim_cur > ARCH_STACK_DEFAULT_SIZE)
++ limit.rlim_cur = ARCH_STACK_DEFAULT_SIZE;
++
+ /* Make sure it meets the minimum size that allocate_stack
+ (allocatestack.c) will demand, which depends on the page size. */
+ const uintptr_t pagesz = sysconf (_SC_PAGESIZE);
diff --git a/toolchain/uClibc/patches-0.9.33.2/200-no_forced_unwind.patch b/toolchain/uClibc/patches-0.9.33.2/200-no_forced_unwind.patch
new file mode 100644
index 0000000..d6869e2
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/200-no_forced_unwind.patch
@@ -0,0 +1,10 @@
+--- a/Rules.mak
++++ b/Rules.mak
+@@ -707,7 +707,6 @@ endif
+ ifeq ($(UCLIBC_HAS_THREADS),y)
+ ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+ PTNAME := nptl
+- CFLAGS += -DHAVE_FORCED_UNWIND
+ else
+ ifeq ($(LINUXTHREADS_OLD),y)
+ PTNAME := linuxthreads.old
diff --git a/toolchain/uClibc/patches-0.9.33.2/210-mips_use_pic_crt1.patch b/toolchain/uClibc/patches-0.9.33.2/210-mips_use_pic_crt1.patch
new file mode 100644
index 0000000..2ca10d4
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/210-mips_use_pic_crt1.patch
@@ -0,0 +1,11 @@
+--- a/libc/sysdeps/linux/mips/Makefile.arch
++++ b/libc/sysdeps/linux/mips/Makefile.arch
+@@ -20,6 +20,8 @@ ifneq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+ SSRC += vfork.S clone.S
+ endif
+
++CFLAGS-crt1.S += $(PICFLAG)
++
+ ASFLAGS-syscall_error.S += -D_LIBC_REENTRANT
+
+ ARCH_HEADERS := sgidefs.h
diff --git a/toolchain/uClibc/patches-0.9.33.2/350-use-fputs_unlocked.patch b/toolchain/uClibc/patches-0.9.33.2/350-use-fputs_unlocked.patch
new file mode 100644
index 0000000..58b03ec
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/350-use-fputs_unlocked.patch
@@ -0,0 +1,19 @@
+commit 3e3ae40f053b22fbb9bef50067d6edad4c358c4c
+Author: Mirko Vogt <dev@nanl.de>
+Date: Tue May 24 14:36:42 2011 +0200
+
+ use 'fputws_unlocked(S,F)' instead of 'fputws(S,F)'
+
+ this eliminates a source of reproduceable freezes
+
+--- a/libc/stdio/_vfprintf.c
++++ b/libc/stdio/_vfprintf.c
+@@ -1229,7 +1229,7 @@ static size_t _fp_out_narrow(FILE *fp, i
+ #define STRLEN wcslen
+ #define _PPFS_init _ppwfs_init
+ /* Pulls in fseek: */
+-#define OUTPUT(F,S) fputws(S,F)
++#define OUTPUT(F,S) fputws_unlocked(S,F)
+ /* TODO: #define OUTPUT(F,S) _wstdio_fwrite((S),wcslen(S),(F)) */
+ #define _outnwcs(stream, wstring, len) _wstdio_fwrite((const wchar_t *)(wstring), len, stream)
+ #define FP_OUT _fp_out_wide
diff --git a/toolchain/uClibc/patches-0.9.33.2/410-llvm_workaround.patch b/toolchain/uClibc/patches-0.9.33.2/410-llvm_workaround.patch
new file mode 100644
index 0000000..7ae3943
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/410-llvm_workaround.patch
@@ -0,0 +1,11 @@
+--- a/libc/stdio/_stdio.c
++++ b/libc/stdio/_stdio.c
+@@ -124,7 +124,7 @@ static FILE _stdio_streams[] = {
+ __FLAG_NBF|__FLAG_WRITEONLY, \
+ 2, \
+ NULL, \
+- NULL, \
++ 0, \
+ 0 )
+ };
+
diff --git a/toolchain/uClibc/patches-0.9.33.2/450-powerpc_copysignl.patch b/toolchain/uClibc/patches-0.9.33.2/450-powerpc_copysignl.patch
new file mode 100644
index 0000000..ad8d682
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/450-powerpc_copysignl.patch
@@ -0,0 +1,103 @@
+--- a/libc/sysdeps/linux/powerpc/Makefile.arch
++++ b/libc/sysdeps/linux/powerpc/Makefile.arch
+@@ -5,7 +5,7 @@
+ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ #
+
+-CSRC := __syscall_error.c pread_write.c ioctl.c
++CSRC := __syscall_error.c pread_write.c ioctl.c copysignl.c
+
+ ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),y)
+ CSRC += posix_fadvise.c posix_fadvise64.c
+--- /dev/null
++++ b/libc/sysdeps/linux/powerpc/copysignl.c
+@@ -0,0 +1,89 @@
++/* s_copysignl.c -- long double version of s_copysign.c.
++ * Conversion to long double by Ulrich Drepper,
++ * Cygnus Support, drepper@cygnus.com.
++ */
++
++/*
++ * ====================================================
++ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
++ *
++ * Developed at SunPro, a Sun Microsystems, Inc. business.
++ * Permission to use, copy, modify, and distribute this
++ * software is freely granted, provided that this notice
++ * is preserved.
++ * ====================================================
++ */
++
++/*
++ * copysignl(long double x, long double y)
++ * copysignl(x,y) returns a value with the magnitude of x and
++ * with the sign bit of y.
++ */
++
++#include <endian.h>
++#include <stdint.h>
++
++#if __FLOAT_WORD_ORDER == BIG_ENDIAN
++
++typedef union
++{
++ long double value;
++ struct
++ {
++ int sign_exponent:16;
++ unsigned int empty:16;
++ uint32_t msw;
++ uint32_t lsw;
++ } parts;
++} ieee_long_double_shape_type;
++
++#endif
++
++#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
++
++typedef union
++{
++ long double value;
++ struct
++ {
++ uint32_t lsw;
++ uint32_t msw;
++ int sign_exponent:16;
++ unsigned int empty:16;
++ } parts;
++} ieee_long_double_shape_type;
++
++#endif
++
++/* Get int from the exponent of a long double. */
++
++#define GET_LDOUBLE_EXP(exp,d) \
++do { \
++ ieee_long_double_shape_type ge_u; \
++ ge_u.value = (d); \
++ (exp) = ge_u.parts.sign_exponent; \
++} while (0)
++
++/* Set exponent of a long double from an int. */
++
++#define SET_LDOUBLE_EXP(d,exp) \
++do { \
++ ieee_long_double_shape_type se_u; \
++ se_u.value = (d); \
++ se_u.parts.sign_exponent = (exp); \
++ (d) = se_u.value; \
++} while (0)
++
++long double copysignl(long double x, long double y);
++libc_hidden_proto(copysignl);
++
++long double copysignl(long double x, long double y)
++{
++ uint32_t es1,es2;
++ GET_LDOUBLE_EXP(es1,x);
++ GET_LDOUBLE_EXP(es2,y);
++ SET_LDOUBLE_EXP(x,(es1&0x7fff)|(es2&0x8000));
++ return x;
++}
++
++libc_hidden_def(copysignl);
diff --git a/toolchain/uClibc/patches-0.9.33.2/460-powerpc_ptrace_h.patch b/toolchain/uClibc/patches-0.9.33.2/460-powerpc_ptrace_h.patch
new file mode 100644
index 0000000..c48b682
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/460-powerpc_ptrace_h.patch
@@ -0,0 +1,96 @@
+--- a/libc/sysdeps/linux/powerpc/sys/ptrace.h
++++ b/libc/sysdeps/linux/powerpc/sys/ptrace.h
+@@ -1,5 +1,5 @@
+ /* `ptrace' debugger support interface. Linux version.
+- Copyright (C) 2001 Free Software Foundation, Inc.
++ Copyright (C) 2001, 2006, 2007, 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+@@ -13,9 +13,8 @@
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+- License along with the GNU C Library; if not, write to the Free
+- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+- 02111-1307 USA. */
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
+
+ #ifndef _SYS_PTRACE_H
+ #define _SYS_PTRACE_H 1
+@@ -79,8 +78,73 @@ enum __ptrace_request
+ #define PT_DETACH PTRACE_DETACH
+
+ /* Continue and stop at the next (return from) syscall. */
+- PTRACE_SYSCALL = 24
++ PTRACE_SYSCALL = 24,
+ #define PT_SYSCALL PTRACE_SYSCALL
++
++ /* Set ptrace filter options. */
++ PTRACE_SETOPTIONS = 0x4200,
++#define PT_SETOPTIONS PTRACE_SETOPTIONS
++
++ /* Get last ptrace message. */
++ PTRACE_GETEVENTMSG = 0x4201,
++#define PT_GETEVENTMSG PTRACE_GETEVENTMSG
++
++ /* Get siginfo for process. */
++ PTRACE_GETSIGINFO = 0x4202,
++#define PT_GETSIGINFO PTRACE_GETSIGINFO
++
++ /* Set new siginfo for process. */
++ PTRACE_SETSIGINFO = 0x4203,
++#define PT_SETSIGINFO PTRACE_SETSIGINFO
++
++ /* Get register content. */
++ PTRACE_GETREGSET = 0x4204,
++#define PTRACE_GETREGSET PTRACE_GETREGSET
++
++ /* Set register content. */
++ PTRACE_SETREGSET = 0x4205,
++#define PTRACE_SETREGSET PTRACE_SETREGSET
++
++ /* Like PTRACE_ATTACH, but do not force tracee to trap and do not affect
++ signal or group stop state. */
++ PTRACE_SEIZE = 0x4206,
++#define PTRACE_SEIZE PTRACE_SEIZE
++
++ /* Trap seized tracee. */
++ PTRACE_INTERRUPT = 0x4207,
++#define PTRACE_INTERRUPT PTRACE_INTERRUPT
++
++ /* Wait for next group event. */
++ PTRACE_LISTEN = 0x4208
++};
++
++
++/* Flag for PTRACE_LISTEN. */
++enum __ptrace_flags
++{
++ PTRACE_SEIZE_DEVEL = 0x80000000
++};
++
++/* Options set using PTRACE_SETOPTIONS. */
++enum __ptrace_setoptions {
++ PTRACE_O_TRACESYSGOOD = 0x00000001,
++ PTRACE_O_TRACEFORK = 0x00000002,
++ PTRACE_O_TRACEVFORK = 0x00000004,
++ PTRACE_O_TRACECLONE = 0x00000008,
++ PTRACE_O_TRACEEXEC = 0x00000010,
++ PTRACE_O_TRACEVFORKDONE = 0x00000020,
++ PTRACE_O_TRACEEXIT = 0x00000040,
++ PTRACE_O_MASK = 0x0000007f
++};
++
++/* Wait extended result codes for the above trace options. */
++enum __ptrace_eventcodes {
++ PTRACE_EVENT_FORK = 1,
++ PTRACE_EVENT_VFORK = 2,
++ PTRACE_EVENT_CLONE = 3,
++ PTRACE_EVENT_EXEC = 4,
++ PTRACE_EVENT_VFORK_DONE = 5,
++ PTRACE_EVENT_EXIT = 6
+ };
+
+ /* Perform process tracing functions. REQUEST is one of the values
diff --git a/toolchain/uClibc/patches-0.9.33.2/470-powerpc_syscall6.patch b/toolchain/uClibc/patches-0.9.33.2/470-powerpc_syscall6.patch
new file mode 100644
index 0000000..9511dcc
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/470-powerpc_syscall6.patch
@@ -0,0 +1,10 @@
+--- a/libc/sysdeps/linux/powerpc/syscall.S
++++ b/libc/sysdeps/linux/powerpc/syscall.S
+@@ -30,6 +30,7 @@ syscall:
+ mr 5,6
+ mr 6,7
+ mr 7,8
++ mr 8,9
+ sc
+ bnslr;
+
diff --git a/toolchain/uClibc/patches-0.9.33.2/480-powerpc_rel24_support.patch b/toolchain/uClibc/patches-0.9.33.2/480-powerpc_rel24_support.patch
new file mode 100644
index 0000000..19c2b2c
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/480-powerpc_rel24_support.patch
@@ -0,0 +1,26 @@
+--- a/ldso/ldso/powerpc/elfinterp.c
++++ b/ldso/ldso/powerpc/elfinterp.c
+@@ -297,22 +297,17 @@ _dl_do_reloc (struct elf_resolve *tpnt,s
+ break;
+ #endif
+ case R_PPC_REL24:
+-#if 0
+ {
+ Elf32_Sword delta = finaladdr - (Elf32_Word)reloc_addr;
+ if (unlikely(delta<<6>>6 != delta)) {
+ _dl_dprintf(2, "%s: symbol '%s' R_PPC_REL24 is out of range.\n\t"
+ "Compile shared libraries with -fPIC!\n",
+ _dl_progname, symname);
+- _dl_exit(1);
++ return -1;
+ }
+ *reloc_addr = (*reloc_addr & 0xfc000003) | (delta & 0x3fffffc);
+ break;
+ }
+-#else
+- _dl_dprintf(2,"R_PPC_REL24: Compile shared libraries with -fPIC!\n");
+- return -1;
+-#endif
+ case R_PPC_NONE:
+ goto out_nocode; /* No code code modified */
+ default:
diff --git a/toolchain/uClibc/patches-0.9.33.2/500-eventfd.patch b/toolchain/uClibc/patches-0.9.33.2/500-eventfd.patch
new file mode 100644
index 0000000..374052c
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/500-eventfd.patch
@@ -0,0 +1,53 @@
+From 7810e4f8027b5c4c8ceec6fefec4eb779362ebb5 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 10 Jun 2012 16:36:23 +0000
+Subject: eventfd: Implement eventfd2 and fix eventfd
+
+eventfd: evntfd assumes to take two arguments instead it
+should be one evntfd expects two therefore implement both syscalls with
+correct parameters
+
+Thanks Eugene Rudoy for reporting it and also providing the patch
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+--- a/libc/sysdeps/linux/common/eventfd.c
++++ b/libc/sysdeps/linux/common/eventfd.c
+@@ -7,12 +7,24 @@
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
++#include <errno.h>
+ #include <sys/syscall.h>
+ #include <sys/eventfd.h>
+
+ /*
+ * eventfd()
+ */
+-#ifdef __NR_eventfd
+-_syscall2(int, eventfd, int, count, int, flags)
++#if defined __NR_eventfd || defined __NR_eventfd2
++int eventfd (int count, int flags)
++{
++#if defined __NR_eventfd2
++ return INLINE_SYSCALL (eventfd2, 2, count, flags);
++#elif defined __NR_eventfd
++ if (flags != 0) {
++ __set_errno (EINVAL);
++ return -1;
++ }
++ return INLINE_SYSCALL (eventfd, 1, count);
++#endif
++}
+ #endif
+--- a/libc/sysdeps/linux/common/stubs.c
++++ b/libc/sysdeps/linux/common/stubs.c
+@@ -93,7 +93,7 @@ make_stub(epoll_ctl)
+ make_stub(epoll_wait)
+ #endif
+
+-#if !defined __NR_eventfd && defined __UCLIBC_LINUX_SPECIFIC__
++#if !defined __NR_eventfd && !defined __NR_eventfd2 && defined __UCLIBC_LINUX_SPECIFIC__
+ make_stub(eventfd)
+ #endif
+
diff --git a/toolchain/uClibc/patches-0.9.33.2/600-mips64_abi_selection.patch b/toolchain/uClibc/patches-0.9.33.2/600-mips64_abi_selection.patch
new file mode 100644
index 0000000..beca17c
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/600-mips64_abi_selection.patch
@@ -0,0 +1,48 @@
+From 603af30d6992e94ac30a66b953264076f4f2fd71 Mon Sep 17 00:00:00 2001
+From: Markos Chandras <markos.chandras@imgtec.com>
+Date: Thu, 11 Jul 2013 16:59:16 +0000
+Subject: Rules.mak: MIPS64: Select correct interpreter
+
+gcc (eg 4.7.3) hardcodes the MIPS64 interpreters like this:
+(see gcc/config/linux.h and gcc/config/mips/linux64.h)
+
+o32: UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
+n32: UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
+n64: UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
+
+The existing check for MIPS64 in uClibc is wrong because it does
+not respect the selected ABI
+
+We fix this by explicitely checking the selected ABI instead of the
+selected MIPS variant.
+
+Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
+Cc: Anthony G. Basile <blueness@gentoo.org>
+Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+---
+
+--- a/Rules.mak
++++ b/Rules.mak
+@@ -118,13 +118,19 @@ export MAJOR_VERSION MINOR_VERSION SUBLE
+ LIBC := libc
+ SHARED_LIBNAME := $(LIBC).so.$(ABI_VERSION)
+ UBACKTRACE_DSO := libubacktrace.so.$(ABI_VERSION)
+-ifneq ($(findstring $(TARGET_ARCH) , hppa64 ia64 mips64 powerpc64 s390x sparc64 x86_64 ),)
++
++UCLIBC_LDSO_NAME := ld-uClibc
++ARCH_NATIVE_BIT := 32
++ifneq ($(findstring $(TARGET_ARCH),hppa64 ia64 powerpc64 s390x sparc64 x86_64),)
+ UCLIBC_LDSO_NAME := ld64-uClibc
+ ARCH_NATIVE_BIT := 64
+ else
+-UCLIBC_LDSO_NAME := ld-uClibc
+-ARCH_NATIVE_BIT := 32
++ifeq ($(CONFIG_MIPS_N64_ABI),y)
++UCLIBC_LDSO_NAME := ld64-uClibc
++ARCH_NATIVE_BIT := 64
+ endif
++endif
++
+ UCLIBC_LDSO := $(UCLIBC_LDSO_NAME).so.$(ABI_VERSION)
+ NONSHARED_LIBNAME := uclibc_nonshared.a
+ libc := $(top_builddir)lib/$(SHARED_LIBNAME)
diff --git a/toolchain/uClibc/patches-0.9.33.2/610-mips64_syscall_fix.patch b/toolchain/uClibc/patches-0.9.33.2/610-mips64_syscall_fix.patch
new file mode 100644
index 0000000..46d1f5c
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/610-mips64_syscall_fix.patch
@@ -0,0 +1,285 @@
+commit e5cde2eb0ed7df9416fdd6070af07c8448c72a30
+Author: Steve Ellcey <sellcey@mips.com>
+Date: Wed Feb 12 11:01:35 2014 -0800
+
+ mips: Remove duplicate macro definitions
+
+ The INLINE_SYSCALL, INTERNAL_SYSCALL*, and internal_syscall* macros
+ are defined for MIPS in both libc/sysdeps/linux/mips/sysdep.h and
+ libc/sysdeps/linux/mips/bits/syscalls.h. The macros are the same
+ in both cases except that syscalls.h defines internal_syscalls[567]
+ the same for N32 and N64 ABIs and has a different definition for O32.
+ I believe that is correct. The sysdep.h header uses the O32 versions
+ for N32 and has different definitions for N64. I think that is wrong
+ and that N32 and N64 should share the same definition (modulo the
+ type 'long' vs. 'long long' for the arguments. This setup (from
+ sysdep.h) now agrees with what glibc has.
+
+ I am not positive about which header (sysdep.h vs syscalls.h) is
+ really the right one to have these definitions in but using sysdep.h
+ seems to work for all my builds.
+
+ Signed-off-by: Steve Ellcey <sellcey@mips.com>
+ Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+
+--- a/libc/sysdeps/linux/mips/sysdep.h
++++ b/libc/sysdeps/linux/mips/sysdep.h
+@@ -133,258 +133,6 @@ L(syse1):
+
+ #else /* ! __ASSEMBLER__ */
+
+-/* Define a macro which expands into the inline wrapper code for a system
+- call. */
+-#undef INLINE_SYSCALL
+-#define INLINE_SYSCALL(name, nr, args...) \
+- ({ INTERNAL_SYSCALL_DECL(err); \
+- long result_var = INTERNAL_SYSCALL (name, err, nr, args); \
+- if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) ) \
+- { \
+- __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \
+- result_var = -1L; \
+- } \
+- result_var; })
+-
+-#undef INTERNAL_SYSCALL_DECL
+-#define INTERNAL_SYSCALL_DECL(err) long err
+-
+-#undef INTERNAL_SYSCALL_ERROR_P
+-#define INTERNAL_SYSCALL_ERROR_P(val, err) ((long) (err))
+-
+-#undef INTERNAL_SYSCALL_ERRNO
+-#define INTERNAL_SYSCALL_ERRNO(val, err) (val)
+-
+-#undef INTERNAL_SYSCALL
+-#define INTERNAL_SYSCALL(name, err, nr, args...) \
+- internal_syscall##nr (, "li\t$2, %2\t\t\t# " #name "\n\t", \
+- "i" (SYS_ify (name)), err, args)
+-
+-#undef INTERNAL_SYSCALL_NCS
+-#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
+- internal_syscall##nr (= number, , "r" (__v0), err, args)
+-#undef internal_syscall0
+-#define internal_syscall0(ncs_init, cs_init, input, err, dummy...) \
+-({ \
+- long _sys_result; \
+- \
+- { \
+- register long __v0 __asm__("$2") ncs_init; \
+- register long __a3 __asm__("$7"); \
+- __asm__ __volatile__ ( \
+- ".set\tnoreorder\n\t" \
+- cs_init \
+- "syscall\n\t" \
+- ".set reorder" \
+- : "=r" (__v0), "=r" (__a3) \
+- : input \
+- : __SYSCALL_CLOBBERS); \
+- err = __a3; \
+- _sys_result = __v0; \
+- } \
+- _sys_result; \
+-})
+-
+-#undef internal_syscall1
+-#define internal_syscall1(ncs_init, cs_init, input, err, arg1) \
+-({ \
+- long _sys_result; \
+- \
+- { \
+- register long __v0 __asm__("$2") ncs_init; \
+- register long __a0 __asm__("$4") = (long) arg1; \
+- register long __a3 __asm__("$7"); \
+- __asm__ __volatile__ ( \
+- ".set\tnoreorder\n\t" \
+- cs_init \
+- "syscall\n\t" \
+- ".set reorder" \
+- : "=r" (__v0), "=r" (__a3) \
+- : input, "r" (__a0) \
+- : __SYSCALL_CLOBBERS); \
+- err = __a3; \
+- _sys_result = __v0; \
+- } \
+- _sys_result; \
+-})
+-
+-#undef internal_syscall2
+-#define internal_syscall2(ncs_init, cs_init, input, err, arg1, arg2) \
+-({ \
+- long _sys_result; \
+- \
+- { \
+- register long __v0 __asm__("$2") ncs_init; \
+- register long __a0 __asm__("$4") = (long) arg1; \
+- register long __a1 __asm__("$5") = (long) arg2; \
+- register long __a3 __asm__("$7"); \
+- __asm__ __volatile__ ( \
+- ".set\tnoreorder\n\t" \
+- cs_init \
+- "syscall\n\t" \
+- ".set\treorder" \
+- : "=r" (__v0), "=r" (__a3) \
+- : input, "r" (__a0), "r" (__a1) \
+- : __SYSCALL_CLOBBERS); \
+- err = __a3; \
+- _sys_result = __v0; \
+- } \
+- _sys_result; \
+-})
+-
+-#undef internal_syscall3
+-#define internal_syscall3(ncs_init, cs_init, input, err, arg1, arg2, arg3)\
+-({ \
+- long _sys_result; \
+- \
+- { \
+- register long __v0 __asm__("$2") ncs_init; \
+- register long __a0 __asm__("$4") = (long) arg1; \
+- register long __a1 __asm__("$5") = (long) arg2; \
+- register long __a2 __asm__("$6") = (long) arg3; \
+- register long __a3 __asm__("$7"); \
+- __asm__ __volatile__ ( \
+- ".set\tnoreorder\n\t" \
+- cs_init \
+- "syscall\n\t" \
+- ".set\treorder" \
+- : "=r" (__v0), "=r" (__a3) \
+- : input, "r" (__a0), "r" (__a1), "r" (__a2) \
+- : __SYSCALL_CLOBBERS); \
+- err = __a3; \
+- _sys_result = __v0; \
+- } \
+- _sys_result; \
+-})
+-
+-#undef internal_syscall4
+-#define internal_syscall4(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4)\
+-({ \
+- long _sys_result; \
+- \
+- { \
+- register long __v0 __asm__("$2") ncs_init; \
+- register long __a0 __asm__("$4") = (long) arg1; \
+- register long __a1 __asm__("$5") = (long) arg2; \
+- register long __a2 __asm__("$6") = (long) arg3; \
+- register long __a3 __asm__("$7") = (long) arg4; \
+- __asm__ __volatile__ ( \
+- ".set\tnoreorder\n\t" \
+- cs_init \
+- "syscall\n\t" \
+- ".set\treorder" \
+- : "=r" (__v0), "+r" (__a3) \
+- : input, "r" (__a0), "r" (__a1), "r" (__a2) \
+- : __SYSCALL_CLOBBERS); \
+- err = __a3; \
+- _sys_result = __v0; \
+- } \
+- _sys_result; \
+-})
+-
+-/* We need to use a frame pointer for the functions in which we
+- adjust $sp around the syscall, or debug information and unwind
+- information will be $sp relative and thus wrong during the syscall. As
+- of GCC 3.4.3, this is sufficient. */
+-#define FORCE_FRAME_POINTER alloca (4)
+-
+-#undef internal_syscall5
+-#define internal_syscall5(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5)\
+-({ \
+- long _sys_result; \
+- \
+- FORCE_FRAME_POINTER; \
+- { \
+- register long __v0 __asm__("$2") ncs_init; \
+- register long __a0 __asm__("$4") = (long) arg1; \
+- register long __a1 __asm__("$5") = (long) arg2; \
+- register long __a2 __asm__("$6") = (long) arg3; \
+- register long __a3 __asm__("$7") = (long) arg4; \
+- __asm__ __volatile__ ( \
+- ".set\tnoreorder\n\t" \
+- "subu\t$29, 32\n\t" \
+- "sw\t%6, 16($29)\n\t" \
+- cs_init \
+- "syscall\n\t" \
+- "addiu\t$29, 32\n\t" \
+- ".set\treorder" \
+- : "=r" (__v0), "+r" (__a3) \
+- : input, "r" (__a0), "r" (__a1), "r" (__a2), \
+- "r" ((long)arg5) \
+- : __SYSCALL_CLOBBERS); \
+- err = __a3; \
+- _sys_result = __v0; \
+- } \
+- _sys_result; \
+-})
+-
+-#undef internal_syscall6
+-#define internal_syscall6(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5, arg6)\
+-({ \
+- long _sys_result; \
+- \
+- FORCE_FRAME_POINTER; \
+- { \
+- register long __v0 __asm__("$2") ncs_init; \
+- register long __a0 __asm__("$4") = (long) arg1; \
+- register long __a1 __asm__("$5") = (long) arg2; \
+- register long __a2 __asm__("$6") = (long) arg3; \
+- register long __a3 __asm__("$7") = (long) arg4; \
+- __asm__ __volatile__ ( \
+- ".set\tnoreorder\n\t" \
+- "subu\t$29, 32\n\t" \
+- "sw\t%6, 16($29)\n\t" \
+- "sw\t%7, 20($29)\n\t" \
+- cs_init \
+- "syscall\n\t" \
+- "addiu\t$29, 32\n\t" \
+- ".set\treorder" \
+- : "=r" (__v0), "+r" (__a3) \
+- : input, "r" (__a0), "r" (__a1), "r" (__a2), \
+- "r" ((long)arg5), "r" ((long)arg6) \
+- : __SYSCALL_CLOBBERS); \
+- err = __a3; \
+- _sys_result = __v0; \
+- } \
+- _sys_result; \
+-})
+-
+-#undef internal_syscall7
+-#define internal_syscall7(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5, arg6, arg7)\
+-({ \
+- long _sys_result; \
+- \
+- FORCE_FRAME_POINTER; \
+- { \
+- register long __v0 __asm__("$2") ncs_init; \
+- register long __a0 __asm__("$4") = (long) arg1; \
+- register long __a1 __asm__("$5") = (long) arg2; \
+- register long __a2 __asm__("$6") = (long) arg3; \
+- register long __a3 __asm__("$7") = (long) arg4; \
+- __asm__ __volatile__ ( \
+- ".set\tnoreorder\n\t" \
+- "subu\t$29, 32\n\t" \
+- "sw\t%6, 16($29)\n\t" \
+- "sw\t%7, 20($29)\n\t" \
+- "sw\t%8, 24($29)\n\t" \
+- cs_init \
+- "syscall\n\t" \
+- "addiu\t$29, 32\n\t" \
+- ".set\treorder" \
+- : "=r" (__v0), "+r" (__a3) \
+- : input, "r" (__a0), "r" (__a1), "r" (__a2), \
+- "r" ((long)arg5), "r" ((long)arg6), "r" ((long)arg7) \
+- : __SYSCALL_CLOBBERS); \
+- err = __a3; \
+- _sys_result = __v0; \
+- } \
+- _sys_result; \
+-})
+-
+-#undef __SYSCALL_CLOBBERS
+-#define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", \
+- "$14", "$15", "$24", "$25", "memory"
+-
+ /* Pointer mangling is not yet supported for MIPS. */
+ #define PTR_MANGLE(var) (void) (var)
+ #define PTR_DEMANGLE(var) (void) (var)
diff --git a/toolchain/uClibc/patches-0.9.33.2/611-mips_syscall_error_argument.patch b/toolchain/uClibc/patches-0.9.33.2/611-mips_syscall_error_argument.patch
new file mode 100644
index 0000000..87ef8ba
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/611-mips_syscall_error_argument.patch
@@ -0,0 +1,99 @@
+commit 2952c70804b48bb5c87eea21df5e401969dc4ec1
+Author: Kevin Cernekee <cernekee@gmail.com>
+Date: Tue Jun 5 15:05:20 2012 -0700
+
+ MIPS: Use $a0 instead of $v0 for __syscall_error() argument
+
+ $a0 is saved across _dl_runtime_resolve(); $v0 is not. Unfortunately,
+ __syscall_error() uses $v0 for its argument, not $a0 as is the MIPS ABI
+ standard. This means that if lazy binding was used for __syscall_error(),
+ the errno value in $v0 could get corrupted.
+
+ The problem can be easily seen in testcases where syscalls in librt fail;
+ when librt tries to call __syscall_error() in libc, the argument gets
+ lost and errno gets set to a bogus value:
+
+ # ./tst-mqueue1 ; echo $?
+ mq_receive on O_WRONLY mqd_t did not fail with EBADF: Unknown error 2004684208
+ 1
+ # ./tst-mqueue2 ; echo $?
+ mq_timedreceive with too small msg_len did not fail with EMSGSIZE: Unknown error 1997360560
+ 1
+ # ./tst-mqueue4 ; echo $?
+ mq_timedsend did not fail with ETIMEDOUT: Unknown error 2008747440
+ 1
+
+ When _dl_runtime_resolve() was taken out of the equation, the same test
+ cases passed:
+
+ # LD_BIND_NOW=y ./tst-mqueue1 ; echo $?
+ 0
+ # LD_BIND_NOW=y ./tst-mqueue2 ; echo $?
+ 0
+ # LD_BIND_NOW=y ./tst-mqueue4 ; echo $?
+ 0
+
+ Changing __syscall_error() to look at $a0 instead of $v0 fixed the
+ problem.
+
+ (Note that there is also a "__syscall_error.c" file which presumably
+ uses the standard C calling conventions, but I do not think it is used
+ on MIPS.)
+
+ Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
+ Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+
+commit 3c58d95d918c7e2fda374c37a52f81b34b81e4ca
+Author: Kevin Cernekee <cernekee@gmail.com>
+Date: Tue Jun 5 15:05:19 2012 -0700
+
+ MIPS: Convert __syscall_error() callers to use $a0 for argument
+
+ Some callers passed the first argument in $v0, while others used $a0.
+ Change the callers to use $a0 consistently.
+
+ Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
+ Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+
+--- a/libc/sysdeps/linux/mips/vfork.S
++++ b/libc/sysdeps/linux/mips/vfork.S
+@@ -84,6 +84,7 @@ NESTED(__vfork,FRAMESZ,sp)
+
+ /* Something bad happened -- no child created. */
+ L(error):
++ move a0, v0
+ #ifdef __PIC__
+ PTR_LA t9, __syscall_error
+ RESTORE_GP64
+--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
++++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
+@@ -31,7 +31,7 @@
+ # undef PSEUDO
+ # define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+- 99: \
++ 99: move a0, v0; \
+ PTR_LA t9,__syscall_error; \
+ /* manual cpreturn. */ \
+ REG_L gp, STKOFF_GP(sp); \
+--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S
++++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S
+@@ -80,6 +80,7 @@ NESTED(__vfork,FRAMESZ,sp)
+
+ /* Something bad happened -- no child created. */
+ L(error):
++ move a0, v0
+ #ifdef __PIC__
+ PTR_LA t9, __syscall_error
+ RESTORE_GP64
+--- a/libc/sysdeps/linux/mips/syscall_error.S
++++ b/libc/sysdeps/linux/mips/syscall_error.S
+@@ -43,7 +43,7 @@ ENTRY(__syscall_error)
+ #ifdef __PIC__
+ SAVE_GP(GPOFF)
+ #endif
+- REG_S v0, V0OFF(sp)
++ REG_S a0, V0OFF(sp)
+ REG_S ra, RAOFF(sp)
+
+ /* Find our per-thread errno address */
diff --git a/toolchain/uClibc/patches-0.9.33.2/612-mips64_relocation_fix.patch b/toolchain/uClibc/patches-0.9.33.2/612-mips64_relocation_fix.patch
new file mode 100644
index 0000000..7edeee1
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/612-mips64_relocation_fix.patch
@@ -0,0 +1,29 @@
+commit 052bcf13afb067cafac5e7f4fc21fbad2b34b11f
+Author: Waldemar Brodkorb <wbx@openadk.org>
+Date: Wed Nov 27 09:55:51 2013 +0100
+
+ Fix for SIGBUS error on MIPS64 with N64 ABI
+
+ When accessing errno, a per thread variable, from _stdio_init
+ a SIGBUS error happens. This change fixes the wrong relocation
+ and debug output.
+
+ Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
+ Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+
+--- a/ldso/ldso/mips/elfinterp.c
++++ b/ldso/ldso/mips/elfinterp.c
+@@ -259,11 +259,11 @@ int _dl_parse_relocation_information(str
+ case R_MIPS_TLS_TPREL32:
+ case R_MIPS_TLS_TPREL64:
+ CHECK_STATIC_TLS((struct link_map *)tls_tpnt);
+- *(ElfW(Word) *)reloc_addr +=
++ *(ElfW(Addr) *)reloc_addr +=
+ TLS_TPREL_VALUE (tls_tpnt, symbol_addr);
+ #ifdef __SUPPORT_LD_DEBUG__
+ _dl_dprintf(2, "TLS_TPREL : %s, %x, %x\n",
+- symname, old_val, *((unsigned int *)reloc_addr));
++ symname, old_val, *((unsigned long *)reloc_addr));
+ #endif
+ break;
+ }
diff --git a/toolchain/uClibc/patches-0.9.33.2/613-mips64_more_relocation_fixes.patch b/toolchain/uClibc/patches-0.9.33.2/613-mips64_more_relocation_fixes.patch
new file mode 100644
index 0000000..e2efa23
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/613-mips64_more_relocation_fixes.patch
@@ -0,0 +1,20 @@
+--- a/ldso/ldso/mips/elfinterp.c
++++ b/ldso/ldso/mips/elfinterp.c
+@@ -239,7 +239,7 @@ int _dl_parse_relocation_information(str
+ case R_MIPS_TLS_DTPMOD64:
+ case R_MIPS_TLS_DTPMOD32:
+ if (tls_tpnt)
+- *(ElfW(Word) *)reloc_addr = tls_tpnt->l_tls_modid;
++ *(ElfW(Addr) *)reloc_addr = tls_tpnt->l_tls_modid;
+ #ifdef __SUPPORT_LD_DEBUG__
+ _dl_dprintf(2, "TLS_DTPMOD : %s, %d, %d\n",
+ symname, old_val, *((unsigned int *)reloc_addr));
+@@ -248,7 +248,7 @@ int _dl_parse_relocation_information(str
+
+ case R_MIPS_TLS_DTPREL64:
+ case R_MIPS_TLS_DTPREL32:
+- *(ElfW(Word) *)reloc_addr +=
++ *(ElfW(Addr) *)reloc_addr +=
+ TLS_DTPREL_VALUE (symbol_addr);
+ #ifdef __SUPPORT_LD_DEBUG__
+ _dl_dprintf(2, "TLS_DTPREL : %s, %x, %x\n",
diff --git a/toolchain/uClibc/patches-0.9.33.2/614-mips64_fix_setjmp_longjmp.patch b/toolchain/uClibc/patches-0.9.33.2/614-mips64_fix_setjmp_longjmp.patch
new file mode 100644
index 0000000..1706130
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/614-mips64_fix_setjmp_longjmp.patch
@@ -0,0 +1,99 @@
+commit 70a04a287a2875c82e6822c36e071afba5b63a62
+Author: Waldemar Brodkorb <wbx@openadk.org>
+Date: Wed Jan 29 18:58:56 2014 +0100
+
+ libc: mips: Fix setjmp/longjmp for MIPS64 N64 ABI
+
+ When booting a Linux system with qemu-system-mips64 the execution
+ of $(pwd) in the ash shell triggers a segmentation fault. Ash uses
+ setjmp/longjmp for exception handling.
+
+ After looking at the glibc implementation,
+ I found some differences, with this patch tries to resolve.
+ Now the system boots up fine and no segmentation faults occur.
+
+ The global pointer should be restored and the types for the
+ register values should be wide enough.
+
+ See:
+ http://www.cygwin.com/ml/libc-alpha/2003-03/msg00363.html
+
+ Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
+ Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+
+--- a/libc/sysdeps/linux/mips/bits/setjmp.h
++++ b/libc/sysdeps/linux/mips/bits/setjmp.h
+@@ -26,13 +26,19 @@
+
+ #include <sgidefs.h>
+
++#if _MIPS_SIM == _MIPS_SIM_ABI32
++#define ptrsize void *
++#else
++#define ptrsize long long
++#endif
++
+ typedef struct
+ {
+ /* Program counter. */
+- void * __pc;
++ ptrsize __pc;
+
+ /* Stack pointer. */
+- void * __sp;
++ ptrsize __sp;
+
+ /* Callee-saved registers s0 through s7. */
+ #if _MIPS_SIM == _MIPS_SIM_ABI32
+@@ -42,10 +48,10 @@ typedef struct
+ #endif
+
+ /* The frame pointer. */
+- void * __fp;
++ ptrsize __fp;
+
+ /* The global pointer. */
+- void * __gp;
++ ptrsize __gp;
+
+ /* Floating point status register. */
+ int __fpc_csr;
+--- a/libc/sysdeps/linux/mips/setjmp.S
++++ b/libc/sysdeps/linux/mips/setjmp.S
+@@ -53,6 +53,7 @@ __sigsetjmp:
+ PTR_LA t9, __sigsetjmp_aux
+ #if _MIPS_SIM != _MIPS_SIM_ABI32
+ .cpreturn
++ move a4, gp
+ #endif
+ jr t9
+ #else
+--- a/libc/sysdeps/linux/mips/setjmp_aux.c
++++ b/libc/sysdeps/linux/mips/setjmp_aux.c
+@@ -31,7 +31,7 @@ extern int __sigjmp_save (sigjmp_buf, in
+
+ int
+ #if _MIPS_SIM == _MIPS_SIM_ABI64
+-__sigsetjmp_aux (jmp_buf env, int savemask, long sp, long fp)
++__sigsetjmp_aux (jmp_buf env, int savemask, long long sp, long long fp, long long gp)
+ #else /* O32 || N32 */
+ __sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
+ #endif /* O32 || N32 */
+@@ -65,14 +65,14 @@ __sigsetjmp_aux (jmp_buf env, int savema
+ #endif
+
+ /* .. and the stack pointer; */
+- env[0].__jmpbuf[0].__sp = (void *) sp;
++ env[0].__jmpbuf[0].__sp = (ptrsize) sp;
+
+ /* .. and the FP; it'll be in s8. */
+- env[0].__jmpbuf[0].__fp = (void *) fp;
++ env[0].__jmpbuf[0].__fp = (ptrsize) fp;
+
+ /* .. and the GP; */
+ #if _MIPS_SIM == _MIPS_SIM_ABI64
+- __asm__ __volatile__ ("sd $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp));
++ env[0].__jmpbuf[0].__gp = (ptrsize) gp;
+ #else
+ __asm__ __volatile__ ("sw $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp));
+ #endif
diff --git a/toolchain/uClibc/patches-0.9.33.2/615-mips_fix_sigev_pad_size.patch b/toolchain/uClibc/patches-0.9.33.2/615-mips_fix_sigev_pad_size.patch
new file mode 100644
index 0000000..f75092f
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/615-mips_fix_sigev_pad_size.patch
@@ -0,0 +1,58 @@
+commit b97b4b698b023f75b54f987859c856ab4861ea00
+Author: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
+Date: Thu Jan 2 15:02:12 2014 +0000
+
+ siginfo.h: __SIGEV_PAD_SIZE takes __WORDSIZE into account
+
+ Make __SIGEV_PAD_SIZE to take __WORDSIZE into account for alpha, mips
+ and ia64 arches.
+
+ Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
+ Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+
+--- a/libc/sysdeps/linux/alpha/bits/siginfo.h
++++ b/libc/sysdeps/linux/alpha/bits/siginfo.h
+@@ -258,7 +258,11 @@ enum
+
+ /* Structure to transport application-defined values with signals. */
+ # define __SIGEV_MAX_SIZE 64
+-# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
++# if __WORDSIZE == 64
++# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
++# else
++# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3)
++# endif
+
+ typedef struct sigevent
+ {
+--- a/libc/sysdeps/linux/ia64/bits/siginfo.h
++++ b/libc/sysdeps/linux/ia64/bits/siginfo.h
+@@ -298,7 +298,11 @@ enum
+
+ /* Structure to transport application-defined values with signals. */
+ # define __SIGEV_MAX_SIZE 64
+-# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
++# if __WORDSIZE == 64
++# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
++# else
++# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3)
++# endif
+
+ typedef struct sigevent
+ {
+--- a/libc/sysdeps/linux/mips/bits/siginfo.h
++++ b/libc/sysdeps/linux/mips/bits/siginfo.h
+@@ -265,8 +265,11 @@ enum
+
+ /* Structure to transport application-defined values with signals. */
+ # define __SIGEV_MAX_SIZE 64
+-# define __SIGEV_HEAD_SIZE (sizeof(long) + 2*sizeof(int))
+-# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE - __SIGEV_HEAD_SIZE) / sizeof (int))
++# if __WORDSIZE == 64
++# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
++# else
++# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3)
++# endif
+
+ /* Forward declaration of the `pthread_attr_t' type. */
+ struct __pthread_attr_s;
diff --git a/toolchain/uClibc/patches-0.9.33.2/616-mips_fix_stat_time.patch b/toolchain/uClibc/patches-0.9.33.2/616-mips_fix_stat_time.patch
new file mode 100644
index 0000000..1559857
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/616-mips_fix_stat_time.patch
@@ -0,0 +1,123 @@
+--- a/libc/sysdeps/linux/common/xstatconv.c
++++ b/libc/sysdeps/linux/common/xstatconv.c
+@@ -39,9 +39,12 @@ void __xstat_conv(struct kernel_stat *kb
+ buf->st_size = kbuf->st_size;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_blocks = kbuf->st_blocks;
+- buf->st_atim = kbuf->st_atim;
+- buf->st_mtim = kbuf->st_mtim;
+- buf->st_ctim = kbuf->st_ctim;
++ buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
++ buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
++ buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec;
++ buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec;
++ buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec;
++ buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec;
+ }
+
+ void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf)
+@@ -58,9 +61,12 @@ void __xstat32_conv(struct kernel_stat64
+ buf->st_size = kbuf->st_size;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_blocks = kbuf->st_blocks;
+- buf->st_atim = kbuf->st_atim;
+- buf->st_mtim = kbuf->st_mtim;
+- buf->st_ctim = kbuf->st_ctim;
++ buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
++ buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
++ buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec;
++ buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec;
++ buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec;
++ buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec;
+ }
+
+ #ifdef __UCLIBC_HAS_LFS__
+@@ -82,9 +88,12 @@ void __xstat64_conv(struct kernel_stat64
+ buf->st_size = kbuf->st_size;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_blocks = kbuf->st_blocks;
+- buf->st_atim = kbuf->st_atim;
+- buf->st_mtim = kbuf->st_mtim;
+- buf->st_ctim = kbuf->st_ctim;
++ buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
++ buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
++ buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec;
++ buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec;
++ buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec;
++ buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec;
+ }
+
+ #endif /* __UCLIBC_HAS_LFS__ */
+--- a/libc/sysdeps/linux/mips/bits/kernel_stat.h
++++ b/libc/sysdeps/linux/mips/bits/kernel_stat.h
+@@ -8,6 +8,18 @@
+ #include <sgidefs.h>
+
+ #if _MIPS_SIM == _MIPS_SIM_ABI64
++typedef struct {
++ unsigned int tv_sec;
++ unsigned int tv_nsec;
++} __ktimespec_t;
++#else
++typedef struct {
++ time_t tv_sec;
++ unsigned long tv_nsec;
++} __ktimespec_t;
++#endif
++
++#if _MIPS_SIM == _MIPS_SIM_ABI64
+ /* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
+ struct kernel_stat {
+ __kernel_dev_t st_dev;
+@@ -20,9 +32,9 @@ struct kernel_stat {
+ __kernel_dev_t st_rdev;
+ unsigned int st_pad2[3];
+ __kernel_off_t st_size;
+- struct timespec st_atim;
+- struct timespec st_mtim;
+- struct timespec st_ctim;
++ __ktimespec_t st_atim;
++ __ktimespec_t st_mtim;
++ __ktimespec_t st_ctim;
+ unsigned int st_blksize;
+ unsigned int reserved3;
+ unsigned long st_blocks;
+@@ -41,9 +53,9 @@ struct kernel_stat {
+ unsigned int st_rdev;
+ unsigned int st_pad2[3];
+ unsigned long long st_size;
+- struct timespec st_atim;
+- struct timespec st_mtim;
+- struct timespec st_ctim;
++ __ktimespec_t st_atim;
++ __ktimespec_t st_mtim;
++ __ktimespec_t st_ctim;
+ unsigned int st_blksize;
+ unsigned int reserved3;
+ unsigned long long st_blocks;
+@@ -62,9 +74,9 @@ struct kernel_stat {
+ long st_pad2[2];
+ __kernel_off_t st_size;
+ long st_pad3;
+- struct timespec st_atim;
+- struct timespec st_mtim;
+- struct timespec st_ctim;
++ __ktimespec_t st_atim;
++ __ktimespec_t st_mtim;
++ __ktimespec_t st_ctim;
+ long st_blksize;
+ long st_blocks;
+ long st_pad4[14];
+@@ -81,9 +93,9 @@ struct kernel_stat64 {
+ unsigned long st_rdev;
+ unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */
+ long long st_size;
+- struct timespec st_atim;
+- struct timespec st_mtim;
+- struct timespec st_ctim;
++ __ktimespec_t st_atim;
++ __ktimespec_t st_mtim;
++ __ktimespec_t st_ctim;
+ unsigned long st_blksize;
+ unsigned long st_pad2;
+ long long st_blocks;
diff --git a/toolchain/uClibc/patches-0.9.33.2/617-mips_fix_setjmp_ptrsize.patch b/toolchain/uClibc/patches-0.9.33.2/617-mips_fix_setjmp_ptrsize.patch
new file mode 100644
index 0000000..628d4b0
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/617-mips_fix_setjmp_ptrsize.patch
@@ -0,0 +1,58 @@
+--- a/libc/sysdeps/linux/mips/bits/setjmp.h
++++ b/libc/sysdeps/linux/mips/bits/setjmp.h
+@@ -27,18 +27,18 @@
+ #include <sgidefs.h>
+
+ #if _MIPS_SIM == _MIPS_SIM_ABI32
+-#define ptrsize void *
++#define __setjmp_ptr void *
+ #else
+-#define ptrsize long long
++#define __setjmp_ptr long long
+ #endif
+
+ typedef struct
+ {
+ /* Program counter. */
+- ptrsize __pc;
++ __setjmp_ptr __pc;
+
+ /* Stack pointer. */
+- ptrsize __sp;
++ __setjmp_ptr __sp;
+
+ /* Callee-saved registers s0 through s7. */
+ #if _MIPS_SIM == _MIPS_SIM_ABI32
+@@ -48,10 +48,10 @@ typedef struct
+ #endif
+
+ /* The frame pointer. */
+- ptrsize __fp;
++ __setjmp_ptr __fp;
+
+ /* The global pointer. */
+- ptrsize __gp;
++ __setjmp_ptr __gp;
+
+ /* Floating point status register. */
+ int __fpc_csr;
+--- a/libc/sysdeps/linux/mips/setjmp_aux.c
++++ b/libc/sysdeps/linux/mips/setjmp_aux.c
+@@ -65,14 +65,14 @@ __sigsetjmp_aux (jmp_buf env, int savema
+ #endif
+
+ /* .. and the stack pointer; */
+- env[0].__jmpbuf[0].__sp = (ptrsize) sp;
++ env[0].__jmpbuf[0].__sp = (__setjmp_ptr) sp;
+
+ /* .. and the FP; it'll be in s8. */
+- env[0].__jmpbuf[0].__fp = (ptrsize) fp;
++ env[0].__jmpbuf[0].__fp = (__setjmp_ptr) fp;
+
+ /* .. and the GP; */
+ #if _MIPS_SIM == _MIPS_SIM_ABI64
+- env[0].__jmpbuf[0].__gp = (ptrsize) gp;
++ env[0].__jmpbuf[0].__gp = (__setjmp_ptr) gp;
+ #else
+ __asm__ __volatile__ ("sw $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp));
+ #endif
diff --git a/toolchain/uClibc/patches-0.9.33.2/618-mips64_fix_syscall_error.patch b/toolchain/uClibc/patches-0.9.33.2/618-mips64_fix_syscall_error.patch
new file mode 100644
index 0000000..67611fd
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/618-mips64_fix_syscall_error.patch
@@ -0,0 +1,36 @@
+--- a/libc/sysdeps/linux/mips/sysdep.h
++++ b/libc/sysdeps/linux/mips/sysdep.h
+@@ -96,7 +96,8 @@
+ backwards into the previous fn. */
+
+ #ifdef __PIC__
+-#define PSEUDO(name, syscall_name, args) \
++# if _MIPS_SIM == _ABIO32
++# define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+ 99: move a0, v0; \
+ la t9,__syscall_error; \
+@@ -109,6 +110,23 @@
+ .set reorder; \
+ bne a3, zero, 99b; \
+ L(syse1):
++# else
++# define PSEUDO(name, syscall_name, args) \
++ .align 2; \
++ 99: \
++ .set noat; \
++ .cpsetup t9, $1, name; \
++ .set at; \
++ move a0, v0; \
++ dla t9,__syscall_error; \
++ .cpreturn; \
++ jr t9; \
++ ENTRY(name) \
++ li v0, SYS_ify(syscall_name); \
++ syscall; \
++ bne a3, zero, 99b; \
++L(syse1):
++# endif
+ #else
+ #define PSEUDO(name, syscall_name, args) \
+ .set noreorder; \
diff --git a/toolchain/uClibc/patches-0.9.33.2/619-mips64_fix_sysdep_cancel.patch b/toolchain/uClibc/patches-0.9.33.2/619-mips64_fix_sysdep_cancel.patch
new file mode 100644
index 0000000..d590359
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/619-mips64_fix_sysdep_cancel.patch
@@ -0,0 +1,195 @@
+--- a/extra/Configs/Config.in
++++ b/extra/Configs/Config.in
+@@ -235,6 +235,7 @@ config TARGET_SUBARCH
+ default "i486" if CONFIG_486
+ default "i586" if CONFIG_586 || CONFIG_586MMX
+ default "i686" if TARGET_ARCH = "i386"
++ default "mips64" if CONFIG_MIPS_N64_ABI
+ default ""
+
+ source "extra/Configs/Config.in.arch"
+--- /dev/null
++++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
+@@ -0,0 +1,182 @@
++/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library. If not, see
++ <http://www.gnu.org/licenses/>. */
++
++#include <sysdep.h>
++#include <tls.h>
++#ifndef __ASSEMBLER__
++# include <pthreadP.h>
++#endif
++#include <sys/asm.h>
++
++/* Gas will put the initial save of $gp into the CIE, because it appears to
++ happen before any instructions. So we use cfi_same_value instead of
++ cfi_restore. */
++
++#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
++
++#ifdef __PIC__
++# undef PSEUDO
++# define PSEUDO(name, syscall_name, args) \
++ .align 2; \
++ L(pseudo_start): \
++ cfi_startproc; \
++ cfi_adjust_cfa_offset (STKSPACE); \
++ cfi_rel_offset (gp, STKOFF_GP); \
++ 99: move a0, v0; \
++ PTR_LA t9,__syscall_error; \
++ /* manual cpreturn */ \
++ REG_L gp, STKOFF_GP(sp); \
++ cfi_same_value (gp); \
++ RESTORESTK; \
++ jr t9; \
++ .type __##syscall_name##_nocancel, @function; \
++ .globl __##syscall_name##_nocancel; \
++ __##syscall_name##_nocancel: \
++ SAVESTK; \
++ .cpsetup t9, STKOFF_GP, name; \
++ cfi_rel_offset (gp, STKOFF_GP); \
++ li v0, SYS_ify(syscall_name); \
++ syscall; \
++ bne a3, zero, SYSCALL_ERROR_LABEL; \
++ /* manual cpreturn */ \
++ REG_L gp, STKOFF_GP(sp); \
++ cfi_same_value (gp); \
++ RESTORESTK; \
++ ret; \
++ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
++ ENTRY (name) \
++ SAVESTK; \
++ .cpsetup t9, STKOFF_GP, name; \
++ cfi_rel_offset (gp, STKOFF_GP); \
++ SINGLE_THREAD_P(v1); \
++ bne zero, v1, L(pseudo_cancel); \
++ .set noreorder; \
++ li v0, SYS_ify(syscall_name); \
++ syscall; \
++ .set reorder; \
++ bne a3, zero, SYSCALL_ERROR_LABEL; \
++ /* manual cpreturn */ \
++ REG_L gp, STKOFF_GP(sp); \
++ cfi_same_value (gp); \
++ RESTORESTK; \
++ ret; \
++ L(pseudo_cancel): \
++ cfi_adjust_cfa_offset (STKSPACE); \
++ cfi_rel_offset (gp, STKOFF_GP); \
++ REG_S ra, STKOFF_RA(sp); \
++ cfi_rel_offset (ra, STKOFF_RA); \
++ PUSHARGS_##args; /* save syscall args */ \
++ CENABLE; \
++ REG_S v0, STKOFF_SVMSK(sp); /* save mask */ \
++ POPARGS_##args; /* restore syscall args */ \
++ .set noreorder; \
++ li v0, SYS_ify (syscall_name); \
++ syscall; \
++ .set reorder; \
++ REG_S v0, STKOFF_SC_V0(sp); /* save syscall result */ \
++ REG_S a3, STKOFF_SC_ERR(sp); /* save syscall error flag */ \
++ REG_L a0, STKOFF_SVMSK(sp); /* pass mask as arg1 */ \
++ CDISABLE; \
++ REG_L a3, STKOFF_SC_ERR(sp); /* restore syscall error flag */ \
++ REG_L ra, STKOFF_RA(sp); /* restore return address */ \
++ REG_L v0, STKOFF_SC_V0(sp); /* restore syscall result */ \
++ bne a3, zero, SYSCALL_ERROR_LABEL; \
++ /* manual cpreturn */ \
++ REG_L gp, STKOFF_GP(sp); \
++ cfi_same_value (gp); \
++ RESTORESTK; \
++ L(pseudo_end):
++
++
++# undef PSEUDO_END
++# define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym
++
++#endif
++
++# define PUSHARGS_0 /* nothing to do */
++# define PUSHARGS_1 PUSHARGS_0 REG_S a0, STKOFF_A0(sp); cfi_rel_offset (a0, STKOFF_A0);
++# define PUSHARGS_2 PUSHARGS_1 REG_S a1, STKOFF_A1(sp); cfi_rel_offset (a1, STKOFF_A1);
++# define PUSHARGS_3 PUSHARGS_2 REG_S a2, STKOFF_A2(sp); cfi_rel_offset (a2, STKOFF_A2);
++# define PUSHARGS_4 PUSHARGS_3 REG_S a3, STKOFF_A3(sp); cfi_rel_offset (a3, STKOFF_A3);
++# define PUSHARGS_5 PUSHARGS_4 REG_S a4, STKOFF_A4(sp); cfi_rel_offset (a3, STKOFF_A4);
++# define PUSHARGS_6 PUSHARGS_5 REG_S a5, STKOFF_A5(sp); cfi_rel_offset (a3, STKOFF_A5);
++
++# define POPARGS_0 /* nothing to do */
++# define POPARGS_1 POPARGS_0 REG_L a0, STKOFF_A0(sp);
++# define POPARGS_2 POPARGS_1 REG_L a1, STKOFF_A1(sp);
++# define POPARGS_3 POPARGS_2 REG_L a2, STKOFF_A2(sp);
++# define POPARGS_4 POPARGS_3 REG_L a3, STKOFF_A3(sp);
++# define POPARGS_5 POPARGS_4 REG_L a4, STKOFF_A4(sp);
++# define POPARGS_6 POPARGS_5 REG_L a5, STKOFF_A5(sp);
++
++/* Save an even number of slots. Should be 0 if an even number of slots
++ are used below, or SZREG if an odd number are used. */
++# define STK_PAD SZREG
++
++/* Place values that we are more likely to use later in this sequence, i.e.
++ closer to the SP at function entry. If you do that, the are more
++ likely to already be in your d-cache. */
++# define STKOFF_A5 (STK_PAD)
++# define STKOFF_A4 (STKOFF_A5 + SZREG)
++# define STKOFF_A3 (STKOFF_A4 + SZREG)
++# define STKOFF_A2 (STKOFF_A3 + SZREG) /* MT and more args. */
++# define STKOFF_A1 (STKOFF_A2 + SZREG) /* MT and 2 args. */
++# define STKOFF_A0 (STKOFF_A1 + SZREG) /* MT and 1 arg. */
++# define STKOFF_RA (STKOFF_A0 + SZREG) /* Used if MT. */
++# define STKOFF_SC_V0 (STKOFF_RA + SZREG) /* Used if MT. */
++# define STKOFF_SC_ERR (STKOFF_SC_V0 + SZREG) /* Used if MT. */
++# define STKOFF_SVMSK (STKOFF_SC_ERR + SZREG) /* Used if MT. */
++# define STKOFF_GP (STKOFF_SVMSK + SZREG) /* Always used. */
++
++# define STKSPACE (STKOFF_GP + SZREG)
++# define SAVESTK PTR_SUBU sp, STKSPACE; cfi_adjust_cfa_offset(STKSPACE)
++# define RESTORESTK PTR_ADDU sp, STKSPACE; cfi_adjust_cfa_offset(-STKSPACE)
++
++# ifdef IS_IN_libpthread
++# define CENABLE PTR_LA t9, __pthread_enable_asynccancel; jalr t9
++# define CDISABLE PTR_LA t9, __pthread_disable_asynccancel; jalr t9
++# elif defined IS_IN_librt
++# define CENABLE PTR_LA t9, __librt_enable_asynccancel; jalr t9
++# define CDISABLE PTR_LA t9, __librt_disable_asynccancel; jalr t9
++# else
++# define CENABLE PTR_LA t9, __libc_enable_asynccancel; jalr t9
++# define CDISABLE PTR_LA t9, __libc_disable_asynccancel; jalr t9
++# endif
++
++# ifndef __ASSEMBLER__
++# define SINGLE_THREAD_P \
++ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
++ header.multiple_threads) \
++ == 0, 1)
++# else
++# define SINGLE_THREAD_P(reg) \
++ READ_THREAD_POINTER(reg); \
++ lw reg, MULTIPLE_THREADS_OFFSET(reg)
++#endif
++
++#elif !defined __ASSEMBLER__
++
++# define SINGLE_THREAD_P 1
++# define NO_CANCELLATION 1
++
++#endif
++
++#ifndef __ASSEMBLER__
++# define RTLD_SINGLE_THREAD_P \
++ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
++ header.multiple_threads) == 0, 1)
++#endif
diff --git a/toolchain/uClibc/patches-0.9.33.2/960-remove_eabi_oabi_selection.patch b/toolchain/uClibc/patches-0.9.33.2/960-remove_eabi_oabi_selection.patch
new file mode 100644
index 0000000..19ac246
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/960-remove_eabi_oabi_selection.patch
@@ -0,0 +1,32 @@
+Rely on the compiler to be properly setup for the default ABI.
+
+When installing-headers, there are two cases:
+- NPTL: no issue, a cross-compiler is already expected
+- LinuxThreads: no issue, EABI/OABI has no impact on installed headers.
+
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
+Cc: Khem Raj <raj.khem@gmail.com>
+Cc: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+Cc: Carmelo AMOROSO <carmelo.amoroso@st.com>
+---
+
+--- a/extra/Configs/Config.arm
++++ b/extra/Configs/Config.arm
+@@ -12,17 +12,6 @@ config FORCE_OPTIONS_FOR_ARCH
+ default y
+ select ARCH_ANY_ENDIAN
+
+-config CONFIG_ARM_EABI
+- bool "Build for EABI"
+- help
+- If you say 'y' here, functions and constants required by the
+- ARM EABI will be built into the library. You should say 'y'
+- if your compiler uses the ARM EABI, in which case you will also
+- need a kernel supporting the EABI system call interface.
+-
+- If you say 'n' here, then the library will be built for the
+- old Linux ABI.
+-
+ config COMPILE_IN_THUMB_MODE
+ bool "Build using Thumb mode"
+ select USE_BX
diff --git a/toolchain/uClibc/patches-0.9.33.2/970-add___kernel_long_and___kernel_ulong.patch b/toolchain/uClibc/patches-0.9.33.2/970-add___kernel_long_and___kernel_ulong.patch
new file mode 100644
index 0000000..d790664
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/970-add___kernel_long_and___kernel_ulong.patch
@@ -0,0 +1,320 @@
+From 6a76edddaa62ff06f178143b582167734cb55c18 Mon Sep 17 00:00:00 2001
+From: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Date: Mon, 01 Oct 2012 05:12:54 +0000
+Subject: libc/sysdeps: add __kernel_long and __kernel_ulong
+
+Linux 3.4 added __kernel_long_t and __kernel_ulong_t and various
+exported header files were updated to use these new types. Add the
+definitions for __kernel_long_t and __kernel_ulong_t to the relevant
+kernel_types.h headers.
+
+This change was automated with the following scriptlet
+
+ git grep --name-only 'typedef.*__kernel_old_dev_t' \
+ | xargs sed -i '/typedef.*__kernel_old_dev_t/ a\
+ typedef long\t\t__kernel_long_t;\
+ typedef unsigned long\t__kernel_ulong_t;'
+
+Whitespace in arm, avr32, hppa, sparc was then manually fixed up.
+
+Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
+--
+Here's a cleaned up patch which should get the whitespace right. I'm a
+bit iffy about the sparc changes they make sense to me but it's not a
+platform I have access to.
+
+I can break this up per arch or per maintainer if requested.
+
+ libc/sysdeps/linux/alpha/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/arm/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/avr32/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/bfin/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/c6x/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/cris/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/e1/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/h8300/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/hppa/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/i386/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/ia64/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/m68k/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/microblaze/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/mips/bits/kernel_types.h | 4 ++++
+ libc/sysdeps/linux/nios2/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/powerpc/bits/kernel_types.h | 4 ++++
+ libc/sysdeps/linux/sh/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/sh64/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/sparc/bits/kernel_types.h | 4 ++++
+ libc/sysdeps/linux/v850/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/x86_64/bits/kernel_types.h | 2 ++
+ libc/sysdeps/linux/xtensa/bits/kernel_types.h | 2 ++
+ 22 files changed, 50 insertions(+)
+Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+---
+--- a/libc/sysdeps/linux/alpha/bits/kernel_types.h
++++ b/libc/sysdeps/linux/alpha/bits/kernel_types.h
+@@ -33,6 +33,8 @@ typedef __kernel_gid_t __kernel_old_gid_
+ typedef __kernel_uid_t __kernel_uid32_t;
+ typedef __kernel_gid_t __kernel_gid32_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+
+ typedef struct {
+ int val[2];
+--- a/libc/sysdeps/linux/arm/bits/kernel_types.h
++++ b/libc/sysdeps/linux/arm/bits/kernel_types.h
+@@ -32,6 +32,8 @@ typedef unsigned short __kernel_old_uid
+ typedef unsigned short __kernel_old_gid_t;
+ typedef long long __kernel_loff_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+
+ typedef struct {
+ #ifdef __USE_ALL
+--- a/libc/sysdeps/linux/avr32/bits/kernel_types.h
++++ b/libc/sysdeps/linux/avr32/bits/kernel_types.h
+@@ -39,6 +39,8 @@ typedef unsigned int __kernel_gid32_t;
+ typedef unsigned short __kernel_old_uid_t;
+ typedef unsigned short __kernel_old_gid_t;
+ typedef unsigned short __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+
+ #ifdef __GNUC__
+ typedef long long __kernel_loff_t;
+--- a/libc/sysdeps/linux/bfin/bits/kernel_types.h
++++ b/libc/sysdeps/linux/bfin/bits/kernel_types.h
+@@ -32,6 +32,8 @@ typedef unsigned short __kernel_old_uid_
+ typedef unsigned short __kernel_old_gid_t;
+ typedef long long __kernel_loff_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+
+ typedef struct {
+ #ifdef __USE_ALL
+--- a/libc/sysdeps/linux/c6x/bits/kernel_types.h
++++ b/libc/sysdeps/linux/c6x/bits/kernel_types.h
+@@ -22,6 +22,8 @@ typedef unsigned int __kernel_gid32_t;
+ typedef unsigned int __kernel_old_uid_t;
+ typedef unsigned int __kernel_old_gid_t;
+ typedef unsigned int __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef unsigned int __kernel_size_t;
+ typedef int __kernel_ssize_t;
+ typedef int __kernel_ptrdiff_t;
+--- a/libc/sysdeps/linux/cris/bits/kernel_types.h
++++ b/libc/sysdeps/linux/cris/bits/kernel_types.h
+@@ -28,6 +28,8 @@ typedef unsigned int __kernel_gid32_t
+ typedef unsigned short __kernel_old_uid_t;
+ typedef unsigned short __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+
+ #ifdef __GNUC__
+ typedef long long __kernel_loff_t;
+--- a/libc/sysdeps/linux/e1/bits/kernel_types.h
++++ b/libc/sysdeps/linux/e1/bits/kernel_types.h
+@@ -31,6 +31,8 @@ typedef unsigned int __kernel_gid32_t;
+ typedef unsigned short __kernel_old_uid_t;
+ typedef unsigned short __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef long long __kernel_loff_t;
+
+ /*
+--- a/libc/sysdeps/linux/h8300/bits/kernel_types.h
++++ b/libc/sysdeps/linux/h8300/bits/kernel_types.h
+@@ -32,6 +32,8 @@ typedef unsigned short __kernel_old_uid_
+ typedef unsigned short __kernel_old_gid_t;
+ typedef long long __kernel_loff_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+
+ typedef struct {
+ #ifdef __USE_ALL
+--- a/libc/sysdeps/linux/hppa/bits/kernel_types.h
++++ b/libc/sysdeps/linux/hppa/bits/kernel_types.h
+@@ -45,6 +45,8 @@ typedef long long __kernel_off64_t;
+ typedef unsigned long long __kernel_ino64_t;
+
+ typedef unsigned int __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+
+ typedef struct {
+ #ifdef __USE_ALL
+--- a/libc/sysdeps/linux/i386/bits/kernel_types.h
++++ b/libc/sysdeps/linux/i386/bits/kernel_types.h
+@@ -40,6 +40,8 @@ typedef unsigned int __kernel_gid32_t;
+ typedef unsigned short __kernel_old_uid_t;
+ typedef unsigned short __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef long long __kernel_loff_t;
+
+ typedef struct {
+--- a/libc/sysdeps/linux/ia64/bits/kernel_types.h
++++ b/libc/sysdeps/linux/ia64/bits/kernel_types.h
+@@ -52,5 +52,7 @@ typedef __kernel_gid_t __kernel_gid32_t;
+
+ typedef unsigned int __kernel_dev_t;
+ typedef unsigned int __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+
+ #endif /* _ASM_IA64_POSIX_TYPES_H */
+--- a/libc/sysdeps/linux/m68k/bits/kernel_types.h
++++ b/libc/sysdeps/linux/m68k/bits/kernel_types.h
+@@ -32,6 +32,8 @@ typedef unsigned short __kernel_old_uid_
+ typedef unsigned short __kernel_old_gid_t;
+ typedef long long __kernel_loff_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+
+ typedef struct {
+ #ifdef __USE_ALL
+--- a/libc/sysdeps/linux/microblaze/bits/kernel_types.h
++++ b/libc/sysdeps/linux/microblaze/bits/kernel_types.h
+@@ -44,6 +44,8 @@ typedef unsigned int __kernel_gid32_t;
+ typedef unsigned int __kernel_old_uid_t;
+ typedef unsigned int __kernel_old_gid_t;
+ typedef unsigned int __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+
+ #ifdef __GNUC__
+ typedef long long __kernel_loff_t;
+--- a/libc/sysdeps/linux/mips/bits/kernel_types.h
++++ b/libc/sysdeps/linux/mips/bits/kernel_types.h
+@@ -32,6 +32,8 @@ typedef int __kernel_gid32_t;
+ typedef __kernel_uid_t __kernel_old_uid_t;
+ typedef __kernel_gid_t __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef long long __kernel_loff_t;
+ #else
+ typedef unsigned int __kernel_dev_t;
+@@ -68,6 +70,8 @@ typedef int __kernel_gid32_t;
+ typedef __kernel_uid_t __kernel_old_uid_t;
+ typedef __kernel_gid_t __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef long long __kernel_loff_t;
+ #endif
+
+--- a/libc/sysdeps/linux/nios2/bits/kernel_types.h
++++ b/libc/sysdeps/linux/nios2/bits/kernel_types.h
+@@ -31,6 +31,8 @@ typedef unsigned int __kernel_gid32_t;
+ typedef unsigned short __kernel_old_uid_t;
+ typedef unsigned short __kernel_old_gid_t;
+ typedef unsigned short __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef long long __kernel_loff_t;
+
+ typedef struct {
+--- a/libc/sysdeps/linux/powerpc/bits/kernel_types.h
++++ b/libc/sysdeps/linux/powerpc/bits/kernel_types.h
+@@ -36,6 +36,8 @@ typedef unsigned int __kernel_gid32_t;
+ typedef unsigned int __kernel_old_uid_t;
+ typedef unsigned int __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ #else
+ typedef unsigned int __kernel_dev_t;
+ typedef unsigned int __kernel_ino_t;
+@@ -61,6 +63,8 @@ typedef unsigned int __kernel_gid32_t;
+ typedef unsigned int __kernel_old_uid_t;
+ typedef unsigned int __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef long long __kernel_loff_t;
+ #endif
+
+--- a/libc/sysdeps/linux/sh/bits/kernel_types.h
++++ b/libc/sysdeps/linux/sh/bits/kernel_types.h
+@@ -32,6 +32,8 @@ typedef unsigned int __kernel_gid32_t;
+ typedef unsigned short __kernel_old_uid_t;
+ typedef unsigned short __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef long long __kernel_loff_t;
+
+ typedef struct {
+--- a/libc/sysdeps/linux/sh64/bits/kernel_types.h
++++ b/libc/sysdeps/linux/sh64/bits/kernel_types.h
+@@ -43,6 +43,8 @@ typedef unsigned int __kernel_gid32_t
+ typedef unsigned short __kernel_old_uid_t;
+ typedef unsigned short __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef long long __kernel_loff_t;
+
+ typedef struct {
+--- a/libc/sysdeps/linux/sparc/bits/kernel_types.h
++++ b/libc/sysdeps/linux/sparc/bits/kernel_types.h
+@@ -32,6 +32,8 @@ typedef unsigned short __kernel_g
+ typedef __kernel_uid_t __kernel_old_uid_t;
+ typedef __kernel_gid_t __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef __kernel_uid_t __kernel_uid32_t;
+ typedef __kernel_gid_t __kernel_gid32_t;
+ typedef int __kernel_suseconds_t;
+@@ -62,6 +64,8 @@ typedef unsigned int __kernel_gid
+ typedef unsigned short __kernel_old_uid_t;
+ typedef unsigned short __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef long long __kernel_loff_t;
+ #endif
+
+--- a/libc/sysdeps/linux/v850/bits/kernel_types.h
++++ b/libc/sysdeps/linux/v850/bits/kernel_types.h
+@@ -41,6 +41,8 @@ typedef unsigned int __kernel_gid32_t;
+ typedef unsigned short __kernel_old_uid_t;
+ typedef unsigned short __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+
+ typedef struct {
+ #ifdef __USE_ALL
+--- a/libc/sysdeps/linux/x86_64/bits/kernel_types.h
++++ b/libc/sysdeps/linux/x86_64/bits/kernel_types.h
+@@ -40,6 +40,8 @@ typedef unsigned int __kernel_gid32_t;
+ typedef unsigned short __kernel_old_uid_t;
+ typedef unsigned short __kernel_old_gid_t;
+ typedef __kernel_dev_t __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef long long __kernel_loff_t;
+
+ typedef struct {
+--- a/libc/sysdeps/linux/xtensa/bits/kernel_types.h
++++ b/libc/sysdeps/linux/xtensa/bits/kernel_types.h
+@@ -33,6 +33,8 @@ typedef unsigned int __kernel_gid32_t;
+ typedef unsigned short __kernel_old_uid_t;
+ typedef unsigned short __kernel_old_gid_t;
+ typedef unsigned short __kernel_old_dev_t;
++typedef long __kernel_long_t;
++typedef unsigned long __kernel_ulong_t;
+ typedef long long __kernel_loff_t;
+
+ /* Beginning in 2.6 kernels, which is the first version that includes the
diff --git a/toolchain/uClibc/patches-0.9.33.2/981-fix_setting_arch_native_bit.patch b/toolchain/uClibc/patches-0.9.33.2/981-fix_setting_arch_native_bit.patch
new file mode 100644
index 0000000..4c7dd46
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/981-fix_setting_arch_native_bit.patch
@@ -0,0 +1,28 @@
+From 7e509aae23665b9a79f6c9b4c24d1d8a55bd3582 Mon Sep 17 00:00:00 2001
+From: Gustavo Zacarias <gustavo@zacarias.com.ar>
+Date: Wed, 24 Jul 2013 15:30:35 +0000
+Subject: Rules.mak: Fix setting arch native bit
+
+fix breakage from 603af30d
+
+Removing the whitespace from findstring for 64 bit architectures has
+bad consequences since powerpc would be a match in powerpc64 and sparc
+would also be a match in sparc64.
+That doesn't make them 64 bits in reality causing general breakage.
+
+Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
+Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>
+Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+---
+
+--- a/Rules.mak
++++ b/Rules.mak
+@@ -121,7 +121,7 @@ UBACKTRACE_DSO := libubacktrace.so.$(ABI
+
+ UCLIBC_LDSO_NAME := ld-uClibc
+ ARCH_NATIVE_BIT := 32
+-ifneq ($(findstring $(TARGET_ARCH),hppa64 ia64 powerpc64 s390x sparc64 x86_64),)
++ifneq ($(findstring $(TARGET_ARCH) , hppa64 ia64 powerpc64 s390x sparc64 x86_64 ),)
+ UCLIBC_LDSO_NAME := ld64-uClibc
+ ARCH_NATIVE_BIT := 64
+ else
diff --git a/toolchain/uClibc/patches-0.9.33.2/990-no-stack-cache.patch b/toolchain/uClibc/patches-0.9.33.2/990-no-stack-cache.patch
new file mode 100644
index 0000000..8f0b511
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/990-no-stack-cache.patch
@@ -0,0 +1,11 @@
+--- a/libpthread/nptl/allocatestack.c
++++ b/libpthread/nptl/allocatestack.c
+@@ -100,7 +100,7 @@
+ /* Cache handling for not-yet free stacks. */
+
+ /* Maximum size in kB of cache. */
+-static size_t stack_cache_maxsize = 40 * 1024 * 1024; /* 40MiBi by default. */
++static size_t stack_cache_maxsize = 0; /* embedded systems don't have enough ram for dirty stack caches */
+ static size_t stack_cache_actsize;
+
+ /* Mutex protecting this variable. */
diff --git a/toolchain/uClibc/patches-0.9.33.2/991-gen_wctype.patch b/toolchain/uClibc/patches-0.9.33.2/991-gen_wctype.patch
new file mode 100644
index 0000000..e85d6d4
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/991-gen_wctype.patch
@@ -0,0 +1,183 @@
+--- a/extra/locale/gen_wctype.c
++++ b/extra/locale/gen_wctype.c
+@@ -227,11 +227,12 @@ int main(int argc, char **argv)
+ ++verbose;
+ continue;
+ }
+- if (!setlocale(LC_CTYPE, *argv)) {
++ /* setlocale might be just a stub */
++ /* if (!setlocale(LC_CTYPE, *argv)) {
+ verbose_msg("setlocale(LC_CTYPE,%s) failed! Skipping this locale...\n", *argv);
+ continue;
+ }
+-
++ */
+ if (!(totitle = wctrans("totitle"))) {
+ verbose_msg("no totitle transformation.\n");
+ }
+@@ -306,43 +307,43 @@ int main(int argc, char **argv)
+ #endif
+ #if 0
+ if (c < 256) {
+- unsigned int glibc;
++ unsigned int curr_stdclib;
+
+- glibc = 0;
+- if (isalnum(c)) ++glibc; glibc <<= 1;
+- if (isalpha(c)) ++glibc; glibc <<= 1;
+- if (isblank(c)) ++glibc; glibc <<= 1;
+- if (iscntrl(c)) ++glibc; glibc <<= 1;
+- if (isdigit(c)) ++glibc; glibc <<= 1;
+- if (isgraph(c)) ++glibc; glibc <<= 1;
+- if (islower(c)) ++glibc; glibc <<= 1;
+- if (isprint(c)) ++glibc; glibc <<= 1;
+- if (ispunct(c)) ++glibc; glibc <<= 1;
+- if (isspace(c)) ++glibc; glibc <<= 1;
+- if (isupper(c)) ++glibc; glibc <<= 1;
+- if (isxdigit(c)) ++glibc;
+- verbose_msg("%#8x : ctype %#4x\n", c, glibc);
++ curr_stdclib = 0;
++ if (isalnum(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (isalpha(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (isblank(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iscntrl(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (isdigit(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (isgraph(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (islower(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (isprint(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (ispunct(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (isspace(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (isupper(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (isxdigit(c)) ++curr_stdclib;
++ verbose_msg("%#8x : ctype %#4x\n", c, curr_stdclib);
+ }
+ #endif
+ #if 1
+ /* Paranoid checking... */
+ {
+- unsigned int glibc;
++ unsigned int curr_stdclib;
+ unsigned int mine;
+
+- glibc = 0;
+- if (iswalnum(c)) ++glibc; glibc <<= 1;
+- if (iswalpha(c)) ++glibc; glibc <<= 1;
+- if (iswblank(c)) ++glibc; glibc <<= 1;
+- if (iswcntrl(c)) ++glibc; glibc <<= 1;
+- if (iswdigit(c)) ++glibc; glibc <<= 1;
+- if (iswgraph(c)) ++glibc; glibc <<= 1;
+- if (iswlower(c)) ++glibc; glibc <<= 1;
+- if (iswprint(c)) ++glibc; glibc <<= 1;
+- if (iswpunct(c)) ++glibc; glibc <<= 1;
+- if (iswspace(c)) ++glibc; glibc <<= 1;
+- if (iswupper(c)) ++glibc; glibc <<= 1;
+- if (iswxdigit(c)) ++glibc;
++ curr_stdclib = 0;
++ if (iswalnum(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswalpha(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswblank(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswcntrl(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswdigit(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswgraph(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswlower(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswprint(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswpunct(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswspace(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswupper(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswxdigit(c)) ++curr_stdclib;
+
+ mine = 0;
+ if (mywalnum(d,c)) ++mine; mine <<= 1;
+@@ -358,15 +359,15 @@ int main(int argc, char **argv)
+ if (mywupper(d,c)) ++mine; mine <<= 1;
+ if (mywxdigit(d,c)) ++mine;
+
+- if (glibc != mine) {
+- verbose_msg("%#8x : glibc %#4x != %#4x mine %u\n", c, glibc, mine, d);
++ if (curr_stdclib != mine) {
++ verbose_msg("%#8x : curr_stdclib %#4x != %#4x mine %u\n", c, curr_stdclib, mine, d);
+ return EXIT_FAILURE;
+ }
+ #if 0
+ if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
+ /* if (!iswpunct(c)) { */
+ verbose_msg("%#8x : %d %d %#4x\n",
+- c, iswctype(c,is_comb),iswctype(c,is_comb3), glibc);
++ c, iswctype(c,is_comb),iswctype(c,is_comb3), curr_stdclib);
+ /* } */
+ }
+ #endif
+@@ -553,7 +554,7 @@ int main(int argc, char **argv)
+ for (c = 0; c <= 0x10ffffUL; c++)
+ #endif
+ {
+- unsigned int glibc;
++ unsigned int curr_stdclib;
+ unsigned int mine;
+ unsigned int upper, lower;
+
+@@ -568,19 +569,19 @@ int main(int argc, char **argv)
+ }
+ #endif
+ #endif
+- glibc = 0;
+- if (iswalnum(c)) ++glibc; glibc <<= 1;
+- if (iswalpha(c)) ++glibc; glibc <<= 1;
+- if (iswblank(c)) ++glibc; glibc <<= 1;
+- if (iswcntrl(c)) ++glibc; glibc <<= 1;
+- if (iswdigit(c)) ++glibc; glibc <<= 1;
+- if (iswgraph(c)) ++glibc; glibc <<= 1;
+- if (iswlower(c)) ++glibc; glibc <<= 1;
+- if (iswprint(c)) ++glibc; glibc <<= 1;
+- if (iswpunct(c)) ++glibc; glibc <<= 1;
+- if (iswspace(c)) ++glibc; glibc <<= 1;
+- if (iswupper(c)) ++glibc; glibc <<= 1;
+- if (iswxdigit(c)) ++glibc;
++ curr_stdclib = 0;
++ if (iswalnum(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswalpha(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswblank(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswcntrl(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswdigit(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswgraph(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswlower(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswprint(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswpunct(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswspace(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswupper(c)) ++curr_stdclib; curr_stdclib <<= 1;
++ if (iswxdigit(c)) ++curr_stdclib;
+
+ {
+ unsigned int u;
+@@ -630,8 +631,8 @@ int main(int argc, char **argv)
+ if (mywupper(d,c)) ++mine; mine <<= 1;
+ if (mywxdigit(d,c)) ++mine;
+
+- if (glibc != mine) {
+- verbose_msg("%#8x : glibc %#4x != %#4x mine %d\n", c, glibc, mine, d);
++ if (curr_stdclib != mine) {
++ verbose_msg("%#8x : curr_stdclib %#4x != %#4x mine %d\n", c, curr_stdclib, mine, d);
+ if (c < 0x30000UL) {
+ verbose_msg("sc=%#x u=%#x n=%#x i0=%#x i1=%#x\n", sc, u, n, i0, i1);
+ }
+@@ -655,17 +656,17 @@ int main(int argc, char **argv)
+ }
+
+ if (towupper(c) != upper) {
+- verbose_msg("%#8x : towupper glibc %#4x != %#4x mine\n",
++ verbose_msg("%#8x : towupper curr_stdclib %#4x != %#4x mine\n",
+ c, towupper(c), upper);
+ }
+
+ if (towlower(c) != lower) {
+- verbose_msg("%#8x : towlower glibc %#4x != %#4x mine i0 = %d\n",
++ verbose_msg("%#8x : towlower curr_stdclib %#4x != %#4x mine i0 = %d\n",
+ c, towlower(c), lower, i0);
+ }
+
+ if (totitle && ((tt = towctrans(c, totitle)) != upper)) {
+- verbose_msg("%#8x : totitle glibc %#4lx != %#4x mine i0 = %d\n",
++ verbose_msg("%#8x : totitle curr_stdclib %#4lx != %#4x mine i0 = %d\n",
+ c, tt, upper, i0);
+ }
+ }
diff --git a/toolchain/uClibc/patches-0.9.33.2/995-add-sigsys-to-siginfo_t-union.patch b/toolchain/uClibc/patches-0.9.33.2/995-add-sigsys-to-siginfo_t-union.patch
new file mode 100644
index 0000000..4894a56
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/995-add-sigsys-to-siginfo_t-union.patch
@@ -0,0 +1,145 @@
+Index: uClibc/libc/sysdeps/linux/common/bits/siginfo.h
+===================================================================
+--- uClibc.orig/libc/sysdeps/linux/common/bits/siginfo.h
++++ uClibc/libc/sysdeps/linux/common/bits/siginfo.h
+@@ -104,6 +104,14 @@ typedef struct siginfo
+ long int si_band; /* Band event for SIGPOLL. */
+ int si_fd;
+ } _sigpoll;
++
++ /* SIGSYS. */
++ struct
++ {
++ void *_call_addr; /* Calling user insn. */
++ int _syscall; /* Triggering system call number. */
++ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */
++ } _sigsys;
+ } _sifields;
+ } siginfo_t;
+
+@@ -122,6 +130,9 @@ typedef struct siginfo
+ # define si_addr _sifields._sigfault.si_addr
+ # define si_band _sifields._sigpoll.si_band
+ # define si_fd _sifields._sigpoll.si_fd
++# define si_call_addr _sifields._sigsys._call_addr
++# define si_syscall _sifields._sigsys._syscall
++# define si_arch _sifields._sigsys._arch
+
+
+ /* Values for `si_code'. Positive values are reserved for kernel-generated
+Index: uClibc/libc/sysdeps/linux/alpha/bits/siginfo.h
+===================================================================
+--- uClibc.orig/libc/sysdeps/linux/alpha/bits/siginfo.h
++++ uClibc/libc/sysdeps/linux/alpha/bits/siginfo.h
+@@ -98,6 +98,14 @@ typedef struct siginfo
+ int si_band; /* Band event for SIGPOLL. */
+ int si_fd;
+ } _sigpoll;
++
++ /* SIGSYS. */
++ struct
++ {
++ void *_call_addr; /* Calling user insn. */
++ int _syscall; /* Triggering system call number. */
++ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */
++ } _sigsys;
+ } _sifields;
+ } siginfo_t;
+
+@@ -116,6 +124,9 @@ typedef struct siginfo
+ # define si_addr _sifields._sigfault.si_addr
+ # define si_band _sifields._sigpoll.si_band
+ # define si_fd _sifields._sigpoll.si_fd
++# define si_call_addr _sifields._sigsys._call_addr
++# define si_syscall _sifields._sigsys._syscall
++# define si_arch _sifields._sigsys._arch
+
+
+ /* Values for `si_code'. Positive values are reserved for kernel-generated
+Index: uClibc/libc/sysdeps/linux/ia64/bits/siginfo.h
+===================================================================
+--- uClibc.orig/libc/sysdeps/linux/ia64/bits/siginfo.h
++++ uClibc/libc/sysdeps/linux/ia64/bits/siginfo.h
+@@ -103,6 +103,14 @@ typedef struct siginfo
+ long int si_band; /* Band event for SIGPOLL. */
+ int si_fd;
+ } _sigpoll;
++
++ /* SIGSYS. */
++ struct
++ {
++ void *_call_addr; /* Calling user insn. */
++ int _syscall; /* Triggering system call number. */
++ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */
++ } _sigsys;
+ } _sifields;
+ } siginfo_t;
+
+@@ -121,6 +129,9 @@ typedef struct siginfo
+ # define si_addr _sifields._sigfault.si_addr
+ # define si_band _sifields._sigpoll.si_band
+ # define si_fd _sifields._sigpoll.si_fd
++# define si_call_addr _sifields._sigsys._call_addr
++# define si_syscall _sifields._sigsys._syscall
++# define si_arch _sifields._sigsys._arch
+
+ # ifdef __USE_GNU
+ # define si_imm _sifields._sigfault._si_imm
+Index: uClibc/libc/sysdeps/linux/mips/bits/siginfo.h
+===================================================================
+--- uClibc.orig/libc/sysdeps/linux/mips/bits/siginfo.h
++++ uClibc/libc/sysdeps/linux/mips/bits/siginfo.h
+@@ -107,6 +107,14 @@ typedef struct siginfo
+ __uid_t si_uid; /* Real user ID of sending process. */
+ sigval_t si_sigval; /* Signal value. */
+ } _rt;
++
++ /* SIGSYS. */
++ struct
++ {
++ void *_call_addr; /* Calling user insn. */
++ int _syscall; /* Triggering system call number. */
++ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */
++ } _sigsys;
+ } _sifields;
+ } siginfo_t;
+
+@@ -123,6 +131,9 @@ typedef struct siginfo
+ # define si_addr _sifields._sigfault.si_addr
+ # define si_band _sifields._sigpoll.si_band
+ # define si_fd _sifields._sigpoll.si_fd
++# define si_call_addr _sifields._sigsys._call_addr
++# define si_syscall _sifields._sigsys._syscall
++# define si_arch _sifields._sigsys._arch
+
+
+ /* Values for `si_code'. Positive values are reserved for kernel-generated
+Index: uClibc/libc/sysdeps/linux/sparc/bits/siginfo.h
+===================================================================
+--- uClibc.orig/libc/sysdeps/linux/sparc/bits/siginfo.h
++++ uClibc/libc/sysdeps/linux/sparc/bits/siginfo.h
+@@ -105,6 +105,14 @@ typedef struct siginfo
+ int si_band; /* Band event for SIGPOLL. */
+ int si_fd;
+ } _sigpoll;
++
++ /* SIGSYS. */
++ struct
++ {
++ void *_call_addr; /* Calling user insn. */
++ int _syscall; /* Triggering system call number. */
++ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */
++ } _sigsys;
+ } _sifields;
+ } siginfo_t;
+
+@@ -124,6 +132,9 @@ typedef struct siginfo
+ # define si_trapno _sifields._sigfault.si_trapno
+ # define si_band _sifields._sigpoll.si_band
+ # define si_fd _sifields._sigpoll.si_fd
++# define si_call_addr _sifields._sigsys._call_addr
++# define si_syscall _sifields._sigsys._syscall
++# define si_arch _sifields._sigsys._arch
+
+
+ /* Values for `si_code'. Positive values are reserved for kernel-generated
diff --git a/toolchain/uClibc/patches-0.9.33.2/999-eventfd_use_bits_scheme.patch b/toolchain/uClibc/patches-0.9.33.2/999-eventfd_use_bits_scheme.patch
new file mode 100644
index 0000000..0551290
--- /dev/null
+++ b/toolchain/uClibc/patches-0.9.33.2/999-eventfd_use_bits_scheme.patch
@@ -0,0 +1,248 @@
+From fd355bc1dbcb794ae1abf0fad1459e28d8567ba0 Mon Sep 17 00:00:00 2001
+From: Hiroaki KAWAI <kawai@stratosphere.co.jp>
+Date: Fri, 19 Apr 2013 01:09:35 +0000
+Subject: eventfd.h: Use new "bits/" scheme for arch-specific flags
+
+As in timerfd.h, eventfd.h needs arch-specific definition files.
+alpha, mips and sparc needs separate file, all the other arch
+will use common definition.
+
+This problem is already fixed in glibc.
+
+Also sanitize and provide bits for hppa.
+Make sure not to install the new bits/eventfd unless eventfd support is
+enabled.
+
+Signed-off-by: Hiroaki KAWAI <kawai@stratosphere.co.jp>
+Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
+---
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -272,6 +272,7 @@ HEADERS_RM-$(UCLIBC_HAS_XATTR)
+ HEADERS_RM-$(UCLIBC_HAS_XLOCALE) += xlocale.h
+ HEADERS_RM-$(UCLIBC_LINUX_SPECIFIC) += sys/eventfd.h sys/fsuid.h \
+ bits/inotify.h \
++ bits/eventfd.h \
+ sys/inotify.h \
+ sys/kdaemon.h \
+ sys/perm.h \
+--- /dev/null
++++ b/libc/sysdeps/linux/alpha/bits/eventfd.h
+@@ -0,0 +1,31 @@
++/* Copyright (C) 2007-2013 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
++
++#ifndef _SYS_EVENTFD_H
++# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
++#endif
++
++/* Flags for eventfd. */
++enum
++ {
++ EFD_SEMAPHORE = 000000001,
++#define EFD_SEMAPHORE EFD_SEMAPHORE
++ EFD_CLOEXEC = 010000000,
++#define EFD_CLOEXEC EFD_CLOEXEC
++ EFD_NONBLOCK = 000000004
++#define EFD_NONBLOCK EFD_NONBLOCK
++ };
+--- /dev/null
++++ b/libc/sysdeps/linux/common/bits/eventfd.h
+@@ -0,0 +1,31 @@
++/* Copyright (C) 2007-2013 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
++
++#ifndef _SYS_EVENTFD_H
++# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
++#endif
++
++/* Flags for eventfd. */
++enum
++ {
++ EFD_SEMAPHORE = 00000001,
++#define EFD_SEMAPHORE EFD_SEMAPHORE
++ EFD_CLOEXEC = 02000000,
++#define EFD_CLOEXEC EFD_CLOEXEC
++ EFD_NONBLOCK = 00004000
++#define EFD_NONBLOCK EFD_NONBLOCK
++ };
+--- a/libc/sysdeps/linux/common/sys/eventfd.h
++++ b/libc/sysdeps/linux/common/sys/eventfd.h
+@@ -1,4 +1,4 @@
+-/* Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
++/* Copyright (C) 2007-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+@@ -21,21 +21,12 @@
+
+ #include <stdint.h>
+
++/* Get the platform-dependent flags. */
++#include <bits/eventfd.h>
+
+ /* Type for event counter. */
+ typedef uint64_t eventfd_t;
+
+-/* Flags for signalfd. */
+-enum
+- {
+- EFD_SEMAPHORE = 1,
+-#define EFD_SEMAPHORE EFD_SEMAPHORE
+- EFD_CLOEXEC = 02000000,
+-#define EFD_CLOEXEC EFD_CLOEXEC
+- EFD_NONBLOCK = 04000
+-#define EFD_NONBLOCK EFD_NONBLOCK
+- };
+-
+
+ __BEGIN_DECLS
+
+@@ -43,6 +34,16 @@ __BEGIN_DECLS
+ value to COUNT. */
+ extern int eventfd (int __count, int __flags) __THROW;
+
++#if 0 /* not (yet) implemented in uClibc */
++
++/* Read event counter and possibly wait for events. */
++extern int eventfd_read (int __fd, eventfd_t *__value);
++
++/* Increment event counter. */
++extern int eventfd_write (int __fd, eventfd_t __value);
++
++#endif
++
+ __END_DECLS
+
+ #endif /* sys/eventfd.h */
+--- /dev/null
++++ b/libc/sysdeps/linux/hppa/bits/eventfd.h
+@@ -0,0 +1,32 @@
++/* Copyright (C) 2007-2013 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library. If not, see
++ <http://www.gnu.org/licenses/>. */
++
++#ifndef _SYS_EVENTFD_H
++# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
++#endif
++
++/* Flags for signalfd. */
++enum
++ {
++ EFD_SEMAPHORE = 000000001,
++#define EFD_SEMAPHORE EFD_SEMAPHORE
++ EFD_CLOEXEC = 010000000,
++#define EFD_CLOEXEC EFD_CLOEXEC
++/* the below value looks suspicious, should be 000200004 for consistency */
++ EFD_NONBLOCK = 00200004 /* HPUX has separate NDELAY & NONBLOCK */
++#define EFD_NONBLOCK EFD_NONBLOCK
++ };
+--- /dev/null
++++ b/libc/sysdeps/linux/mips/bits/eventfd.h
+@@ -0,0 +1,31 @@
++/* Copyright (C) 2007-2013 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
++
++#ifndef _SYS_EVENTFD_H
++# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
++#endif
++
++/* Flags for eventfd. */
++enum
++ {
++ EFD_SEMAPHORE = 00000001,
++#define EFD_SEMAPHORE EFD_SEMAPHORE
++ EFD_CLOEXEC = 02000000,
++#define EFD_CLOEXEC EFD_CLOEXEC
++ EFD_NONBLOCK = 00000200
++#define EFD_NONBLOCK EFD_NONBLOCK
++ };
+--- /dev/null
++++ b/libc/sysdeps/linux/sparc/bits/eventfd.h
+@@ -0,0 +1,31 @@
++/* Copyright (C) 2007-2013 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
++
++#ifndef _SYS_EVENTFD_H
++# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
++#endif
++
++/* Flags for eventfd. */
++enum
++ {
++ EFD_SEMAPHORE = 1,
++#define EFD_SEMAPHORE EFD_SEMAPHORE
++ EFD_CLOEXEC = 0x400000,
++#define EFD_CLOEXEC EFD_CLOEXEC
++ EFD_NONBLOCK = 0x004000
++#define EFD_NONBLOCK EFD_NONBLOCK
++ };
diff --git a/toolchain/uClibc/utils/Makefile b/toolchain/uClibc/utils/Makefile
new file mode 100644
index 0000000..83100d7
--- /dev/null
+++ b/toolchain/uClibc/utils/Makefile
@@ -0,0 +1,24 @@
+PATH_PREFIX=..
+
+include ../common.mk
+
+HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.utils_built
+HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc_utils_installed
+
+define Host/Compile
+ $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(HOST_BUILD_DIR)/Rules.mak
+ $(UCLIBC_MAKE) PREFIX= utils
+endef
+
+define Host/Install
+ $(INSTALL_DIR) $(TOOLCHAIN_DIR)/bin
+ $(INSTALL_BIN) \
+ $(HOST_BUILD_DIR)/utils/ldd \
+ $(TOOLCHAIN_DIR)/bin/
+ $(INSTALL_DIR) $(TOOLCHAIN_DIR)/sbin
+ $(INSTALL_BIN) \
+ $(HOST_BUILD_DIR)/utils/ldconfig \
+ $(TOOLCHAIN_DIR)/sbin/
+endef
+
+$(eval $(call HostBuild))
diff --git a/toolchain/wrapper/Makefile b/toolchain/wrapper/Makefile
new file mode 100644
index 0000000..3398e40
--- /dev/null
+++ b/toolchain/wrapper/Makefile
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2012 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=wrapper
+PKG_VERSION:=1
+
+include $(INCLUDE_DIR)/toolchain-build.mk
+
+
+# 1: args
+define toolchain_util
+$(strip $(SCRIPT_DIR)/ext-toolchain.sh --toolchain $(CONFIG_TOOLCHAIN_ROOT) \
+ --cflags $(CONFIG_TARGET_OPTIMIZATION) \
+ --cflags "$(if $(call qstrip,$(CONFIG_TOOLCHAIN_LIBC)),-m$(call qstrip,$(CONFIG_TOOLCHAIN_LIBC))) $(if $(CONFIG_SOFT_FLOAT),-msoft-float)" \
+ --cflags "$(patsubst ./%,-I$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_INC_PATH)))" \
+ --cflags "$(patsubst ./%,-L$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_LIB_PATH)))" \
+ $(1))
+endef
+
+# 1: config symbol
+# 2: feature
+define toolchain_test
+$$(if $$($(1)), \
+ @echo -n "Testing external toolchain for $(2) support ... "; \
+ if $(call toolchain_util,--test "$(2)"); then \
+ echo "ok"; exit 0; \
+ else \
+ echo "failed"; \
+ echo "ERROR: $(1) is enabled but the external toolchain does not support it"; \
+ exit 1; \
+ fi)
+endef
+
+
+define Host/Prepare
+ $(call toolchain_test,CONFIG_SOFT_FLOAT,softfloat)
+ $(call toolchain_test,CONFIG_IPV6,ipv6)
+ $(call toolchain_test,CONFIG_NLS,wchar)
+ $(call toolchain_test,CONFIG_PACKAGE_libpthread,threads)
+endef
+
+define Host/Configure
+endef
+
+define Host/Compile
+endef
+
+define Host/Install
+ $(call toolchain_util,--wrap "$(TOOLCHAIN_DIR)/bin")
+endef
+
+define Host/Clean
+ rm -rf $(TOOLCHAIN_DIR)/bin
+endef
+
+$(eval $(call HostBuild))