aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--toolchain/gcc/Config.in5
-rw-r--r--toolchain/gcc/Config.version3
-rw-r--r--toolchain/gcc/common.mk22
-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
40 files changed, 0 insertions, 1610 deletions
diff --git a/toolchain/gcc/Config.in b/toolchain/gcc/Config.in
index a8c39d6a09..def296f01e 100644
--- a/toolchain/gcc/Config.in
+++ b/toolchain/gcc/Config.in
@@ -7,11 +7,6 @@ choice
help
Select the version of gcc you wish to use.
- config GCC_USE_VERSION_4_8_LINARO
- select GCC_VERSION_4_8_LINARO
- bool "gcc 4.8.x with Linaro enhancements"
- depends on !arc
-
config GCC_USE_VERSION_4_8_ARC
select GCC_VERSION_4_8_ARC
bool "gcc 4.8.x with support of ARC cores"
diff --git a/toolchain/gcc/Config.version b/toolchain/gcc/Config.version
index efd8dc026d..808c0c282c 100644
--- a/toolchain/gcc/Config.version
+++ b/toolchain/gcc/Config.version
@@ -1,6 +1,3 @@
-config GCC_VERSION_4_8_LINARO
- bool
-
config GCC_VERSION_4_8_ARC
default y if (!TOOLCHAINOPTS && arc)
bool
diff --git a/toolchain/gcc/common.mk b/toolchain/gcc/common.mk
index 648cd2d5ad..2912f8f612 100644
--- a/toolchain/gcc/common.mk
+++ b/toolchain/gcc/common.mk
@@ -28,32 +28,10 @@ GCC_DIR:=$(PKG_NAME)-$(PKG_VERSION)
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
-ifeq ($(findstring linaro, $(CONFIG_GCC_VERSION)),linaro)
- LINARO_RELEASE:=
- 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)
-endif
-
ifneq ($(CONFIG_GCC_VERSION_4_8_ARC),)
PKG_VERSION:=4.8.4
PKG_SOURCE_URL:=https://github.com/foss-for-synopsys-dwc-arc-processors/gcc/archive/arc-2015.06
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
deleted file mode 100644
index 162d651394..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/001-revert_register_mode_search.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-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
deleted file mode 100644
index a740b4ce9e..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/002-weak_data_fix.patch
+++ /dev/null
@@ -1,42 +0,0 @@
---- /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
deleted file mode 100644
index 1b9a5b3081..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/003-universal_initializer.patch
+++ /dev/null
@@ -1,94 +0,0 @@
---- 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
deleted file mode 100644
index b3d2dbe291..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/004-case_insensitive.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- 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
deleted file mode 100644
index 5548069d1b..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/010-documentation.patch
+++ /dev/null
@@ -1,23 +0,0 @@
---- 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
deleted file mode 100644
index b225376865..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/020-no-plt-backport.patch
+++ /dev/null
@@ -1,28 +0,0 @@
---- 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
deleted file mode 100644
index ff9ad94f62..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/100-uclibc-conf.patch
+++ /dev/null
@@ -1,33 +0,0 @@
---- 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
deleted file mode 100644
index 0142745c83..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/200-musl_config.patch
+++ /dev/null
@@ -1,204 +0,0 @@
---- 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
deleted file mode 100644
index f39ff52468..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/201-musl_arm.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- 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
deleted file mode 100644
index 42a2648f02..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/202-musl_mips.patch
+++ /dev/null
@@ -1,13 +0,0 @@
---- 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
deleted file mode 100644
index 61e94be6c3..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/203-musl_powerpc.patch
+++ /dev/null
@@ -1,100 +0,0 @@
---- 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
deleted file mode 100644
index 9a50c227e8..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/204-musl_sh.patch
+++ /dev/null
@@ -1,17 +0,0 @@
---- 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
deleted file mode 100644
index 9a25113319..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/205-musl_x86.patch
+++ /dev/null
@@ -1,48 +0,0 @@
---- 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
deleted file mode 100644
index 9d75dc9493..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/206-musl_aarch64.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- 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
deleted file mode 100644
index e6fa47f7e6..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/207-musl_fixincludes.patch
+++ /dev/null
@@ -1,12 +0,0 @@
---- 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
deleted file mode 100644
index 84c781ee7d..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/208-musl_gomp.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- 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
deleted file mode 100644
index 6643935b18..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/209-musl_libstdc++.patch
+++ /dev/null
@@ -1,26 +0,0 @@
---- 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
deleted file mode 100644
index 56084692a1..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/210-disable_libsanitizer_off_t_check.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- 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
deleted file mode 100644
index b86adf59b9..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/220-musl_mips_softfloat.patch
+++ /dev/null
@@ -1,8 +0,0 @@
---- 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
deleted file mode 100644
index 7447dbd307..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/221-musl_mips64.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-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
deleted file mode 100644
index 22176934af..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/230-musl_libssp.patch
+++ /dev/null
@@ -1,13 +0,0 @@
---- 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
deleted file mode 100644
index efa9789c67..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/800-arm_v5te_no_ldrd_strd.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- 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
deleted file mode 100644
index 33cf8add30..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/810-arm-softfloat-libgcc.patch
+++ /dev/null
@@ -1,25 +0,0 @@
---- 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
deleted file mode 100644
index 7a0ac7353e..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/820-libgcc_pic.patch
+++ /dev/null
@@ -1,36 +0,0 @@
---- 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
deleted file mode 100644
index 37f8f2a54d..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/830-arm_unbreak_armv4t.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-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
deleted file mode 100644
index 2283b83c5f..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/840-armv4_pass_fix-v4bx_to_ld.patch
+++ /dev/null
@@ -1,19 +0,0 @@
---- 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
deleted file mode 100644
index 6934bc97f6..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/850-use_shared_libgcc.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- 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
deleted file mode 100644
index 80c3476841..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/851-libgcc_no_compat.patch
+++ /dev/null
@@ -1,12 +0,0 @@
---- 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
deleted file mode 100644
index 1ac83fe4dc..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/860-use_eh_frame.patch
+++ /dev/null
@@ -1,42 +0,0 @@
---- 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
deleted file mode 100644
index 4b7fcbd5e1..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/870-ppc_no_crtsavres.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- 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
deleted file mode 100644
index def6c9f4a0..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/880-no_java_section.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- 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
deleted file mode 100644
index dd6e9dc889..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/900-bad-mips16-crt.patch
+++ /dev/null
@@ -1,9 +0,0 @@
---- 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
deleted file mode 100644
index 5387f8e86f..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/910-mbsd_multi.patch
+++ /dev/null
@@ -1,253 +0,0 @@
-
- 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
deleted file mode 100644
index 09768f525b..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/920-specs_nonfatal_getenv.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- 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
deleted file mode 100644
index e72ed3a4cf..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/930-fix-mips-noexecstack.patch
+++ /dev/null
@@ -1,111 +0,0 @@
-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
deleted file mode 100644
index dbecef2d57..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/940-no-clobber-stamp-bits.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- 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
deleted file mode 100644
index f487dbc8ff..0000000000
--- a/toolchain/gcc/patches/4.8-linaro/951-arm_bug_58595.patch
+++ /dev/null
@@ -1,117 +0,0 @@
-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