Add aarch64 and arm fuchsia support in binutils and gcc.

Change-Id: I412df42e201e599a465a38c1c1be1ac08655a44b
diff --git a/patches/binutils-patch.txt b/patches/binutils-patch.txt
index 2d18df0..22251a4 100644
--- a/patches/binutils-patch.txt
+++ b/patches/binutils-patch.txt
@@ -186,3 +186,82 @@
   			targ_emul=elf_x86_64
   			targ_extra_emuls="elf_i386 elf_iamcu elf32_x86_64 elf_l1om elf_k1om"
   			targ_extra_libpath="elf_i386 elf_iamcu elf32_x86_64 elf_l1om elf_k1om"
+diff -rdcp binutils-2.27-orig/bfd/config.bfd binutils-2.27/bfd/config.bfd
+*** binutils-2.27-orig/bfd/config.bfd	2016-11-14 16:52:46.909843404 -0800
+--- binutils-2.27/bfd/config.bfd	2016-11-15 08:37:21.691710128 -0800
+*************** case "${targ}" in
+*** 192,197 ****
+--- 192,202 ----
+      targ_selvecs="aarch64_elf64_be_vec arm_elf32_le_vec arm_elf32_be_vec"
+      want64=true
+      ;;
++   aarch64-*-fuchsia*)
++     targ_defvec=aarch64_elf64_le_vec
++     targ_selvecs="aarch64_elf64_be_vec arm_elf32_le_vec arm_elf32_be_vec"
++     want64=true
++     ;;
+    aarch64-*-cloudabi*)
+      targ_defvec=aarch64_elf64_le_cloudabi_vec
+      targ_selvecs=aarch64_elf64_be_cloudabi_vec
+*************** case "${targ}" in
+*** 286,291 ****
+--- 291,300 ----
+      targ_selvecs="mach_o_le_vec mach_o_be_vec mach_o_fat_vec"
+      targ_archs="$targ_archs bfd_i386_arch bfd_powerpc_arch bfd_rs6000_arch"
+      ;;
++   arm-*-fuchsia*)
++     targ_defvec=arm_elf32_le_vec
++     targ_selvecs="arm_elf32_be_vec"
++     ;;
+    arm-*-nacl*)
+      targ_defvec=arm_elf32_nacl_le_vec
+      targ_selvecs="arm_elf32_nacl_be_vec i386_elf32_nacl_vec"
+diff -rdcp binutils-2.27-orig/gas/configure.tgt binutils-2.27/gas/configure.tgt
+*** binutils-2.27-orig/gas/configure.tgt	2016-11-14 16:52:47.073842705 -0800
+--- binutils-2.27/gas/configure.tgt	2016-11-15 08:39:07.799302559 -0800
+*************** generic_target=${cpu_type}-$vendor-$os
+*** 121,126 ****
+--- 121,127 ----
+  # Note: This table is alpha-sorted, please try to keep it that way.
+  case ${generic_target} in
+    aarch64*-*-elf | aarch64*-*-rtems*)	fmt=elf;;
++   aarch64*-*-fuchsia*)			fmt=elf;;
+    aarch64*-*-linux*)			fmt=elf em=linux ;;
+  
+    alpha-*-*vms*)			fmt=evax ;;
+*************** case ${generic_target} in
+*** 159,164 ****
+--- 160,166 ----
+  					fmt=coff em=wince-pe ;;
+    arm-*-pe)				fmt=coff em=pe ;;
+    arm-*-riscix*)			fmt=aout em=riscix ;;
++   arm-*-fuchsia*)			fmt=elf ;;
+  
+    avr-*-*)				fmt=elf bfd_gas=yes ;;
+  
+diff -rdcp binutils-2.27-orig/ld/configure.tgt binutils-2.27/ld/configure.tgt
+*** binutils-2.27-orig/ld/configure.tgt	2016-11-14 16:52:46.665844445 -0800
+--- binutils-2.27/ld/configure.tgt	2016-11-15 08:40:41.870942601 -0800
+*************** aarch64-*-cloudabi*)	targ_emul=aarch64cl
+*** 54,59 ****
+--- 54,61 ----
+  			targ_extra_emuls=aarch64cloudabib ;;
+  aarch64-*-freebsd*)	targ_emul=aarch64fbsd
+  			targ_extra_emuls="aarch64fbsdb aarch64elf" ;;
++ aarch64-*-fuchsia*)	targ_emul=aarch64elf
++ 			targ_extra_emuls="aarch64elfb armelf armelfb" ;;
+  aarch64_be-*-linux*)	targ_emul=aarch64linuxb
+  			targ_extra_libpath="aarch64linux aarch64linux32 aarch64linux32b armelfb_linux_eabi armelf_linux_eabi"
+  			targ_extra_emuls="aarch64elfb aarch64elf aarch64elf32 aarch64elf32b armelfb armelf $targ_extra_libpath" ;;
+*************** arm*-*-uclinux*)	targ_emul=armelf_linux
+*** 150,155 ****
+--- 152,160 ----
+  			;;
+  arm-*-vxworks)		targ_emul=armelf_vxworks ;;
+  arm*-*-conix*)		targ_emul=armelf ;;
++ arm*-*-fuchsia*)	targ_emul=armelf
++ 			targ_extra_emuls="armelfb"
++ 			;;
+  avr-*-*)		targ_emul=avr2
+  			targ_extra_emuls="avr1 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 avrxmega1 avrxmega2 avrxmega3 avrxmega4 avrxmega5 avrxmega6 avrxmega7 avrtiny"
+  			;;
diff --git a/patches/gcc-patch.txt b/patches/gcc-patch.txt
index 8319982..bd5c275 100644
--- a/patches/gcc-patch.txt
+++ b/patches/gcc-patch.txt
@@ -573,3 +573,106 @@
         _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         ;;
   
+diff -dcpr gcc-6.2.0-orig/gcc/config/fuchsia.h gcc-6.2.0/gcc/config/fuchsia.h
+*** gcc-6.2.0-orig/gcc/config/fuchsia.h	2016-11-14 16:41:03.688822073 -0800
+--- gcc-6.2.0/gcc/config/fuchsia.h	2016-11-15 15:41:41.047289495 -0800
+*************** along with GCC; see the file COPYING3.
+*** 47,49 ****
+--- 47,53 ----
+  		  "%{shared: -shared}" \
+  		  "%{!shared:%{!static:%{!dynamic-linker: -dynamic-linker=ld.so.1}}}"
+  
++ /* We are using MUSL as our libc.  */
++ #undef  OPTION_MUSL
++ #define OPTION_MUSL 1
++ 
+diff -dcpr gcc-6.2.0-orig/gcc/config.gcc gcc-6.2.0/gcc/config.gcc
+*** gcc-6.2.0-orig/gcc/config.gcc	2016-11-14 16:41:05.332815117 -0800
+--- gcc-6.2.0/gcc/config.gcc	2016-11-15 15:42:09.055176481 -0800
+*************** case ${target} in
+*** 907,913 ****
+  esac
+  
+  case ${target} in
+! aarch64*-*-elf | aarch64*-*-rtems*)
+  	tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h"
+  	tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-elf-raw.h"
+  	tmake_file="${tmake_file} aarch64/t-aarch64"
+--- 907,913 ----
+  esac
+  
+  case ${target} in
+! aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
+  	tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h"
+  	tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-elf-raw.h"
+  	tmake_file="${tmake_file} aarch64/t-aarch64"
+*************** aarch64*-*-elf | aarch64*-*-rtems*)
+*** 915,920 ****
+--- 915,923 ----
+  	aarch64-*-elf*)
+  		use_gcc_stdint=wrap
+  		;;
++         aarch64-*-fuchsia*)
++                 tm_file="${tm_file} fuchsia.h"
++                 ;;
+  	aarch64-*-rtems*)
+  	  	tm_file="${tm_file} rtems.h aarch64/rtems.h"
+  		;;
+*************** arm*-*-uclinux*eabi*)		# ARM ucLinux
+*** 1097,1103 ****
+  	# The EABI requires the use of __cxa_atexit.
+  	default_use_cxa_atexit=yes
+  	;;
+! arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
+  	case ${target} in
+  	arm*eb-*-eabi*)
+  	  tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
+--- 1100,1106 ----
+  	# The EABI requires the use of __cxa_atexit.
+  	default_use_cxa_atexit=yes
+  	;;
+! arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems* | arm*-*-fuchsia*)
+  	case ${target} in
+  	arm*eb-*-eabi*)
+  	  tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
+*************** arm*-*-eabi* | arm*-*-symbianelf* | arm*
+*** 1111,1116 ****
+--- 1114,1122 ----
+  	  tmake_file="${tmake_file} arm/t-bpabi"
+  	  use_gcc_stdint=wrap
+  	  ;;
++ 	arm*-*-fuchsia*)
++ 	  tm_file="${tm_file} fuchsia.h glibc-stdint.h"
++ 	  ;;
+  	arm*-*-rtems*)
+  	  tm_file="${tm_file} rtems.h arm/rtems.h newlib-stdint.h"
+  	  tmake_file="${tmake_file} arm/t-bpabi arm/t-rtems"
+diff -dcpr gcc-6.2.0-orig/libgcc/config.host gcc-6.2.0/libgcc/config.host
+*** gcc-6.2.0-orig/libgcc/config.host	2016-11-14 16:41:05.536814253 -0800
+--- gcc-6.2.0/libgcc/config.host	2016-11-15 08:48:35.813137073 -0800
+*************** aarch64*-*-elf | aarch64*-*-rtems*)
+*** 336,341 ****
+--- 336,345 ----
+  	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+  	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
+  	;;
++ aarch64*-*-fuchsia*)
++ 	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
++ 	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp"
++ 	;;
+  aarch64*-*-linux*)
+  	extra_parts="$extra_parts crtfastmath.o"
+  	md_unwind_header=aarch64/linux-unwind.h
+*************** arm*-*-freebsd*)                # ARM Fr
+*** 386,391 ****
+--- 390,399 ----
+  	unwind_header=config/arm/unwind-arm.h
+  	tmake_file="${tmake_file} t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp"
+  	;;
++ arm*-*-fuchsia*)
++ 	tmake_file="${tmake_file} arm/t-arm arm/t-elf"
++ 	tmake_file="${tmake_file} arm/tsoftfp t-softfp"
++ 	;;
+  arm*-*-netbsdelf*)
+  	tmake_file="$tmake_file arm/t-arm arm/t-netbsd t-slibgcc-gld-nover"
+  	;;