summaryrefslogtreecommitdiff
path: root/patches/gcc/linaro-4.9-2017.01
diff options
context:
space:
mode:
Diffstat (limited to 'patches/gcc/linaro-4.9-2017.01')
-rw-r--r--patches/gcc/linaro-4.9-2017.01/001-gcc_bug_62231.patch129
-rw-r--r--patches/gcc/linaro-4.9-2017.01/002-gcc_bug_62231.patch18
-rw-r--r--patches/gcc/linaro-4.9-2017.01/100-uclibc-conf.patch15
-rw-r--r--patches/gcc/linaro-4.9-2017.01/1000-libtool-leave-framework-alone.patch14
-rw-r--r--patches/gcc/linaro-4.9-2017.01/1000-powerpc-link-with-math-lib.patch.conditional122
-rw-r--r--patches/gcc/linaro-4.9-2017.01/111-pr65730.patch34
-rw-r--r--patches/gcc/linaro-4.9-2017.01/120-gcc-config.gcc-fix-typo-for-powerpc-e6500-cpu_is_64b.patch26
-rw-r--r--patches/gcc/linaro-4.9-2017.01/130-pr43538.patch25
-rw-r--r--patches/gcc/linaro-4.9-2017.01/131-mt-ospace-preserve-FLAGS_FOR_TARGET.patch28
-rw-r--r--patches/gcc/linaro-4.9-2017.01/140-sanitizer-Fix-build-with-_FILE_OFFSET_BITS-64.patch37
-rw-r--r--patches/gcc/linaro-4.9-2017.01/301-missing-execinfo_h.patch13
-rw-r--r--patches/gcc/linaro-4.9-2017.01/370-gcc-plugin-Win-Dont-need-undefined-extern-var-refs-nor-fpic.patch104
-rw-r--r--patches/gcc/linaro-4.9-2017.01/810-arm-softfloat-libgcc.patch30
-rw-r--r--patches/gcc/linaro-4.9-2017.01/830-arm_unbreak_armv4t.patch13
-rw-r--r--patches/gcc/linaro-4.9-2017.01/840-microblaze-enable-dwarf-eh-support.patch166
-rw-r--r--patches/gcc/linaro-4.9-2017.01/850-libstdcxx-uclibc-c99.patch274
-rw-r--r--patches/gcc/linaro-4.9-2017.01/860-cilk-wchar.patch56
-rw-r--r--patches/gcc/linaro-4.9-2017.01/870-xtensa-add-mauto-litpools-option.patch287
-rw-r--r--patches/gcc/linaro-4.9-2017.01/871-xtensa-reimplement-register-spilling.patch76
-rw-r--r--patches/gcc/linaro-4.9-2017.01/872-xtensa-use-unwind-dw2-fde-dip-instead-of-unwind-dw2-.patch33
-rw-r--r--patches/gcc/linaro-4.9-2017.01/873-xtensa-fix-_Unwind_GetCFA.patch40
-rw-r--r--patches/gcc/linaro-4.9-2017.01/874-xtensa-add-uclinux-support.patch169
-rw-r--r--patches/gcc/linaro-4.9-2017.01/880-nios2_legitimize_address.patch49
-rw-r--r--patches/gcc/linaro-4.9-2017.01/890-fix-m68k-compile.patch15
-rw-r--r--patches/gcc/linaro-4.9-2017.01/891-fix-m68k-uclinux.patch18
-rw-r--r--patches/gcc/linaro-4.9-2017.01/930-libgcc-disable-split-stack-nothreads.patch14
-rw-r--r--patches/gcc/linaro-4.9-2017.01/940-uclinux-enable-threads.patch20
27 files changed, 1825 insertions, 0 deletions
diff --git a/patches/gcc/linaro-4.9-2017.01/001-gcc_bug_62231.patch b/patches/gcc/linaro-4.9-2017.01/001-gcc_bug_62231.patch
new file mode 100644
index 0000000..e7c9cf9
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/001-gcc_bug_62231.patch
@@ -0,0 +1,129 @@
+As-applied. From:
+
+https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02625.html
+
+Linked from bug62231 comment 4 there
+
+diff -durN a/gcc/defaults.h b/gcc/defaults.h
+--- a/gcc/defaults.h 2013-01-10 12:38:27.000000000 -0800
++++ b/gcc/defaults.h 2014-12-15 13:26:13.498904465 -0800
+@@ -438,6 +438,11 @@
+ #define DWARF_FRAME_REGNUM(REG) DBX_REGISTER_NUMBER (REG)
+ #endif
+
++/* The mapping from dwarf CFA reg number to internal dwarf reg numbers. */
++#ifndef DWARF_REG_TO_UNWIND_COLUMN
++#define DWARF_REG_TO_UNWIND_COLUMN(REGNO) (REGNO)
++#endif
++
+ /* Map register numbers held in the call frame info that gcc has
+ collected using DWARF_FRAME_REGNUM to those that should be output in
+ .debug_frame and .eh_frame. */
+diff -durN a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c
+--- a/gcc/dwarf2cfi.c 2013-01-10 12:38:27.000000000 -0800
++++ b/gcc/dwarf2cfi.c 2014-12-15 13:50:24.554883694 -0800
+@@ -225,7 +225,44 @@
+ emit_move_insn (adjust_address (mem, mode, offset), GEN_INT (size));
+ }
+
+-/* Generate code to initialize the register size table. */
++/* Helper for expand_builtin_init_dwarf_reg_sizes. Generate code to
++ initialize the dwarf register size table entry corresponding to register
++ REGNO in REGMODE. TABLE is the table base address, SLOTMODE is the mode
++ to use for the size entry to initialize, and WROTE_RETURN_COLUMN needs to
++ be set to true if the dwarf register number for REGNO is the dwarf return
++ column number. */
++
++static
++void init_one_dwarf_reg_size (int regno, enum machine_mode regmode,
++ rtx table, enum machine_mode slotmode,
++ bool *wrote_return_column)
++{
++ const unsigned int dnum = DWARF_FRAME_REGNUM (regno);
++ const unsigned int rnum = DWARF2_FRAME_REG_OUT (dnum, 1);
++ const unsigned int dcol = DWARF_REG_TO_UNWIND_COLUMN (rnum);
++
++ const HOST_WIDE_INT slotoffset = dcol * GET_MODE_SIZE (slotmode);
++ const HOST_WIDE_INT regsize = GET_MODE_SIZE (regmode);
++
++ if (rnum >= DWARF_FRAME_REGISTERS)
++ return;
++
++ if (dnum == DWARF_FRAME_RETURN_COLUMN)
++ {
++ if (regmode == VOIDmode)
++ return;
++ *wrote_return_column = true;
++ }
++
++ if (slotoffset < 0)
++ return;
++
++ emit_move_insn (adjust_address (table, slotmode, slotoffset),
++ gen_int_mode (regsize, slotmode));
++}
++
++/* Generate code to initialize the dwarf register size table located
++ at the provided ADDRESS. */
+
+ void
+ expand_builtin_init_dwarf_reg_sizes (tree address)
+@@ -238,30 +275,21 @@
+
+ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+ {
+- unsigned int dnum = DWARF_FRAME_REGNUM (i);
+- unsigned int rnum = DWARF2_FRAME_REG_OUT (dnum, 1);
+-
+- if (rnum < DWARF_FRAME_REGISTERS)
+- {
+- HOST_WIDE_INT offset = rnum * GET_MODE_SIZE (mode);
+- enum machine_mode save_mode = reg_raw_mode[i];
+- HOST_WIDE_INT size;
+-
+- if (HARD_REGNO_CALL_PART_CLOBBERED (i, save_mode))
+- save_mode = choose_hard_reg_mode (i, 1, true);
+- if (dnum == DWARF_FRAME_RETURN_COLUMN)
+- {
+- if (save_mode == VOIDmode)
+- continue;
+- wrote_return_column = true;
+- }
+- size = GET_MODE_SIZE (save_mode);
+- if (offset < 0)
+- continue;
++ enum machine_mode save_mode = reg_raw_mode[i];
++ rtx span;
+
+- emit_move_insn (adjust_address (mem, mode, offset),
+- gen_int_mode (size, mode));
+- }
++ span = targetm.dwarf_register_span (gen_rtx_REG (save_mode, i));
++ if (!span)
++ init_one_dwarf_reg_size (i, save_mode, mem, mode, &wrote_return_column);
++ else
++ {
++ for (int si = 0; si < XVECLEN (span, 0); si++)
++ {
++ rtx reg = XVECEXP (span, 0, si);
++ init_one_dwarf_reg_size
++ (REGNO (reg), GET_MODE (reg), mem, mode, &wrote_return_column);
++ }
++ }
+ }
+
+ if (!wrote_return_column)
+diff -durN a/libgcc/unwind-dw2.c b/libgcc/unwind-dw2.c
+--- a/libgcc/unwind-dw2.c 2013-05-31 16:21:46.000000000 -0700
++++ b/libgcc/unwind-dw2.c 2014-12-15 13:26:13.570904866 -0800
+@@ -55,10 +55,6 @@
+ #define PRE_GCC3_DWARF_FRAME_REGISTERS DWARF_FRAME_REGISTERS
+ #endif
+
+-#ifndef DWARF_REG_TO_UNWIND_COLUMN
+-#define DWARF_REG_TO_UNWIND_COLUMN(REGNO) (REGNO)
+-#endif
+-
+ /* ??? For the public function interfaces, we tend to gcc_assert that the
+ column numbers are in range. For the dwarf2 unwind info this does happen,
+ although so far in a case that doesn't actually matter.
diff --git a/patches/gcc/linaro-4.9-2017.01/002-gcc_bug_62231.patch b/patches/gcc/linaro-4.9-2017.01/002-gcc_bug_62231.patch
new file mode 100644
index 0000000..b970ebc
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/002-gcc_bug_62231.patch
@@ -0,0 +1,18 @@
+As-applied. From:
+
+https://gcc.gnu.org/ml/gcc-patches/2014-10/msg02605.html
+
+Linked from bug62231 comment 4 there
+
+diff -durN a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
+--- a/gcc/config/rs6000/rs6000.c 2014-12-08 17:29:04.000000000 -0800
++++ b/gcc/config/rs6000/rs6000.c 2014-12-15 14:44:46.568801843 -0800
+@@ -1673,7 +1673,7 @@
+ SCmode so as to pass the value correctly in a pair of
+ registers. */
+ else if (TARGET_E500_DOUBLE && FLOAT_MODE_P (mode) && mode != SCmode
+- && !DECIMAL_FLOAT_MODE_P (mode))
++ && !DECIMAL_FLOAT_MODE_P (mode) && SPE_SIMD_REGNO_P (regno))
+ reg_size = UNITS_PER_FP_WORD;
+
+ else
diff --git a/patches/gcc/linaro-4.9-2017.01/100-uclibc-conf.patch b/patches/gcc/linaro-4.9-2017.01/100-uclibc-conf.patch
new file mode 100644
index 0000000..d56bf0a
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/100-uclibc-conf.patch
@@ -0,0 +1,15 @@
+Index: gcc-4.8.0/contrib/regression/objs-gcc.sh
+===================================================================
+--- gcc-4.8.0.orig/contrib/regression/objs-gcc.sh 2009-04-09 17:00:19.000000000 +0200
++++ gcc-4.8.0/contrib/regression/objs-gcc.sh 2013-03-23 17:39:04.000000000 +0100
+@@ -106,6 +106,10 @@
+ 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
diff --git a/patches/gcc/linaro-4.9-2017.01/1000-libtool-leave-framework-alone.patch b/patches/gcc/linaro-4.9-2017.01/1000-libtool-leave-framework-alone.patch
new file mode 100644
index 0000000..525592e
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/1000-libtool-leave-framework-alone.patch
@@ -0,0 +1,14 @@
+--- gcc-4.9.4/libtool-ldflags 2016-12-20 11:13:12.669668125 -0800
++++ gcc-4.9.4/libtool-ldflags 2016-12-20 11:28:34.894826286 -0800
+@@ -36,6 +36,11 @@
+ for arg
+ do
+ case $arg in
++ -framework)
++ # libtool handles this option. It should not be prefixed with
++ # -Xcompiler, as that would split it from the argument that
++ # follows.
++ ;;
+ -f*|--*)
+ # Libtool does not ascribe any special meaning options
+ # that begin with -f or with a double-dash. So, it will
diff --git a/patches/gcc/linaro-4.9-2017.01/1000-powerpc-link-with-math-lib.patch.conditional b/patches/gcc/linaro-4.9-2017.01/1000-powerpc-link-with-math-lib.patch.conditional
new file mode 100644
index 0000000..5e0484f
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/1000-powerpc-link-with-math-lib.patch.conditional
@@ -0,0 +1,122 @@
+http://gcc.gnu.org/ml/gcc-patches/2008-10/msg00269.html
+
+On glibc the libc.so carries a copy of the math function copysignl() but
+on uClibc math functions like copysignl() live in libm. Since libgcc_s
+contains unresolved symbols, any attempt to link against libgcc_s
+without explicitely specifying -lm fails, resulting in a broken
+bootstrap of the compiler.
+
+Forward port to gcc 4.5.1 by Gustavo Zacarias <gustavo@zacarias.com.ar>
+
+---
+ libgcc/Makefile.in | 4 +++-
+ libgcc/configure | 32 ++++++++++++++++++++++++++++++++
+ libgcc/configure.ac | 21 +++++++++++++++++++++
+ 3 files changed, 56 insertions(+), 1 deletion(-)
+
+Index: b/libgcc/Makefile.in
+===================================================================
+--- a/libgcc/Makefile.in
++++ b/libgcc/Makefile.in
+@@ -42,6 +42,7 @@
+ enable_vtable_verify = @enable_vtable_verify@
+ enable_decimal_float = @enable_decimal_float@
+ fixed_point = @fixed_point@
++LIBGCC_LIBM = @LIBGCC_LIBM@
+
+ host_noncanonical = @host_noncanonical@
+ target_noncanonical = @target_noncanonical@
+@@ -943,9 +944,10 @@
+ @multilib_dir@,$(MULTIDIR),$(subst \
+ @shlib_objs@,$(objects) libgcc.a,$(subst \
+ @shlib_base_name@,libgcc_s,$(subst \
++ @libgcc_libm@,$(LIBGCC_LIBM),$(subst \
+ @shlib_map_file@,$(mapfile),$(subst \
+ @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(subst \
+- @shlib_slibdir@,$(shlib_slibdir),$(SHLIB_LINK))))))))
++ @shlib_slibdir@,$(shlib_slibdir),$(SHLIB_LINK)))))))))
+
+ libunwind$(SHLIB_EXT): $(libunwind-s-objects) $(extra-parts)
+ # @multilib_flags@ is still needed because this may use
+Index: b/libgcc/configure
+===================================================================
+--- a/libgcc/configure
++++ b/libgcc/configure
+@@ -564,6 +564,7 @@
+ tmake_file
+ sfp_machine_header
+ set_use_emutls
++LIBGCC_LIBM
+ set_have_cc_tls
+ vis_hide
+ fixed_point
+@@ -4535,6 +4536,37 @@
+ fi
+ fi
+
++# On powerpc libgcc_s references copysignl which is a libm function but
++# glibc apparently also provides it via libc as opposed to uClibc where
++# it lives in libm.
++echo "$as_me:$LINENO: checking for library containing copysignl" >&5
++echo $ECHO_N "checking for library containing copysignl... $ECHO_C" >&6
++if test "${libgcc_cv_copysignl_lib+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++
++ echo '#include <features.h>' > conftest.c
++ echo 'int the_libc = __UCLIBC__ + __powerpc__;' >> conftest.c
++ libgcc_cv_copysignl_lib="-lc"
++ if { ac_try='${CC-cc} -S conftest.c -o conftest.s 1>&5'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }
++ then
++ libgcc_cv_copysignl_lib="-lm"
++ fi
++ rm -f conftest.*
++
++fi
++echo "$as_me:$LINENO: result: $libgcc_cv_copysignl_lib" >&5
++echo "${ECHO_T}$libgcc_cv_copysignl_lib" >&6
++
++case /${libgcc_cv_copysignl_lib}/ in
++ /-lm/) LIBGCC_LIBM="$LIBGCC_LIBM -lm" ;;
++ *) LIBGCC_LIBM= ;;
++esac
+
+ # Conditionalize the makefile for this target machine.
+ tmake_file_=
+Index: b/libgcc/configure.ac
+===================================================================
+--- a/libgcc/configure.ac
++++ b/libgcc/configure.ac
+@@ -357,6 +357,27 @@
+ fi
+ AC_SUBST(set_have_cc_tls)
+
++# On powerpc libgcc_s references copysignl which is a libm function but
++# glibc apparently also provides it via libc as opposed to uClibc where
++# it lives in libm.
++AC_CACHE_CHECK
++ libgcc_cv_copysignl_lib,
++ echo '#include <features.h>' > conftest.c
++ echo 'int the_libc = __UCLIBC__ + __powerpc__;' >> conftest.c
++ libgcc_cv_copysignl_lib="-lc"
++ if AC_TRY_COMMAND(${CC-cc} -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD)
++ then
++ libgcc_cv_copysignl_lib="-lm"
++ fi
++ rm -f conftest.*
++ ])
++
++case /${libgcc_cv_copysignl_lib}/ in
++ /-lm/) LIBGCC_LIBM="$LIBGCC_LIBM -lm" ;;
++ *) LIBGCC_LIBM= ;;
++esac
++AC_SUBST(LIBGCC_LIBM)
++
+ # See if we have emulated thread-local storage.
+ GCC_CHECK_EMUTLS
+ set_use_emutls=
diff --git a/patches/gcc/linaro-4.9-2017.01/111-pr65730.patch b/patches/gcc/linaro-4.9-2017.01/111-pr65730.patch
new file mode 100644
index 0000000..8a41fd2
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/111-pr65730.patch
@@ -0,0 +1,34 @@
+From b9a7775674d91c7af8043a83211ffeaa576327d7 Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Fri, 10 Apr 2015 17:46:30 +0300
+Subject: [PATCH] Fix PR target/65730
+
+2015-05-20 Max Filippov <jcmvbkbc@gmail.com>
+gcc/
+ * config/xtensa/xtensa.c (init_alignment_context): Replace MULT
+ by BITS_PER_UNIT with ASHIFT by exact_log2 (BITS_PER_UNIT).
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223452
+Changes to ChangeLog are dropped.
+
+ gcc/config/xtensa/xtensa.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+Index: b/gcc/config/xtensa/xtensa.c
+===================================================================
+--- a/gcc/config/xtensa/xtensa.c
++++ b/gcc/config/xtensa/xtensa.c
+@@ -1436,8 +1436,9 @@
+ if (ac->shift != NULL_RTX)
+ {
+ /* Shift is the byte count, but we need the bitcount. */
+- ac->shift = expand_simple_binop (SImode, MULT, ac->shift,
+- GEN_INT (BITS_PER_UNIT),
++ gcc_assert (exact_log2 (BITS_PER_UNIT) >= 0);
++ ac->shift = expand_simple_binop (SImode, ASHIFT, ac->shift,
++ GEN_INT (exact_log2 (BITS_PER_UNIT)),
+ NULL_RTX, 1, OPTAB_DIRECT);
+ ac->modemask = expand_simple_binop (SImode, ASHIFT,
+ GEN_INT (GET_MODE_MASK (mode)),
diff --git a/patches/gcc/linaro-4.9-2017.01/120-gcc-config.gcc-fix-typo-for-powerpc-e6500-cpu_is_64b.patch b/patches/gcc/linaro-4.9-2017.01/120-gcc-config.gcc-fix-typo-for-powerpc-e6500-cpu_is_64b.patch
new file mode 100644
index 0000000..bb77c4b
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/120-gcc-config.gcc-fix-typo-for-powerpc-e6500-cpu_is_64b.patch
@@ -0,0 +1,26 @@
+From 9bf6066d588632dab9f78932df15b5b4140f31f3 Mon Sep 17 00:00:00 2001
+From: "Arnout Vandecappelle (Essensium/Mind)" <arnout@mind.be>
+Date: Fri, 6 Nov 2015 14:27:23 +0100
+Subject: [PATCH] gcc/config.gcc: fix typo for powerpc e6500 cpu_is_64bit
+
+Otherwise it is not recognized as a 64-bit powerpc and gcc will not generate
+64-bit binaries by default.
+
+Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
+---
+ gcc/config.gcc | 2 +-
+ 2 files changed, 4 insertions(+), 1 deletion(-)
+
+Index: b/gcc/config.gcc
+===================================================================
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -441,7 +441,7 @@
+ extra_headers="ppc-asm.h altivec.h spe.h ppu_intrinsics.h paired.h spu2vmx.h vec_types.h si2vmx.h htmintrin.h htmxlintrin.h"
+ need_64bit_hwint=yes
+ case x$with_cpu in
+- xpowerpc64|xdefault64|x6[23]0|x970|xG5|xpower[345678]|xpower6x|xrs64a|xcell|xa2|xe500mc64|xe5500|Xe6500)
++ xpowerpc64|xdefault64|x6[23]0|x970|xG5|xpower[345678]|xpower6x|xrs64a|xcell|xa2|xe500mc64|xe5500|xe6500)
+ cpu_is_64bit=yes
+ ;;
+ esac
diff --git a/patches/gcc/linaro-4.9-2017.01/130-pr43538.patch b/patches/gcc/linaro-4.9-2017.01/130-pr43538.patch
new file mode 100644
index 0000000..19e57bb
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/130-pr43538.patch
@@ -0,0 +1,25 @@
+From c037df1be41f8daf4d581d7ffa4ec8cfa640bccf Mon Sep 17 00:00:00 2001
+From: glisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Fri, 25 Apr 2014 08:03:08 +0000
+Subject: [PATCH] 2014-04-25 Marc Glisse <marc.glisse@inria.fr>
+
+ PR target/43538
+ * mt-gnu: Don't reset CXXFLAGS_FOR_TARGET.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@209784 138bc75d-0d04-0410-961f-82ee72b054a4
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+ config/mt-gnu | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/config/mt-gnu b/config/mt-gnu
+index 15bf417..5c696f5 100644
+--- a/config/mt-gnu
++++ b/config/mt-gnu
+@@ -1 +1 @@
+-CXXFLAGS_FOR_TARGET = $(CXXFLAGS) -D_GNU_SOURCE
++CXXFLAGS_FOR_TARGET += -D_GNU_SOURCE
+--
+2.1.4
+
diff --git a/patches/gcc/linaro-4.9-2017.01/131-mt-ospace-preserve-FLAGS_FOR_TARGET.patch b/patches/gcc/linaro-4.9-2017.01/131-mt-ospace-preserve-FLAGS_FOR_TARGET.patch
new file mode 100644
index 0000000..1c49fb0
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/131-mt-ospace-preserve-FLAGS_FOR_TARGET.patch
@@ -0,0 +1,28 @@
+From 9bcf38cd9f382486b3823eb923b50e2e9a89cef7 Mon Sep 17 00:00:00 2001
+From: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Tue, 18 Nov 2014 22:12:52 +0000
+Subject: [PATCH] 2014-11-17 Bob Dunlop <bob.dunlop@xyzzy.org.uk>
+
+ * mt-ospace (CFLAGS_FOR_TARGET): Append -g -Os rather than
+ overwriting.
+ (CXXFLAGS_FOR_TARGET): Similarly.
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@217739 138bc75d-0d04-0410-961f-82ee72b054a4
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+ config/mt-ospace | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/config/mt-ospace b/config/mt-ospace
+index 7f09104..ce29ff4 100644
+--- a/config/mt-ospace
++++ b/config/mt-ospace
+@@ -1,3 +1,3 @@
+ # Build libraries optimizing for space, not speed.
+- CFLAGS_FOR_TARGET = -g -Os
+- CXXFLAGS_FOR_TARGET = -g -Os
++ CFLAGS_FOR_TARGET += -g -Os
++ CXXFLAGS_FOR_TARGET += -g -Os
+--
+2.1.4
+
diff --git a/patches/gcc/linaro-4.9-2017.01/140-sanitizer-Fix-build-with-_FILE_OFFSET_BITS-64.patch b/patches/gcc/linaro-4.9-2017.01/140-sanitizer-Fix-build-with-_FILE_OFFSET_BITS-64.patch
new file mode 100644
index 0000000..55f3228
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/140-sanitizer-Fix-build-with-_FILE_OFFSET_BITS-64.patch
@@ -0,0 +1,37 @@
+From 3c536954a67a883630f4a7513a27f02a892c3dcb Mon Sep 17 00:00:00 2001
+From: Evgeniy Stepanov <eugeni.stepanov@gmail.com>
+Date: Tue, 21 Oct 2014 21:08:13 +0000
+Subject: [PATCH] [sanitizer] Fix build with _FILE_OFFSET_BITS=64.
+
+Sanitizer source is not affected by _FILE_OFFSET_BITS in general,
+but this one file must be built with 32-bit off_t. More details in the code.
+
+git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@220328 91177308-0d34-0410-b5e6-96231b3b80d8
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+ lib/sanitizer_common/sanitizer_platform_limits_posix.cc | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
+index bbc1108..fc09522 100644
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
+@@ -13,7 +13,15 @@
+
+ #include "sanitizer_platform.h"
+ #if SANITIZER_LINUX || SANITIZER_MAC
++// Tests in this file assume that off_t-dependent data structures match the
++// libc ABI. For example, struct dirent here is what readdir() function (as
++// exported from libc) returns, and not the user-facing "dirent", which
++// depends on _FILE_OFFSET_BITS setting.
++// To get this "true" dirent definition, we undefine _FILE_OFFSET_BITS below.
++#ifdef _FILE_OFFSET_BITS
++#undef _FILE_OFFSET_BITS
++#endif
+
+ #include "sanitizer_internal_defs.h"
+ #include "sanitizer_platform_limits_posix.h"
+
+--
+2.1.4
+
diff --git a/patches/gcc/linaro-4.9-2017.01/301-missing-execinfo_h.patch b/patches/gcc/linaro-4.9-2017.01/301-missing-execinfo_h.patch
new file mode 100644
index 0000000..00efda2
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/301-missing-execinfo_h.patch
@@ -0,0 +1,13 @@
+Index: gcc-4.8.0/boehm-gc/include/gc.h
+===================================================================
+--- gcc-4.8.0.orig/boehm-gc/include/gc.h 2007-04-23 23:10:09.000000000 +0200
++++ gcc-4.8.0/boehm-gc/include/gc.h 2013-03-23 17:39:20.000000000 +0100
+@@ -503,7 +503,7 @@
+ #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/patches/gcc/linaro-4.9-2017.01/370-gcc-plugin-Win-Dont-need-undefined-extern-var-refs-nor-fpic.patch b/patches/gcc/linaro-4.9-2017.01/370-gcc-plugin-Win-Dont-need-undefined-extern-var-refs-nor-fpic.patch
new file mode 100644
index 0000000..c3bab15
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/370-gcc-plugin-Win-Dont-need-undefined-extern-var-refs-nor-fpic.patch
@@ -0,0 +1,104 @@
+diff -urpN '--exclude=autom4te.cache' gcc-4.9.4.orig/gcc/configure gcc-4.9.4/gcc/configure
+--- gcc-4.9.4.orig/gcc/configure 2016-05-22 01:53:32.000000000 -0700
++++ gcc-4.9.4/gcc/configure 2017-02-11 16:54:52.879474293 -0800
+@@ -28058,6 +28058,9 @@ fi
+
+
+ pluginlibs=
++PICFLAG="-fPIC"
++UNDEFINEDPREAMBLE="extern int X;"
++UNDEFINEDCODE="return X == 0;"
+
+ case "${host}" in
+ *-*-darwin*)
+@@ -28069,6 +28072,11 @@ case "${host}" in
+ export_sym_check=
+ fi
+ ;;
++ *-*-mingw*|*-*-cygwin*|*-*-msys*)
++ PICFLAG=""
++ UNDEFINEDPREAMBLE=""
++ UNDEFINEDCODE=""
++ ;;
+ *)
+ if test x$build = x$host; then
+ export_sym_check="objdump${exeext} -T"
+@@ -28181,23 +28189,23 @@ fi
+ case "${host}" in
+ *-*-darwin*)
+ CFLAGS=`echo $CFLAGS | sed s/-mdynamic-no-pic//g`
+- CFLAGS="$CFLAGS -fPIC"
++ CFLAGS="$CFLAGS ${PICFLAG}"
+ LDFLAGS="$LDFLAGS -shared -undefined dynamic_lookup"
+ ;;
+ *)
+- CFLAGS="$CFLAGS -fPIC"
+- LDFLAGS="$LDFLAGS -fPIC -shared"
++ CFLAGS="$CFLAGS ${PICFLAG}"
++ LDFLAGS="$LDFLAGS ${PICFLAG} -shared"
+ ;;
+ esac
+- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fPIC -shared" >&5
+-$as_echo_n "checking for -fPIC -shared... " >&6; }
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${PICFLAG} -shared" >&5
++$as_echo_n "checking for ${PICFLAG} -shared... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+-extern int X;
++${UNDEFINEDPREAMBLE}
+ int
+ main ()
+ {
+-return X == 0;
++${UNDEFINEDCODE}
+ ;
+ return 0;
+ }
+diff -urpN '--exclude=autom4te.cache' gcc-4.9.4.orig/gcc/configure.ac gcc-4.9.4/gcc/configure.ac
+--- gcc-4.9.4.orig/gcc/configure.ac 2016-05-22 01:53:32.000000000 -0700
++++ gcc-4.9.4/gcc/configure.ac 2017-02-11 16:49:59.820965424 -0800
+@@ -5583,6 +5583,9 @@ enable_plugin=$enableval,
+ enable_plugin=yes; default_plugin=yes)
+
+ pluginlibs=
++PICFLAG="-fPIC"
++UNDEFINEDPREAMBLE="extern int X;"
++UNDEFINEDCODE="return X == 0;"
+
+ case "${host}" in
+ *-*-darwin*)
+@@ -5594,6 +5597,11 @@ case "${host}" in
+ export_sym_check=
+ fi
+ ;;
++ *-*-mingw*|*-*-cygwin*|*-*-msys*)
++ PICFLAG=""
++ UNDEFINEDPREAMBLE=""
++ UNDEFINEDCODE=""
++ ;;
+ *)
+ if test x$build = x$host; then
+ export_sym_check="objdump${exeext} -T"
+@@ -5645,17 +5653,17 @@ if test x"$enable_plugin" = x"yes"; then
+ case "${host}" in
+ *-*-darwin*)
+ CFLAGS=`echo $CFLAGS | sed s/-mdynamic-no-pic//g`
+- CFLAGS="$CFLAGS -fPIC"
++ CFLAGS="$CFLAGS ${PICFLAG}"
+ LDFLAGS="$LDFLAGS -shared -undefined dynamic_lookup"
+ ;;
+ *)
+- CFLAGS="$CFLAGS -fPIC"
+- LDFLAGS="$LDFLAGS -fPIC -shared"
++ CFLAGS="$CFLAGS ${PICFLAG}"
++ LDFLAGS="$LDFLAGS ${PICFLAG} -shared"
+ ;;
+ esac
+- AC_MSG_CHECKING([for -fPIC -shared])
++ AC_MSG_CHECKING([for ${PICFLAG} -shared])
+ AC_TRY_LINK(
+- [extern int X;],[return X == 0;],
++ [${UNDEFINEDPREAMBLE}],[${UNDEFINEDCODE}],
+ [AC_MSG_RESULT([yes]); have_pic_shared=yes],
+ [AC_MSG_RESULT([no]); have_pic_shared=no])
+ if test x"$have_pic_shared" != x"yes" -o x"$ac_cv_search_dlopen" = x"no"; then
diff --git a/patches/gcc/linaro-4.9-2017.01/810-arm-softfloat-libgcc.patch b/patches/gcc/linaro-4.9-2017.01/810-arm-softfloat-libgcc.patch
new file mode 100644
index 0000000..5efa7fd
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/810-arm-softfloat-libgcc.patch
@@ -0,0 +1,30 @@
+Index: b/gcc/config/arm/linux-elf.h
+===================================================================
+--- 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 "%{mfloat-abi=soft*:-lfloat} -lgcc"
++#define LIBGCC_SPEC "-lgcc"
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+Index: b/libgcc/config/arm/t-linux
+===================================================================
+--- a/libgcc/config/arm/t-linux
++++ b/libgcc/config/arm/t-linux
+@@ -1,6 +1,11 @@
+ LIB1ASMSRC = arm/lib1funcs.S
+ LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \
+- _ctzsi2 _arm_addsubdf3 _arm_addsubsf3
++ _ctzsi2 _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
+
+ # Just for these, we omit the frame pointer since it makes such a big
+ # difference.
diff --git a/patches/gcc/linaro-4.9-2017.01/830-arm_unbreak_armv4t.patch b/patches/gcc/linaro-4.9-2017.01/830-arm_unbreak_armv4t.patch
new file mode 100644
index 0000000..37f8f2a
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/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/patches/gcc/linaro-4.9-2017.01/840-microblaze-enable-dwarf-eh-support.patch b/patches/gcc/linaro-4.9-2017.01/840-microblaze-enable-dwarf-eh-support.patch
new file mode 100644
index 0000000..03fc47f
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/840-microblaze-enable-dwarf-eh-support.patch
@@ -0,0 +1,166 @@
+Fetched from Xilinx gcc git at https://github.com/Xilinx/gcc
+
+From 23c35173490ac2d6348a668dfc9c1a6eb62171f2 Mon Sep 17 00:00:00 2001
+From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
+Date: Mon, 18 Jun 2012 20:18:13 +0200
+Subject: [PATCH] [Patch, microblaze]: Enable DWARF exception handling support.
+
+Changelog
+
+2013-03-18 Edgar E. Iglesias <edgar.iglesias@xilinx.com>
+ David Holsgrove <david.holsgrove@xilinx.com>
+
+ * common/config/microblaze/microblaze-common.c: Remove
+ TARGET_EXCEPT_UNWIND_INFO definition.
+ * config/microblaze/microblaze-protos.h: Add
+ microblaze_eh_return prototype.
+ * gcc/config/microblaze/microblaze.c: (microblaze_must_save_register,
+ microblaze_expand_epilogue, microblaze_return_addr): Handle
+ calls_eh_return
+ (microblaze_eh_return): New function.
+ * gcc/config/microblaze/microblaze.h: Define RETURN_ADDR_OFFSET,
+ EH_RETURN_DATA_REGNO, MB_EH_STACKADJ_REGNUM, EH_RETURN_STACKADJ_RTX,
+ ASM_PREFERRED_EH_DATA_FORMAT
+ * gcc/config/microblaze/microblaze.md: Define eh_return pattern.
+
+Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
+Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
+---
+ gcc/common/config/microblaze/microblaze-common.c | 3 ---
+ gcc/config/microblaze/microblaze-protos.h | 1 +
+ gcc/config/microblaze/microblaze.c | 29 ++++++++++++++++++++----
+ gcc/config/microblaze/microblaze.h | 15 ++++++++++++
+ gcc/config/microblaze/microblaze.md | 11 +++++++++
+ 5 files changed, 52 insertions(+), 7 deletions(-)
+
+Index: b/gcc/common/config/microblaze/microblaze-common.c
+===================================================================
+--- a/gcc/common/config/microblaze/microblaze-common.c
++++ b/gcc/common/config/microblaze/microblaze-common.c
+@@ -37,7 +37,4 @@
+ #undef TARGET_OPTION_OPTIMIZATION_TABLE
+ #define TARGET_OPTION_OPTIMIZATION_TABLE microblaze_option_optimization_table
+
+-#undef TARGET_EXCEPT_UNWIND_INFO
+-#define TARGET_EXCEPT_UNWIND_INFO sjlj_except_unwind_info
+-
+ struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
+Index: b/gcc/config/microblaze/microblaze-protos.h
+===================================================================
+--- a/gcc/config/microblaze/microblaze-protos.h
++++ b/gcc/config/microblaze/microblaze-protos.h
+@@ -54,6 +54,7 @@
+ extern int symbol_mentioned_p (rtx);
+ extern int label_mentioned_p (rtx);
+ extern bool microblaze_cannot_force_const_mem (enum machine_mode, rtx);
++extern void microblaze_eh_return (rtx op0);
+ #endif /* RTX_CODE */
+
+ /* Declare functions in microblaze-c.c. */
+Index: b/gcc/config/microblaze/microblaze.c
+===================================================================
+--- a/gcc/config/microblaze/microblaze.c
++++ b/gcc/config/microblaze/microblaze.c
+@@ -1906,6 +1906,11 @@
+ if (frame_pointer_needed && (regno == HARD_FRAME_POINTER_REGNUM))
+ return 1;
+
++ if (crtl->calls_eh_return
++ && regno == MB_ABI_SUB_RETURN_ADDR_REGNUM) {
++ return 1;
++ }
++
+ if (!crtl->is_leaf)
+ {
+ if (regno == MB_ABI_SUB_RETURN_ADDR_REGNUM)
+@@ -1933,6 +1938,13 @@
+ return 1;
+ }
+
++ if (crtl->calls_eh_return
++ && (regno == EH_RETURN_DATA_REGNO (0)
++ || regno == EH_RETURN_DATA_REGNO (1)))
++ {
++ return 1;
++ }
++
+ return 0;
+ }
+
+@@ -2962,6 +2974,12 @@
+ emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, fsiz_rtx));
+ }
+
++ if (crtl->calls_eh_return)
++ emit_insn (gen_addsi3 (stack_pointer_rtx,
++ stack_pointer_rtx,
++ gen_rtx_raw_REG (SImode,
++ MB_EH_STACKADJ_REGNUM)));
++
+ emit_jump_insn (gen_return_internal (gen_rtx_REG (Pmode, GP_REG_FIRST +
+ MB_ABI_SUB_RETURN_ADDR_REGNUM)));
+ }
+@@ -3256,10 +3274,13 @@
+ if (count != 0)
+ return NULL_RTX;
+
+- return gen_rtx_PLUS (Pmode,
+- get_hard_reg_initial_val (Pmode,
+- MB_ABI_SUB_RETURN_ADDR_REGNUM),
+- GEN_INT (8));
++ return get_hard_reg_initial_val (Pmode,
++ MB_ABI_SUB_RETURN_ADDR_REGNUM);
++}
++
++void microblaze_eh_return (rtx op0)
++{
++ emit_insn (gen_movsi(gen_rtx_MEM(Pmode, stack_pointer_rtx), op0));
+ }
+
+ /* Queue an .ident string in the queue of top-level asm statements.
+Index: b/gcc/config/microblaze/microblaze.h
+===================================================================
+--- a/gcc/config/microblaze/microblaze.h
++++ b/gcc/config/microblaze/microblaze.h
+@@ -184,6 +184,21 @@
+ #define INCOMING_RETURN_ADDR_RTX \
+ gen_rtx_REG (VOIDmode, GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM)
+
++/* Specifies the offset from INCOMING_RETURN_ADDR_RTX and the actual return PC. */
++#define RETURN_ADDR_OFFSET (8)
++
++/* Describe how we implement __builtin_eh_return. */
++#define EH_RETURN_DATA_REGNO(N) (((N) < 2) ? MB_ABI_FIRST_ARG_REGNUM + (N) : INVALID_REGNUM)
++
++#define MB_EH_STACKADJ_REGNUM MB_ABI_INT_RETURN_VAL2_REGNUM
++#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, MB_EH_STACKADJ_REGNUM)
++
++/* Select a format to encode pointers in exception handling data. CODE
++ is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
++ true if the symbol may be affected by dynamic relocations. */
++#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
++ ((flag_pic || GLOBAL) ? DW_EH_PE_aligned : DW_EH_PE_absptr)
++
+ /* Use DWARF 2 debugging information by default. */
+ #define DWARF2_DEBUGGING_INFO
+ #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
+Index: b/gcc/config/microblaze/microblaze.md
+===================================================================
+--- a/gcc/config/microblaze/microblaze.md
++++ b/gcc/config/microblaze/microblaze.md
+@@ -2261,4 +2261,15 @@
+ (set_attr "mode" "SI")
+ (set_attr "length" "4")])
+
++; This is used in compiling the unwind routines.
++(define_expand "eh_return"
++ [(use (match_operand 0 "general_operand" ""))]
++ ""
++ "
++{
++ microblaze_eh_return(operands[0]);
++ DONE;
++}")
++
+ (include "sync.md")
++
diff --git a/patches/gcc/linaro-4.9-2017.01/850-libstdcxx-uclibc-c99.patch b/patches/gcc/linaro-4.9-2017.01/850-libstdcxx-uclibc-c99.patch
new file mode 100644
index 0000000..533d01f
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/850-libstdcxx-uclibc-c99.patch
@@ -0,0 +1,274 @@
+Allow C99-depending features of libstdc++ with uClibc
+
+The libstdc++ code is fairly restrictive on how it checks for C99
+compatibility: it requires *complete* C99 support to enable certain
+features. For example, uClibc provides a good number of C99 features,
+but not C99 complex number support. For this reason, libstdc++
+completely disables many the standard C++ methods that can in fact
+work because uClibc provides the necessary functions.
+
+This patch is similar and highly inspired from
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58393, but implemented in
+a way that doesn't involve changing the configure.ac script, as
+autoreconfiguring gcc is complicated. It simply relies on the fact
+that uClibc defines the __UCLIBC__ definition.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+[Gustavo: update for 4.9.3]
+
+Index: b/libstdc++-v3/config/locale/generic/c_locale.h
+===================================================================
+--- a/libstdc++-v3/config/locale/generic/c_locale.h
++++ b/libstdc++-v3/config/locale/generic/c_locale.h
+@@ -70,7 +70,7 @@
+ __builtin_va_list __args;
+ __builtin_va_start(__args, __fmt);
+
+-#ifdef _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
+ #else
+ const int __ret = __builtin_vsprintf(__out, __fmt, __args);
+Index: b/libstdc++-v3/config/locale/gnu/c_locale.h
+===================================================================
+--- a/libstdc++-v3/config/locale/gnu/c_locale.h
++++ b/libstdc++-v3/config/locale/gnu/c_locale.h
+@@ -88,7 +88,7 @@
+ __builtin_va_list __args;
+ __builtin_va_start(__args, __fmt);
+
+-#ifdef _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
+ #else
+ const int __ret = __builtin_vsprintf(__out, __fmt, __args);
+Index: b/libstdc++-v3/include/bits/basic_string.h
+===================================================================
+--- a/libstdc++-v3/include/bits/basic_string.h
++++ b/libstdc++-v3/include/bits/basic_string.h
+@@ -2843,7 +2843,7 @@
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace
+
+-#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99)
++#if __cplusplus >= 201103L && (defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__))
+
+ #include <ext/string_conversions.h>
+
+Index: b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+===================================================================
+--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
++++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+@@ -572,7 +572,7 @@
+ {
+ const locale __loc = __io.getloc();
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+-#ifdef _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ // First try a buffer perhaps big enough.
+ int __cs_size = 64;
+ char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
+Index: b/libstdc++-v3/include/bits/locale_facets.tcc
+===================================================================
+--- a/libstdc++-v3/include/bits/locale_facets.tcc
++++ b/libstdc++-v3/include/bits/locale_facets.tcc
+@@ -987,7 +987,7 @@
+ char __fbuf[16];
+ __num_base::_S_format_float(__io, __fbuf, __mod);
+
+-#ifdef _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ // First try a buffer perhaps big enough (most probably sufficient
+ // for non-ios_base::fixed outputs)
+ int __cs_size = __max_digits * 3;
+Index: b/libstdc++-v3/include/c_compatibility/math.h
+===================================================================
+--- a/libstdc++-v3/include/c_compatibility/math.h
++++ b/libstdc++-v3/include/c_compatibility/math.h
+@@ -56,7 +56,7 @@
+ using std::floor;
+ using std::fmod;
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ using std::fpclassify;
+ using std::isfinite;
+ using std::isinf;
+Index: b/libstdc++-v3/include/c_compatibility/wchar.h
+===================================================================
+--- a/libstdc++-v3/include/c_compatibility/wchar.h
++++ b/libstdc++-v3/include/c_compatibility/wchar.h
+@@ -103,7 +103,7 @@
+ using std::wmemset;
+ using std::wcsftime;
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ using std::wcstold;
+ using std::wcstoll;
+ using std::wcstoull;
+Index: b/libstdc++-v3/include/c_global/cstdio
+===================================================================
+--- a/libstdc++-v3/include/c_global/cstdio
++++ b/libstdc++-v3/include/c_global/cstdio
+@@ -146,7 +146,7 @@
+ using ::vsprintf;
+ } // namespace
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ #undef snprintf
+ #undef vfscanf
+Index: b/libstdc++-v3/include/c_global/cstdlib
+===================================================================
+--- a/libstdc++-v3/include/c_global/cstdlib
++++ b/libstdc++-v3/include/c_global/cstdlib
+@@ -182,7 +182,7 @@
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ #undef _Exit
+ #undef llabs
+Index: b/libstdc++-v3/include/c_global/cwchar
+===================================================================
+--- a/libstdc++-v3/include/c_global/cwchar
++++ b/libstdc++-v3/include/c_global/cwchar
+@@ -232,7 +232,7 @@
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ #undef wcstold
+ #undef wcstoll
+@@ -289,7 +289,7 @@
+ using std::vwscanf;
+ #endif
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ using std::wcstold;
+ using std::wcstoll;
+ using std::wcstoull;
+Index: b/libstdc++-v3/include/c_std/cstdio
+===================================================================
+--- a/libstdc++-v3/include/c_std/cstdio
++++ b/libstdc++-v3/include/c_std/cstdio
+@@ -144,7 +144,7 @@
+ using ::vsprintf;
+ } // namespace std
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ #undef snprintf
+ #undef vfscanf
+Index: b/libstdc++-v3/include/c_std/cstdlib
+===================================================================
+--- a/libstdc++-v3/include/c_std/cstdlib
++++ b/libstdc++-v3/include/c_std/cstdlib
+@@ -180,7 +180,7 @@
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ #undef _Exit
+ #undef llabs
+Index: b/libstdc++-v3/include/c_std/cwchar
+===================================================================
+--- a/libstdc++-v3/include/c_std/cwchar
++++ b/libstdc++-v3/include/c_std/cwchar
+@@ -228,7 +228,7 @@
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ #undef wcstold
+ #undef wcstoll
+Index: b/libstdc++-v3/include/ext/vstring.h
+===================================================================
+--- a/libstdc++-v3/include/ext/vstring.h
++++ b/libstdc++-v3/include/ext/vstring.h
+@@ -2680,7 +2680,7 @@
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace
+
+-#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99))
++#if ((__cplusplus >= 201103L) && (defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)))
+
+ #include <ext/string_conversions.h>
+
+Index: b/libstdc++-v3/include/tr1/cstdio
+===================================================================
+--- a/libstdc++-v3/include/tr1/cstdio
++++ b/libstdc++-v3/include/tr1/cstdio
+@@ -33,7 +33,7 @@
+
+ #include <cstdio>
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ namespace std _GLIBCXX_VISIBILITY(default)
+ {
+Index: b/libstdc++-v3/include/tr1/cstdlib
+===================================================================
+--- a/libstdc++-v3/include/tr1/cstdlib
++++ b/libstdc++-v3/include/tr1/cstdlib
+@@ -35,7 +35,7 @@
+
+ #if _GLIBCXX_HOSTED
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ namespace std _GLIBCXX_VISIBILITY(default)
+ {
+Index: b/libstdc++-v3/include/tr1/cwchar
+===================================================================
+--- a/libstdc++-v3/include/tr1/cwchar
++++ b/libstdc++-v3/include/tr1/cwchar
+@@ -52,7 +52,7 @@
+ using std::vwscanf;
+ #endif
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ using std::wcstold;
+ using std::wcstoll;
+ using std::wcstoull;
+Index: b/libstdc++-v3/include/tr1/stdlib.h
+===================================================================
+--- a/libstdc++-v3/include/tr1/stdlib.h
++++ b/libstdc++-v3/include/tr1/stdlib.h
+@@ -33,7 +33,7 @@
+
+ #if _GLIBCXX_HOSTED
+
+-#if _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+
+ using std::tr1::atoll;
+ using std::tr1::strtoll;
+Index: b/libstdc++-v3/src/c++11/debug.cc
+===================================================================
+--- a/libstdc++-v3/src/c++11/debug.cc
++++ b/libstdc++-v3/src/c++11/debug.cc
+@@ -788,7 +788,7 @@
+ int __n __attribute__ ((__unused__)),
+ const char* __fmt, _Tp __s) const throw ()
+ {
+-#ifdef _GLIBCXX_USE_C99
++#if defined(_GLIBCXX_USE_C99) || defined(__UCLIBC__)
+ std::snprintf(__buf, __n, __fmt, __s);
+ #else
+ std::sprintf(__buf, __fmt, __s);
diff --git a/patches/gcc/linaro-4.9-2017.01/860-cilk-wchar.patch b/patches/gcc/linaro-4.9-2017.01/860-cilk-wchar.patch
new file mode 100644
index 0000000..1837405
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/860-cilk-wchar.patch
@@ -0,0 +1,56 @@
+[PATCH] cilk: fix build without wchar
+
+When building against uClibc with wchar support disabled, WCHAR_MIN and
+WCHAR_MAX are not defined leading to compilation errors.
+
+Fix it by only including the wchar code if available.
+
+Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
+---
+ libcilkrts/include/cilk/reducer_min_max.h | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+Index: host-gcc-final-4.9.2/libcilkrts/include/cilk/reducer_min_max.h
+===================================================================
+--- host-gcc-final-4.9.2.orig/libcilkrts/include/cilk/reducer_min_max.h
++++ host-gcc-final-4.9.2/libcilkrts/include/cilk/reducer_min_max.h
+@@ -3154,7 +3154,9 @@
+ CILK_C_REDUCER_MAX_INSTANCE(char, char, CHAR_MIN)
+ CILK_C_REDUCER_MAX_INSTANCE(unsigned char, uchar, 0)
+ CILK_C_REDUCER_MAX_INSTANCE(signed char, schar, SCHAR_MIN)
++#ifdef WCHAR_MIN
+ CILK_C_REDUCER_MAX_INSTANCE(wchar_t, wchar_t, WCHAR_MIN)
++#endif
+ CILK_C_REDUCER_MAX_INSTANCE(short, short, SHRT_MIN)
+ CILK_C_REDUCER_MAX_INSTANCE(unsigned short, ushort, 0)
+ CILK_C_REDUCER_MAX_INSTANCE(int, int, INT_MIN)
+@@ -3306,7 +3308,9 @@
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(char, char, CHAR_MIN)
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(unsigned char, uchar, 0)
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(signed char, schar, SCHAR_MIN)
++#ifdef WCHAR_MIN
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(wchar_t, wchar_t, WCHAR_MIN)
++#endif
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(short, short, SHRT_MIN)
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(unsigned short, ushort, 0)
+ CILK_C_REDUCER_MAX_INDEX_INSTANCE(int, int, INT_MIN)
+@@ -3432,7 +3436,9 @@
+ CILK_C_REDUCER_MIN_INSTANCE(char, char, CHAR_MAX)
+ CILK_C_REDUCER_MIN_INSTANCE(unsigned char, uchar, CHAR_MAX)
+ CILK_C_REDUCER_MIN_INSTANCE(signed char, schar, SCHAR_MAX)
++#ifdef WCHAR_MAX
+ CILK_C_REDUCER_MIN_INSTANCE(wchar_t, wchar_t, WCHAR_MAX)
++#endif
+ CILK_C_REDUCER_MIN_INSTANCE(short, short, SHRT_MAX)
+ CILK_C_REDUCER_MIN_INSTANCE(unsigned short, ushort, USHRT_MAX)
+ CILK_C_REDUCER_MIN_INSTANCE(int, int, INT_MAX)
+@@ -3584,7 +3590,9 @@
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(char, char, CHAR_MAX)
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(unsigned char, uchar, CHAR_MAX)
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(signed char, schar, SCHAR_MAX)
++#ifdef WCHAR_MAX
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(wchar_t, wchar_t, WCHAR_MAX)
++#endif
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(short, short, SHRT_MAX)
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(unsigned short, ushort, USHRT_MAX)
+ CILK_C_REDUCER_MIN_INDEX_INSTANCE(int, int, INT_MAX)
diff --git a/patches/gcc/linaro-4.9-2017.01/870-xtensa-add-mauto-litpools-option.patch b/patches/gcc/linaro-4.9-2017.01/870-xtensa-add-mauto-litpools-option.patch
new file mode 100644
index 0000000..98c7b3f
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/870-xtensa-add-mauto-litpools-option.patch
@@ -0,0 +1,287 @@
+From 6d852ffb43b111a39162135c95249e749c4e285b Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Thu, 6 Aug 2015 01:16:02 +0300
+Subject: [PATCH] xtensa: add -mauto-litpools option
+
+With support from assembler this option allows compiling huge functions,
+where single literal pool at the beginning of a function may not be
+reachable by L32R instructions at its end.
+
+Currently assembler --auto-litpools option cannot deal with literals
+used from multiple locations separated by more than 256 KBytes of code.
+Don't turn constants into literals, instead use MOVI instruction to load
+them into registers and let the assembler turn them into literals as
+necessary.
+
+2015-08-12 Max Filippov <jcmvbkbc@gmail.com>
+gcc/
+ * config/xtensa/constraints.md (define_constraint "Y"): New
+ constraint.
+ * config/xtensa/elf.h (ASM_SPEC): Add m(no-)auto-litpools.
+ * config/xtensa/linux.h (ASM_SPEC): Likewise.
+ * config/xtensa/predicates.md (move_operand): Match constants
+ and symbols in the presence of TARGET_AUTO_LITPOOLS.
+ * config/xtensa/xtensa.c (xtensa_valid_move): Don't allow
+ immediate references to TLS data.
+ (xtensa_emit_move_sequence): Don't force constants to memory in
+ the presence of TARGET_AUTO_LITPOOLS.
+ (print_operand): Add 'y' format, same as default, but capable of
+ printing SF mode constants as well.
+ * config/xtensa/xtensa.md (movsi_internal, movhi_internal)
+ (movsf_internal): Add movi pattern that loads literal.
+ (movsf, movdf): Don't force constants to memory in the presence
+ of TARGET_AUTO_LITPOOLS.
+ (movdf_internal): Add 'Y' constraint.
+ * config/xtensa/xtensa.opt (mauto-litpools): New option.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: r226828
+Changes to ChangeLogs and documentation are dropped.
+
+ gcc/config/xtensa/constraints.md | 5 +++++
+ gcc/config/xtensa/elf.h | 4 +++-
+ gcc/config/xtensa/linux.h | 4 +++-
+ gcc/config/xtensa/predicates.md | 3 ++-
+ gcc/config/xtensa/xtensa.c | 19 ++++++++++++++++++-
+ gcc/config/xtensa/xtensa.md | 35 +++++++++++++++++++----------------
+ gcc/config/xtensa/xtensa.opt | 4 ++++
+ 7 files changed, 54 insertions(+), 20 deletions(-)
+
+Index: b/gcc/config/xtensa/constraints.md
+===================================================================
+--- a/gcc/config/xtensa/constraints.md
++++ b/gcc/config/xtensa/constraints.md
+@@ -111,6 +111,11 @@
+ (and (match_code "const_int")
+ (match_test "xtensa_mask_immediate (ival)")))
+
++(define_constraint "Y"
++ "A constant that can be used in relaxed MOVI instructions."
++ (and (match_code "const_int,const_double,const,symbol_ref,label_ref")
++ (match_test "TARGET_AUTO_LITPOOLS")))
++
+ ;; Memory constraints. Do not use define_memory_constraint here. Doing so
+ ;; causes reload to force some constants into the constant pool, but since
+ ;; the Xtensa constant pool can only be accessed with L32R instructions, it
+Index: b/gcc/config/xtensa/elf.h
+===================================================================
+--- a/gcc/config/xtensa/elf.h
++++ b/gcc/config/xtensa/elf.h
+@@ -48,7 +48,9 @@
+ %{mtarget-align:--target-align} \
+ %{mno-target-align:--no-target-align} \
+ %{mlongcalls:--longcalls} \
+- %{mno-longcalls:--no-longcalls}"
++ %{mno-longcalls:--no-longcalls} \
++ %{mauto-litpools:--auto-litpools} \
++ %{mno-auto-litpools:--no-auto-litpools}"
+
+ #undef LIB_SPEC
+ #define LIB_SPEC "-lc -lsim -lc -lhandlers-sim -lhal"
+Index: b/gcc/config/xtensa/linux.h
+===================================================================
+--- a/gcc/config/xtensa/linux.h
++++ b/gcc/config/xtensa/linux.h
+@@ -42,7 +42,9 @@
+ %{mtarget-align:--target-align} \
+ %{mno-target-align:--no-target-align} \
+ %{mlongcalls:--longcalls} \
+- %{mno-longcalls:--no-longcalls}"
++ %{mno-longcalls:--no-longcalls} \
++ %{mauto-litpools:--auto-litpools} \
++ %{mno-auto-litpools:--no-auto-litpools}"
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+
+Index: b/gcc/config/xtensa/predicates.md
+===================================================================
+--- a/gcc/config/xtensa/predicates.md
++++ b/gcc/config/xtensa/predicates.md
+@@ -142,7 +142,8 @@
+ (match_test "GET_MODE_CLASS (mode) == MODE_INT
+ && xtensa_simm12b (INTVAL (op))"))
+ (and (match_code "const_int,const_double,const,symbol_ref,label_ref")
+- (match_test "TARGET_CONST16 && CONSTANT_P (op)
++ (match_test "(TARGET_CONST16 || TARGET_AUTO_LITPOOLS)
++ && CONSTANT_P (op)
+ && GET_MODE_SIZE (mode) % UNITS_PER_WORD == 0")))))
+
+ ;; Accept the floating point constant 1 in the appropriate mode.
+Index: b/gcc/config/xtensa/xtensa.c
+===================================================================
+--- a/gcc/config/xtensa/xtensa.c
++++ b/gcc/config/xtensa/xtensa.c
+@@ -477,6 +477,9 @@
+ {
+ int dst_regnum = xt_true_regnum (operands[0]);
+
++ if (xtensa_tls_referenced_p (operands[1]))
++ return FALSE;
++
+ /* The stack pointer can only be assigned with a MOVSP opcode. */
+ if (dst_regnum == STACK_POINTER_REGNUM)
+ return (mode == SImode
+@@ -1044,7 +1047,7 @@
+ return 1;
+ }
+
+- if (! TARGET_CONST16)
++ if (! TARGET_AUTO_LITPOOLS && ! TARGET_CONST16)
+ {
+ src = force_const_mem (SImode, src);
+ operands[1] = src;
+@@ -2428,6 +2431,20 @@
+ }
+ break;
+
++ case 'y':
++ if (GET_CODE (x) == CONST_DOUBLE &&
++ GET_MODE (x) == SFmode)
++ {
++ REAL_VALUE_TYPE r;
++ long l;
++ REAL_VALUE_FROM_CONST_DOUBLE (r, x);
++ REAL_VALUE_TO_TARGET_SINGLE (r, l);
++ fprintf (file, "0x%08lx", l);
++ break;
++ }
++
++ /* fall through */
++
+ default:
+ if (GET_CODE (x) == REG || GET_CODE (x) == SUBREG)
+ fprintf (file, "%s", reg_names[xt_true_regnum (x)]);
+Index: b/gcc/config/xtensa/xtensa.md
+===================================================================
+--- a/gcc/config/xtensa/xtensa.md
++++ b/gcc/config/xtensa/xtensa.md
+@@ -799,8 +799,8 @@
+ })
+
+ (define_insn "movsi_internal"
+- [(set (match_operand:SI 0 "nonimmed_operand" "=D,D,D,D,R,R,a,q,a,W,a,a,U,*a,*A")
+- (match_operand:SI 1 "move_operand" "M,D,d,R,D,d,r,r,I,i,T,U,r,*A,*r"))]
++ [(set (match_operand:SI 0 "nonimmed_operand" "=D,D,D,D,R,R,a,q,a,a,W,a,a,U,*a,*A")
++ (match_operand:SI 1 "move_operand" "M,D,d,R,D,d,r,r,I,Y,i,T,U,r,*A,*r"))]
+ "xtensa_valid_move (SImode, operands)"
+ "@
+ movi.n\t%0, %x1
+@@ -812,15 +812,16 @@
+ mov\t%0, %1
+ movsp\t%0, %1
+ movi\t%0, %x1
++ movi\t%0, %1
+ const16\t%0, %t1\;const16\t%0, %b1
+ %v1l32r\t%0, %1
+ %v1l32i\t%0, %1
+ %v0s32i\t%1, %0
+ rsr\t%0, ACCLO
+ wsr\t%1, ACCLO"
+- [(set_attr "type" "move,move,move,load,store,store,move,move,move,move,load,load,store,rsr,wsr")
++ [(set_attr "type" "move,move,move,load,store,store,move,move,move,move,move,load,load,store,rsr,wsr")
+ (set_attr "mode" "SI")
+- (set_attr "length" "2,2,2,2,2,2,3,3,3,6,3,3,3,3,3")])
++ (set_attr "length" "2,2,2,2,2,2,3,3,3,3,6,3,3,3,3,3")])
+
+ ;; 16-bit Integer moves
+
+@@ -834,21 +835,22 @@
+ })
+
+ (define_insn "movhi_internal"
+- [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,U,*a,*A")
+- (match_operand:HI 1 "move_operand" "M,d,r,I,U,r,*A,*r"))]
++ [(set (match_operand:HI 0 "nonimmed_operand" "=D,D,a,a,a,a,U,*a,*A")
++ (match_operand:HI 1 "move_operand" "M,d,r,I,Y,U,r,*A,*r"))]
+ "xtensa_valid_move (HImode, operands)"
+ "@
+ movi.n\t%0, %x1
+ mov.n\t%0, %1
+ mov\t%0, %1
+ movi\t%0, %x1
++ movi\t%0, %1
+ %v1l16ui\t%0, %1
+ %v0s16i\t%1, %0
+ rsr\t%0, ACCLO
+ wsr\t%1, ACCLO"
+- [(set_attr "type" "move,move,move,move,load,store,rsr,wsr")
++ [(set_attr "type" "move,move,move,move,move,load,store,rsr,wsr")
+ (set_attr "mode" "HI")
+- (set_attr "length" "2,2,3,3,3,3,3,3")])
++ (set_attr "length" "2,2,3,3,3,3,3,3,3")])
+
+ ;; 8-bit Integer moves
+
+@@ -919,7 +921,7 @@
+ (match_operand:SF 1 "general_operand" ""))]
+ ""
+ {
+- if (!TARGET_CONST16 && CONSTANT_P (operands[1]))
++ if (!TARGET_CONST16 && !TARGET_AUTO_LITPOOLS && CONSTANT_P (operands[1]))
+ operands[1] = force_const_mem (SFmode, operands[1]);
+
+ if ((!register_operand (operands[0], SFmode)
+@@ -934,8 +936,8 @@
+ })
+
+ (define_insn "movsf_internal"
+- [(set (match_operand:SF 0 "nonimmed_operand" "=f,f,U,D,D,R,a,f,a,W,a,a,U")
+- (match_operand:SF 1 "move_operand" "f,U,f,d,R,d,r,r,f,iF,T,U,r"))]
++ [(set (match_operand:SF 0 "nonimmed_operand" "=f,f,U,D,D,R,a,f,a,a,W,a,a,U")
++ (match_operand:SF 1 "move_operand" "f,U,f,d,R,d,r,r,f,Y,iF,T,U,r"))]
+ "((register_operand (operands[0], SFmode)
+ || register_operand (operands[1], SFmode))
+ && !(FP_REG_P (xt_true_regnum (operands[0]))
+@@ -950,13 +952,14 @@
+ mov\t%0, %1
+ wfr\t%0, %1
+ rfr\t%0, %1
++ movi\t%0, %y1
+ const16\t%0, %t1\;const16\t%0, %b1
+ %v1l32r\t%0, %1
+ %v1l32i\t%0, %1
+ %v0s32i\t%1, %0"
+- [(set_attr "type" "farith,fload,fstore,move,load,store,move,farith,farith,move,load,load,store")
++ [(set_attr "type" "farith,fload,fstore,move,load,store,move,farith,farith,move,move,load,load,store")
+ (set_attr "mode" "SF")
+- (set_attr "length" "3,3,3,2,2,2,3,3,3,6,3,3,3")])
++ (set_attr "length" "3,3,3,2,2,2,3,3,3,3,6,3,3,3")])
+
+ (define_insn "*lsiu"
+ [(set (match_operand:SF 0 "register_operand" "=f")
+@@ -997,7 +1000,7 @@
+ (match_operand:DF 1 "general_operand" ""))]
+ ""
+ {
+- if (CONSTANT_P (operands[1]) && !TARGET_CONST16)
++ if (CONSTANT_P (operands[1]) && !TARGET_CONST16 && !TARGET_AUTO_LITPOOLS)
+ operands[1] = force_const_mem (DFmode, operands[1]);
+
+ if (!register_operand (operands[0], DFmode)
+@@ -1008,8 +1011,8 @@
+ })
+
+ (define_insn_and_split "movdf_internal"
+- [(set (match_operand:DF 0 "nonimmed_operand" "=a,W,a,a,U")
+- (match_operand:DF 1 "move_operand" "r,iF,T,U,r"))]
++ [(set (match_operand:DF 0 "nonimmed_operand" "=a,a,W,a,a,U")
++ (match_operand:DF 1 "move_operand" "r,Y,iF,T,U,r"))]
+ "register_operand (operands[0], DFmode)
+ || register_operand (operands[1], DFmode)"
+ "#"
+Index: b/gcc/config/xtensa/xtensa.opt
+===================================================================
+--- a/gcc/config/xtensa/xtensa.opt
++++ b/gcc/config/xtensa/xtensa.opt
+@@ -38,6 +38,10 @@
+ Target
+ Intersperse literal pools with code in the text section
+
++mauto-litpools
++Target Report Mask(AUTO_LITPOOLS)
++Relax literals in assembler and place them automatically in the text section
++
+ mserialize-volatile
+ Target Report Mask(SERIALIZE_VOLATILE)
+ -mno-serialize-volatile Do not serialize volatile memory references with MEMW instructions
diff --git a/patches/gcc/linaro-4.9-2017.01/871-xtensa-reimplement-register-spilling.patch b/patches/gcc/linaro-4.9-2017.01/871-xtensa-reimplement-register-spilling.patch
new file mode 100644
index 0000000..abc7a08
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/871-xtensa-reimplement-register-spilling.patch
@@ -0,0 +1,76 @@
+From 05154174b369505238b759cf80d595d8cfc8c731 Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Mon, 10 Aug 2015 21:35:20 +0300
+Subject: [PATCH 1/3] xtensa: reimplement register spilling
+
+Spilling windowed registers in userspace is much easier, more portable,
+less error-prone and equally effective as in kernel. Now that register
+spilling syscall is considered obsolete in the xtensa linux kernel
+replace it with CALL12 followed by series of ENTRY in libgcc.
+
+2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
+libgcc/
+ * config/xtensa/lib2funcs.S (__xtensa_libgcc_window_spill): Use
+ CALL12 followed by series of ENTRY to spill windowed registers.
+ (__xtensa_nonlocal_goto): Call __xtensa_libgcc_window_spill
+ instead of making linux spill syscall.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: r226962
+
+ libgcc/config/xtensa/lib2funcs.S | 30 +++++++++++++++++++++++-------
+ 1 file changed, 23 insertions(+), 7 deletions(-)
+
+diff --git a/libgcc/config/xtensa/lib2funcs.S b/libgcc/config/xtensa/lib2funcs.S
+index 3ac8c1d..2e678af 100644
+--- a/libgcc/config/xtensa/lib2funcs.S
++++ b/libgcc/config/xtensa/lib2funcs.S
+@@ -33,10 +33,29 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ .global __xtensa_libgcc_window_spill
+ .type __xtensa_libgcc_window_spill,@function
+ __xtensa_libgcc_window_spill:
+- entry sp, 32
+- movi a2, 0
+- syscall
++ entry sp, 48
++#if XCHAL_NUM_AREGS > 16
++ call12 1f
++ retw
++ .align 4
++1:
++ .rept (XCHAL_NUM_AREGS - 24) / 12
++ _entry sp, 48
++ mov a12, a0
++ .endr
++ _entry sp, 16
++#if XCHAL_NUM_AREGS % 12 == 0
++ mov a4, a4
++#elif XCHAL_NUM_AREGS % 12 == 4
++ mov a8, a8
++#elif XCHAL_NUM_AREGS % 12 == 8
++ mov a12, a12
++#endif
++ retw
++#else
++ mov a8, a8
+ retw
++#endif
+ .size __xtensa_libgcc_window_spill, .-__xtensa_libgcc_window_spill
+
+
+@@ -58,10 +77,7 @@ __xtensa_nonlocal_goto:
+ entry sp, 32
+
+ /* Flush registers. */
+- mov a5, a2
+- movi a2, 0
+- syscall
+- mov a2, a5
++ call8 __xtensa_libgcc_window_spill
+
+ /* Because the save area for a0-a3 is stored one frame below
+ the one identified by a2, the only way to restore those
+--
+1.8.1.4
+
diff --git a/patches/gcc/linaro-4.9-2017.01/872-xtensa-use-unwind-dw2-fde-dip-instead-of-unwind-dw2-.patch b/patches/gcc/linaro-4.9-2017.01/872-xtensa-use-unwind-dw2-fde-dip-instead-of-unwind-dw2-.patch
new file mode 100644
index 0000000..f23a5c0
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/872-xtensa-use-unwind-dw2-fde-dip-instead-of-unwind-dw2-.patch
@@ -0,0 +1,33 @@
+From f66206679a0ad604f13673559f230160cd3d1189 Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Fri, 14 Aug 2015 02:45:02 +0300
+Subject: [PATCH 2/3] xtensa: use unwind-dw2-fde-dip instead of unwind-dw2-fde
+
+This allows having exception cleanup code in binaries that don't
+register their unwind tables.
+
+2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
+libgcc/
+ * config/xtensa/t-xtensa (LIB2ADDEH): Replace unwind-dw2-fde
+ with unwind-dw2-fde-dip.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: r226963
+
+ libgcc/config/xtensa/t-xtensa | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libgcc/config/xtensa/t-xtensa b/libgcc/config/xtensa/t-xtensa
+index 27399e6..66d0eb3 100644
+--- a/libgcc/config/xtensa/t-xtensa
++++ b/libgcc/config/xtensa/t-xtensa
+@@ -13,4 +13,4 @@ LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3 _udivsi3 _umodsi3 \
+ LIB2ADD = $(srcdir)/config/xtensa/lib2funcs.S
+
+ LIB2ADDEH = $(srcdir)/config/xtensa/unwind-dw2-xtensa.c \
+- $(srcdir)/unwind-dw2-fde.c $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
++ $(srcdir)/unwind-dw2-fde-dip.c $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
+--
+1.8.1.4
+
diff --git a/patches/gcc/linaro-4.9-2017.01/873-xtensa-fix-_Unwind_GetCFA.patch b/patches/gcc/linaro-4.9-2017.01/873-xtensa-fix-_Unwind_GetCFA.patch
new file mode 100644
index 0000000..dc40513
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/873-xtensa-fix-_Unwind_GetCFA.patch
@@ -0,0 +1,40 @@
+From 15c7c4d39b317f0d902ef28fd43eca5c3369f891 Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Sat, 15 Aug 2015 05:12:11 +0300
+Subject: [PATCH 3/3] xtensa: fix _Unwind_GetCFA
+
+Returning context->cfa in _Unwind_GetCFA makes CFA point one stack frame
+higher than what was actually used by code at context->ra. This results
+in invalid CFA value in signal frames and premature unwinding completion
+in forced unwinding used by uClibc NPTL thread cancellation.
+Returning context->sp from _Unwind_GetCFA makes all CFA values valid and
+matching code that used them.
+
+2015-08-18 Max Filippov <jcmvbkbc@gmail.com>
+libgcc/
+ * config/xtensa/unwind-dw2-xtensa.c (_Unwind_GetCFA): Return
+ context->sp instead of context->cfa.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: r226964
+
+ libgcc/config/xtensa/unwind-dw2-xtensa.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libgcc/config/xtensa/unwind-dw2-xtensa.c b/libgcc/config/xtensa/unwind-dw2-xtensa.c
+index 35f7797..ef6b900 100644
+--- a/libgcc/config/xtensa/unwind-dw2-xtensa.c
++++ b/libgcc/config/xtensa/unwind-dw2-xtensa.c
+@@ -130,7 +130,7 @@ _Unwind_GetGR (struct _Unwind_Context *context, int index)
+ _Unwind_Word
+ _Unwind_GetCFA (struct _Unwind_Context *context)
+ {
+- return (_Unwind_Ptr) context->cfa;
++ return (_Unwind_Ptr) context->sp;
+ }
+
+ /* Overwrite the saved value for register INDEX in CONTEXT with VAL. */
+--
+1.8.1.4
+
diff --git a/patches/gcc/linaro-4.9-2017.01/874-xtensa-add-uclinux-support.patch b/patches/gcc/linaro-4.9-2017.01/874-xtensa-add-uclinux-support.patch
new file mode 100644
index 0000000..881aec0
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/874-xtensa-add-uclinux-support.patch
@@ -0,0 +1,169 @@
+From 70c2cb98fb129b4766b5da0f945dc41fd568c77a Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Sat, 22 Aug 2015 08:44:26 +0300
+Subject: [PATCH] xtensa: add uclinux support
+
+2015-10-03 Max Filippov <jcmvbkbc@gmail.com>
+gcc/
+ * config.gcc (xtensa*-*-uclinux*): New configuration.
+ * config/xtensa/uclinux.h: New file.
+ * config/xtensa/uclinux.opt: New file.
+
+libgcc/
+ * config.host (xtensa*-*-uclinux*): New configuration.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+---
+Backported from: r228450
+
+ gcc/config.gcc | 5 ++++
+ gcc/config/xtensa/uclinux.h | 69 +++++++++++++++++++++++++++++++++++++++++++
+ gcc/config/xtensa/uclinux.opt | 32 ++++++++++++++++++++
+ libgcc/config.host | 5 ++++
+ 4 files changed, 111 insertions(+)
+ create mode 100644 gcc/config/xtensa/uclinux.h
+ create mode 100644 gcc/config/xtensa/uclinux.opt
+
+Index: b/gcc/config.gcc
+===================================================================
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -2871,6 +2871,11 @@
+ tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h xtensa/linux.h"
+ tmake_file="${tmake_file} xtensa/t-xtensa"
+ ;;
++xtensa*-*-uclinux*)
++ tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h xtensa/uclinux.h"
++ tmake_file="${tmake_file} xtensa/t-xtensa"
++ extra_options="${extra_options} xtensa/uclinux.opt"
++ ;;
+ am33_2.0-*-linux*)
+ tm_file="mn10300/mn10300.h dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h mn10300/linux.h"
+ gas=yes gnu_ld=yes
+Index: b/gcc/config/xtensa/uclinux.h
+===================================================================
+--- /dev/null
++++ b/gcc/config/xtensa/uclinux.h
+@@ -0,0 +1,69 @@
++/* Xtensa uClinux configuration.
++ Derived from the configuration for GCC for Intel i386 running Linux.
++ Copyright (C) 2001-2015 Free Software Foundation, Inc.
++
++This file is part of GCC.
++
++GCC 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 3, or (at your option) any later
++version.
++
++GCC 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 GCC; see the file COPYING3. If not see
++<http://www.gnu.org/licenses/>. */
++
++#undef TARGET_OS_CPP_BUILTINS
++#define TARGET_OS_CPP_BUILTINS() \
++ do \
++ { \
++ GNU_USER_TARGET_OS_CPP_BUILTINS (); \
++ builtin_define ("__uClinux__"); \
++ } \
++ while (0)
++
++#undef SUBTARGET_CPP_SPEC
++#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
++
++#undef SIZE_TYPE
++#define SIZE_TYPE "unsigned int"
++
++#undef PTRDIFF_TYPE
++#define PTRDIFF_TYPE "int"
++
++#undef WCHAR_TYPE
++#define WCHAR_TYPE "long int"
++
++#undef WCHAR_TYPE_SIZE
++#define WCHAR_TYPE_SIZE 32
++
++#undef ASM_SPEC
++#define ASM_SPEC \
++ "%{mtext-section-literals:--text-section-literals} \
++ %{mno-text-section-literals:--no-text-section-literals} \
++ %{mtarget-align:--target-align} \
++ %{mno-target-align:--no-target-align} \
++ %{mlongcalls:--longcalls} \
++ %{mno-longcalls:--no-longcalls} \
++ %{mauto-litpools:--auto-litpools} \
++ %{mno-auto-litpools:--no-auto-litpools}"
++
++#undef LINK_SPEC
++#define LINK_SPEC "%{!no-elf2flt:%{!elf2flt*:-elf2flt}}"
++
++#undef LOCAL_LABEL_PREFIX
++#define LOCAL_LABEL_PREFIX "."
++
++/* Always enable "-fpic" for Xtensa Linux. */
++#define XTENSA_ALWAYS_PIC 1
++
++#undef TARGET_LIBC_HAS_FUNCTION
++#define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
++
++#undef DBX_REGISTER_NUMBER
++
+Index: b/gcc/config/xtensa/uclinux.opt
+===================================================================
+--- /dev/null
++++ b/gcc/config/xtensa/uclinux.opt
+@@ -0,0 +1,32 @@
++; Xtensa uClinux options.
++
++; Copyright (C) 2015 Free Software Foundation, Inc.
++;
++; This file is part of GCC.
++;
++; GCC 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 3, or (at your option) any later
++; version.
++;
++; GCC 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 GCC; see the file COPYING3. If not see
++; <http://www.gnu.org/licenses/>.
++
++; See the GCC internals manual (options.texi) for a description of
++; this file's format.
++
++; Please try to keep this file in ASCII collating order.
++
++elf2flt
++Driver
++
++elf2flt=
++Driver JoinedOrMissing
++
++; This comment is to ensure we retain the blank line above.
+Index: b/libgcc/config.host
+===================================================================
+--- a/libgcc/config.host
++++ b/libgcc/config.host
+@@ -1213,6 +1213,11 @@
+ tmake_file="$tmake_file xtensa/t-xtensa xtensa/t-linux t-slibgcc-libgcc"
+ md_unwind_header=xtensa/linux-unwind.h
+ ;;
++xtensa*-*-uclinux*)
++ tmake_file="$tmake_file xtensa/t-xtensa xtensa/t-linux t-slibgcc-libgcc"
++ md_unwind_header=xtensa/linux-unwind.h
++ extra_parts="$extra_parts crtbeginS.o crtbeginT.o crtendS.o"
++ ;;
+ am33_2.0-*-linux*)
+ # Don't need crtbeginT.o from *-*-linux* default.
+ extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o"
diff --git a/patches/gcc/linaro-4.9-2017.01/880-nios2_legitimize_address.patch b/patches/gcc/linaro-4.9-2017.01/880-nios2_legitimize_address.patch
new file mode 100644
index 0000000..4623f29
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/880-nios2_legitimize_address.patch
@@ -0,0 +1,49 @@
+From b0ea54f3f995754881e0ea6651133aa7b58eeaa2 Mon Sep 17 00:00:00 2001
+From: cltang <cltang@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Tue, 22 Sep 2015 12:23:20 +0000
+Subject: [PATCH] nios2_legitimize_address 2015-09-22 Chung-Lin Tang
+ <cltang@codesourcery.com>
+
+ Backport from mainline
+ 2015-09-22 Chung-Lin Tang <cltang@codesourcery.com>
+
+ * config/nios2/nios2.c (nios2_legitimize_address): When handling
+ 'reg + reloc' cases, allow first operand to be non-REG, and use
+ force_reg() to enforce address pattern.
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-5-branch@228013 138bc75d-0d04-0410-961f-82ee72b054a4
+
+Fixes:
+http://autobuild.buildroot.net/results/901/90186d1fe134b804c0101554296b1235dc0ccbb0
+
+[backported to 4.9.3]
+Signed-off-by: Romain Naour <romain.naour@gmail.com>
+---
+ gcc/config/nios2/nios2.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/gcc/config/nios2/nios2.c b/gcc/config/nios2/nios2.c
+index 047b615..41dd6f9 100644
+--- a/gcc/config/nios2/nios2.c
++++ b/gcc/config/nios2/nios2.c
+@@ -1786,15 +1786,15 @@ nios2_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
+
+ Which will be output as '%tls_le(var+48)(r23)' in assembly. */
+ if (GET_CODE (x) == PLUS
+- && GET_CODE (XEXP (x, 0)) == REG
+ && GET_CODE (XEXP (x, 1)) == CONST)
+ {
+- rtx unspec, offset, reg = XEXP (x, 0);
++ rtx unspec, offset;
+ split_const (XEXP (x, 1), &unspec, &offset);
+ if (GET_CODE (unspec) == UNSPEC
+ && !nios2_large_offset_p (XINT (unspec, 1))
+ && offset != const0_rtx)
+ {
++ rtx reg = force_reg (Pmode, XEXP (x, 0));
+ unspec = copy_rtx (unspec);
+ XVECEXP (unspec, 0, 0)
+ = plus_constant (Pmode, XVECEXP (unspec, 0, 0), INTVAL (offset));
+--
+2.5.0
+
diff --git a/patches/gcc/linaro-4.9-2017.01/890-fix-m68k-compile.patch b/patches/gcc/linaro-4.9-2017.01/890-fix-m68k-compile.patch
new file mode 100644
index 0000000..140977b
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/890-fix-m68k-compile.patch
@@ -0,0 +1,15 @@
+remove unused header, which breaks the toolchain building
+
+Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
+
+diff -Nur gcc-4.9.3.orig/libgcc/config/m68k/linux-atomic.c gcc-4.9.3/libgcc/config/m68k/linux-atomic.c
+--- gcc-4.9.3.orig/libgcc/config/m68k/linux-atomic.c 2014-01-02 23:25:22.000000000 +0100
++++ gcc-4.9.3/libgcc/config/m68k/linux-atomic.c 2016-03-18 22:24:40.000000000 +0100
+@@ -33,7 +33,6 @@
+ using the kernel helper defined below. There is no support for
+ 64-bit operations yet. */
+
+-#include <asm/unistd.h>
+ #include <stdbool.h>
+
+ #ifndef __NR_atomic_cmpxchg_32
diff --git a/patches/gcc/linaro-4.9-2017.01/891-fix-m68k-uclinux.patch b/patches/gcc/linaro-4.9-2017.01/891-fix-m68k-uclinux.patch
new file mode 100644
index 0000000..4347642
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/891-fix-m68k-uclinux.patch
@@ -0,0 +1,18 @@
+avoids internal compiler error while compiling linux-atomic.c
+See here:
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53833
+
+Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
+
+diff -Nur gcc-4.9.3.orig/libgcc/config.host gcc-4.9.3/libgcc/config.host
+--- gcc-4.9.3.orig/libgcc/config.host 2014-03-27 16:40:31.000000000 +0100
++++ gcc-4.9.3/libgcc/config.host 2016-04-05 16:20:53.422809885 +0200
+@@ -750,7 +750,7 @@
+ m68k*-*-openbsd*)
+ ;;
+ m68k-*-uclinux*) # Motorola m68k/ColdFire running uClinux with uClibc
+- tmake_file="$tmake_file m68k/t-floatlib m68k/t-linux"
++ tmake_file="$tmake_file m68k/t-floatlib"
+ md_unwind_header=m68k/linux-unwind.h
+ ;;
+ m68k-*-linux*) # Motorola m68k's running GNU/Linux
diff --git a/patches/gcc/linaro-4.9-2017.01/930-libgcc-disable-split-stack-nothreads.patch b/patches/gcc/linaro-4.9-2017.01/930-libgcc-disable-split-stack-nothreads.patch
new file mode 100644
index 0000000..670cf8d
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/930-libgcc-disable-split-stack-nothreads.patch
@@ -0,0 +1,14 @@
+disable split-stack for non-thread builds
+
+Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
+
+diff -Nur gcc-4.9.3.orig/libgcc/config/t-stack gcc-4.9.3/libgcc/config/t-stack
+--- gcc-4.9.3.orig/libgcc/config/t-stack 2010-10-01 21:31:49.000000000 +0200
++++ gcc-4.9.3/libgcc/config/t-stack 2016-03-07 01:34:32.000000000 +0100
+@@ -1,4 +1,6 @@
+ # Makefile fragment to provide generic support for -fsplit-stack.
+ # This should be used in config.host for any host which supports
+ # -fsplit-stack.
++ifeq ($(enable_threads),yes)
+ LIB2ADD_ST += $(srcdir)/generic-morestack.c $(srcdir)/generic-morestack-thread.c
++endif
diff --git a/patches/gcc/linaro-4.9-2017.01/940-uclinux-enable-threads.patch b/patches/gcc/linaro-4.9-2017.01/940-uclinux-enable-threads.patch
new file mode 100644
index 0000000..5108147
--- /dev/null
+++ b/patches/gcc/linaro-4.9-2017.01/940-uclinux-enable-threads.patch
@@ -0,0 +1,20 @@
+Enable POSIX threads for uClinux targets
+Reported upstream:
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71721
+
+Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
+
+Index: b/gcc/config.gcc
+===================================================================
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -810,6 +810,9 @@
+ *-*-uclinux*)
+ extra_options="$extra_options gnu-user.opt"
+ use_gcc_stdint=wrap
++ case ${enable_threads} in
++ "" | yes | posix) thread_file='posix' ;;
++ esac
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC SINGLE_LIBC"
+ ;;
+ *-*-rdos*)