Merge "build-host-gdb.sh: New script"
diff --git a/build/tools/build-host-gcc.sh b/build/tools/build-host-gcc.sh
index a67b2e5..6b16c94 100755
--- a/build/tools/build-host-gcc.sh
+++ b/build/tools/build-host-gcc.sh
@@ -721,7 +721,7 @@
                         dump ""
                         exit 1
                     fi
-                    local DARWINMINVER=$(darwin_arch_to_version_min $2)
+                    local DARWINMINVER=$(darwin_arch_to_min_version $2)
                     check_darwin_sdk $DARWIN_SYSROOT $DARWINARCH
                     try_host_prefix "$DARWIN_TOOLCHAIN" -m$(tag_to_bits $1) --sysroot "$DARWIN_SYSROOT"
                     if [ -z "$HOST_FULLPREFIX" ]; then
diff --git a/build/tools/dev-defaults.sh b/build/tools/dev-defaults.sh
index ce5cf33..4a3cd50 100644
--- a/build/tools/dev-defaults.sh
+++ b/build/tools/dev-defaults.sh
@@ -23,7 +23,7 @@
 
 # The date to use when downloading toolchain sources from AOSP servers
 # Leave it empty for tip of tree.
-TOOLCHAIN_GIT_DATE=2012-05-17
+TOOLCHAIN_GIT_DATE=2012-06-10
 
 # The space-separated list of all GCC versions we support in this NDK
 DEFAULT_GCC_VERSION_LIST="4.4.3"
diff --git a/build/tools/dev-rebuild-ndk.sh b/build/tools/dev-rebuild-ndk.sh
index 7d26941..24fe139 100755
--- a/build/tools/dev-rebuild-ndk.sh
+++ b/build/tools/dev-rebuild-ndk.sh
@@ -33,7 +33,7 @@
 
 
 # Name of this NDK release
-OPTION_NDK_RELEASE="r6x-eng"
+OPTION_NDK_RELEASE=`date +%Y%m%d`
 register_var_option "--release=<rel_name>" OPTION_NDK_RELEASE "Version of release"
 
 # Should we only Build for Linux platform?
diff --git a/build/tools/toolchain-patches/binutils/0001-Fix-ld-gc-sections.patch b/build/tools/toolchain-patches/binutils/0001-Fix-ld-gc-sections.patch
new file mode 100644
index 0000000..cbb7284
--- /dev/null
+++ b/build/tools/toolchain-patches/binutils/0001-Fix-ld-gc-sections.patch
@@ -0,0 +1,14 @@
+diff --git a/binutils-2.21/bfd/elflink.c b/binutils-2.21/bfd/elflink.c
+index 51dae66..753bb9c 100644
+--- a/binutils-2.21/bfd/elflink.c
++++ b/binutils-2.21/bfd/elflink.c
+@@ -11575,6 +11575,9 @@ struct elf_gc_sweep_symbol_info
+ static bfd_boolean
+ elf_gc_sweep_symbol (struct elf_link_hash_entry *h, void *data)
+ {
++  if (h->root.type == bfd_link_hash_warning)
++    h = (struct elf_link_hash_entry *) h->root.u.i.link;
++
+   if (!h->mark
+       && (((h->root.type == bfd_link_hash_defined
+             || h->root.type == bfd_link_hash_defweak)
diff --git a/build/tools/toolchain-patches/binutils/0001-Modify-linker-script-generation-for-MIPS-Android.patch b/build/tools/toolchain-patches/binutils/0001-Modify-linker-script-generation-for-MIPS-Android.patch
index b00fbc5..8473397 100644
--- a/build/tools/toolchain-patches/binutils/0001-Modify-linker-script-generation-for-MIPS-Android.patch
+++ b/build/tools/toolchain-patches/binutils/0001-Modify-linker-script-generation-for-MIPS-Android.patch
@@ -1,13 +1,14 @@
-From f58e4d63fccf86db7cf36e956ab3a7ce6492b4cf Mon Sep 17 00:00:00 2001
+From 674fa6037621df8bc2d900406ec151d6a437c071 Mon Sep 17 00:00:00 2001
 From: Chao-ying Fu <fu@mips.com>
-Date: Thu, 5 Apr 2012 16:30:13 -0700
+Date: Mon, 11 Jun 2012 11:14:39 -0700
 Subject: [PATCH] Modify linker script generation for MIPS Android.
 
 ---
- binutils-2.21/ld/emulparams/elf32bmip.sh |    8 +----
- binutils-2.21/ld/genscripts.sh           |    5 ++-
- binutils-2.21/ld/scripttempl/elf.sc      |   55 +++++++++++++++++------------
- 3 files changed, 37 insertions(+), 31 deletions(-)
+ binutils-2.21/ld/emulparams/elf32bmip.sh   |    8 +----
+ binutils-2.21/ld/emulparams/elf32ltsmip.sh |    1 +
+ binutils-2.21/ld/genscripts.sh             |    5 ++-
+ binutils-2.21/ld/scripttempl/elf.sc        |   54 +++++++++++++++++-----------
+ 4 files changed, 39 insertions(+), 29 deletions(-)
 
 diff --git a/binutils-2.21/ld/emulparams/elf32bmip.sh b/binutils-2.21/ld/emulparams/elf32bmip.sh
 index 44a0b8a..8dae1bb 100644
@@ -35,6 +36,14 @@
    .gcc_compiled_long32 : { KEEP(*(.gcc_compiled_long32)) }
    .gcc_compiled_long64 : { KEEP(*(.gcc_compiled_long64)) }
  '
+diff --git a/binutils-2.21/ld/emulparams/elf32ltsmip.sh b/binutils-2.21/ld/emulparams/elf32ltsmip.sh
+index 4a660f0..edf73df 100644
+--- a/binutils-2.21/ld/emulparams/elf32ltsmip.sh
++++ b/binutils-2.21/ld/emulparams/elf32ltsmip.sh
+@@ -1,2 +1,3 @@
+ . ${srcdir}/emulparams/elf32btsmip.sh
+ OUTPUT_FORMAT="elf32-tradlittlemips"
++unset TEXT_DYNAMIC
 diff --git a/binutils-2.21/ld/genscripts.sh b/binutils-2.21/ld/genscripts.sh
 index c86631b..d54d85d 100755
 --- a/binutils-2.21/ld/genscripts.sh
@@ -66,10 +75,21 @@
        . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
      ) | sed -e '/^ *$/d;s/[ 	]*$//' > ldscripts/${EMULATION_NAME}.xsc
 diff --git a/binutils-2.21/ld/scripttempl/elf.sc b/binutils-2.21/ld/scripttempl/elf.sc
-index f020a66..142315c 100644
+index f020a66..0fcc22d 100644
 --- a/binutils-2.21/ld/scripttempl/elf.sc
 +++ b/binutils-2.21/ld/scripttempl/elf.sc
-@@ -149,7 +149,7 @@ RELA_IPLT=".rela.iplt    ${RELOCATING-0} :
+@@ -111,7 +111,9 @@ DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
+ DATA_SEGMENT_RELRO_END=""
+ DATA_SEGMENT_END=""
+ if test -n "${COMMONPAGESIZE}"; then
+-  DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
++  #DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
++  # For Android, we align at exactly a page boundary.
++  DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
+   DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
+   DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
+ fi
+@@ -149,7 +151,7 @@ RELA_IPLT=".rela.iplt    ${RELOCATING-0} :
  DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
  RODATA=".${RODATA_NAME}       ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
  DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }"
@@ -78,7 +98,7 @@
  if test -z "${NO_SMALL_DATA}"; then
    SBSS=".${SBSS_NAME}         ${RELOCATING-0} :
    {
-@@ -224,17 +224,15 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
+@@ -224,17 +226,15 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
    }"
  INIT_ARRAY=".init_array   ${RELOCATING-0} :
    {
@@ -98,7 +118,7 @@
    }"
  CTOR=".ctors        ${CONSTRUCTING-0} : 
    {
-@@ -250,14 +248,14 @@ CTOR=".ctors        ${CONSTRUCTING-0} :
+@@ -250,14 +250,14 @@ CTOR=".ctors        ${CONSTRUCTING-0} :
         is in.  */
  
      KEEP (*crtbegin.o(.ctors))
@@ -115,7 +135,7 @@
      KEEP (*(SORT(.ctors.*)))
      KEEP (*(.ctors))
      ${CONSTRUCTING+${CTOR_END}}
-@@ -266,8 +264,8 @@ DTOR=".dtors        ${CONSTRUCTING-0} :
+@@ -266,8 +266,8 @@ DTOR=".dtors        ${CONSTRUCTING-0} :
    {
      ${CONSTRUCTING+${DTOR_START}}
      KEEP (*crtbegin.o(.dtors))
@@ -126,7 +146,7 @@
      KEEP (*(SORT(.dtors.*)))
      KEEP (*(.dtors))
      ${CONSTRUCTING+${DTOR_END}}
-@@ -278,8 +276,11 @@ STACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
+@@ -278,8 +278,11 @@ STACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
      *(.stack)
    }"
  
@@ -140,23 +160,18 @@
  
  # if this is for an embedded system, don't add SIZEOF_HEADERS.
  if [ -z "$EMBEDDED" ]; then
-@@ -459,11 +460,10 @@ cat <<EOF
+@@ -459,8 +462,8 @@ cat <<EOF
    .eh_frame     ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
    .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
  
 -  /* Adjust the address for the data segment.  We want to adjust up to
 -     the same address within the page on the next page up.  */
--  ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
--  ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
--  ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
 +  /* Adjust the address for the data segment.  We want to align at exactly
 +     a page boundary to make life easier for apriori. */
-+  . = ALIGN(4096);
-+  . = DATA_SEGMENT_ALIGN(4096,4096);
- 
-   /* Exception handling  */
-   .eh_frame     ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
-@@ -473,14 +473,23 @@ cat <<EOF
+   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
+   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
+   ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
+@@ -473,14 +476,23 @@ cat <<EOF
    .tdata	${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
    .tbss		${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
  
@@ -182,7 +197,7 @@
    ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
    ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
    .jcr          ${RELOCATING-0} : { KEEP (*(.jcr)) }
-@@ -526,10 +535,8 @@ cat <<EOF
+@@ -526,10 +538,8 @@ cat <<EOF
     *(COMMON)
     /* Align here to ensure that the .bss section occupies space up to
        _end.  Align after .bss to ensure correct alignment even if the
@@ -195,7 +210,7 @@
    }
    ${OTHER_BSS_SECTIONS}
    ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
-@@ -537,7 +544,9 @@ cat <<EOF
+@@ -537,7 +547,9 @@ cat <<EOF
    ${LARGE_SECTIONS}
    ${RELOCATING+. = ALIGN(${ALIGNMENT});}
    ${RELOCATING+${OTHER_END_SYMBOLS}}
diff --git a/build/tools/toolchain-patches/build/0001-Options-brought-in-from-core-combo-for-IA.patch b/build/tools/toolchain-patches/build/0001-Options-brought-in-from-core-combo-for-IA.patch
index 212633c..e1b0438 100644
--- a/build/tools/toolchain-patches/build/0001-Options-brought-in-from-core-combo-for-IA.patch
+++ b/build/tools/toolchain-patches/build/0001-Options-brought-in-from-core-combo-for-IA.patch
@@ -11,7 +11,7 @@
 index 0b73ff6..c7b5847 100644
 --- a/Makefile.in
 +++ b/Makefile.in
-@@ -434,6 +434,35 @@ GCC_CONFIG_ARGS += $(GCC_CONFIG_LIBSTDCXX_V3) --disable-libssp \
+@@ -441,6 +441,35 @@ GCC_CONFIG_ARGS += $(GCC_CONFIG_LIBSTDCXX_V3) --disable-libssp \
  	--disable-tls --disable-libitm
  
  CFLAGS_FOR_TARGET += -DTARGET_POSIX_IO -fno-short-enums
diff --git a/build/tools/toolchain-patches/gdb/0001-ndk-Disable-usage-logging-for-Windows.patch b/build/tools/toolchain-patches/gdb/0005-Disable-usage-logging-for-Windows.patch
similarity index 79%
rename from build/tools/toolchain-patches/gdb/0001-ndk-Disable-usage-logging-for-Windows.patch
rename to build/tools/toolchain-patches/gdb/0005-Disable-usage-logging-for-Windows.patch
index 5e0ed3e..1e42f34 100644
--- a/build/tools/toolchain-patches/gdb/0001-ndk-Disable-usage-logging-for-Windows.patch
+++ b/build/tools/toolchain-patches/gdb/0005-Disable-usage-logging-for-Windows.patch
@@ -1,3 +1,14 @@
+From 8048f512bb7432795642a92948964131b47e70c0 Mon Sep 17 00:00:00 2001
+From: David 'Digit' Turner <digit@android.com>
+Date: Mon, 11 Jun 2012 13:41:52 +0200
+Subject: Disable usage logging for Windows
+
+Change-Id: Idb72bbb9e00fd200c43e458283bead7233394484
+---
+ gdb-7.3.x/gdb/usage-logging.c |   28 ++++++++++++++++++++++++++++
+ gdb-7.3.x/gdb/utils.c         |    2 ++
+ 2 files changed, 30 insertions(+), 0 deletions(-)
+
 diff --git a/gdb-7.3.x/gdb/usage-logging.c b/gdb-7.3.x/gdb/usage-logging.c
 index 76938ab..65981aa 100644
 --- a/gdb-7.3.x/gdb/usage-logging.c
@@ -62,3 +73,6 @@
      }
    /* END GOOGLE LOCAL */
  }
+-- 
+1.7.6.rc0
+
diff --git a/build/tools/toolchain-patches/gdb/0006-Fix-mingw64-builds.patch b/build/tools/toolchain-patches/gdb/0006-Fix-mingw64-builds.patch
new file mode 100644
index 0000000..e99c7ff
--- /dev/null
+++ b/build/tools/toolchain-patches/gdb/0006-Fix-mingw64-builds.patch
@@ -0,0 +1,54 @@
+From a90f871b4a8df23bbd7236308f26e55910588862 Mon Sep 17 00:00:00 2001
+From: David 'Digit' Turner <digit@android.com>
+Date: Mon, 11 Jun 2012 13:38:29 +0200
+Subject: Fix mingw64 builds
+
+This patch fixes the GDB client builds when using the mingw64 toolchain
+on Linux to generate Windows binaries.
+
+Change-Id: Ie8bd21b50d9c99a90deed93a4d13df835ef7e0b9
+---
+ gdb-6.6/gdb/ser-mingw.c   |    1 +
+ gdb-7.1.x/gdb/ser-mingw.c |    1 +
+ gdb-7.3.x/gdb/ser-mingw.c |    1 +
+ 3 files changed, 3 insertions(+), 0 deletions(-)
+
+diff --git a/gdb-6.6/gdb/ser-mingw.c b/gdb-6.6/gdb/ser-mingw.c
+index c0e124175e6051234f3dd4a50fc5a0b44067362..0b6ef55 100644
+--- a/gdb-6.6/gdb/ser-mingw.c
++++ b/gdb-6.6/gdb/ser-mingw.c
+@@ -25,6 +25,7 @@
+ #include "ser-base.h"
+ #include "ser-tcp.h"
+ 
++#include <winsock2.h>
+ #include <windows.h>
+ #include <conio.h>
+ 
+diff --git a/gdb-7.1.x/gdb/ser-mingw.c b/gdb-7.1.x/gdb/ser-mingw.c
+index af68c2b..1128a6d 100644
+--- a/gdb-7.1.x/gdb/ser-mingw.c
++++ b/gdb-7.1.x/gdb/ser-mingw.c
+@@ -22,6 +22,7 @@
+ #include "ser-base.h"
+ #include "ser-tcp.h"
+ 
++#include <winsock2.h>
+ #include <windows.h>
+ #include <conio.h>
+ 
+diff --git a/gdb-7.3.x/gdb/ser-mingw.c b/gdb-7.3.x/gdb/ser-mingw.c
+index b362878..eee3198 100644
+--- a/gdb-7.3.x/gdb/ser-mingw.c
++++ b/gdb-7.3.x/gdb/ser-mingw.c
+@@ -23,6 +23,7 @@
+ #include "ser-base.h"
+ #include "ser-tcp.h"
+ 
++#include <winsock2.h>
+ #include <windows.h>
+ #include <conio.h>
+ 
+-- 
+1.7.6.rc0
+
diff --git a/docs/ANDROID-MK.html b/docs/ANDROID-MK.html
index 9e36f1c..3fe0d04 100644
--- a/docs/ANDROID-MK.html
+++ b/docs/ANDROID-MK.html
@@ -620,7 +620,7 @@
 
 LOCAL_DISABLE_RELRO
     By default, NDK compiled code is built with read-only relocations
-    and GOT protection.  This instruct the runtime linker to mark
+    and GOT protection.  This instructs the runtime linker to mark
     certain regions of memory as being read-only after relocation,
     making certain security exploits (such as GOT overwrites) harder
     to perform.
diff --git a/toolchains/arm-linux-androideabi-4.4.3/config.mk b/toolchains/arm-linux-androideabi-4.4.3/config.mk
index 604bf78..2547cd4 100644
--- a/toolchains/arm-linux-androideabi-4.4.3/config.mk
+++ b/toolchains/arm-linux-androideabi-4.4.3/config.mk
@@ -13,7 +13,7 @@
 # limitations under the License.
 #
 
-# config file for the arm-eabi-4.4.0 toolchain for the Android NDK
+# config file for the arm gcc-4.4.3 toolchain for the Android NDK
 # the real meat is in the setup.mk file adjacent to this one
 #
 TOOLCHAIN_ARCH := arm
diff --git a/toolchains/arm-linux-androideabi-4.4.3/setup.mk b/toolchains/arm-linux-androideabi-4.4.3/setup.mk
index 5511a8c..45a0109 100644
--- a/toolchains/arm-linux-androideabi-4.4.3/setup.mk
+++ b/toolchains/arm-linux-androideabi-4.4.3/setup.mk
@@ -13,7 +13,7 @@
 # limitations under the License.
 #
 
-# this file is used to prepare the NDK to build with the arm-eabi-4.4.0
+# this file is used to prepare the NDK to build with the arm gcc-4.4.3
 # toolchain any number of source files
 #
 # its purpose is to define (or re-define) templates used to build
diff --git a/toolchains/arm-linux-androideabi-4.6/config.mk b/toolchains/arm-linux-androideabi-4.6/config.mk
new file mode 100644
index 0000000..23b3025
--- /dev/null
+++ b/toolchains/arm-linux-androideabi-4.6/config.mk
@@ -0,0 +1,20 @@
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# config file for the arm gcc-4.6 toolchain for the Android NDK
+# the real meat is in the setup.mk file adjacent to this one
+#
+TOOLCHAIN_ARCH := arm
+TOOLCHAIN_ABIS := armeabi armeabi-v7a
diff --git a/toolchains/arm-linux-androideabi-4.6/setup.mk b/toolchains/arm-linux-androideabi-4.6/setup.mk
new file mode 100644
index 0000000..02073ed
--- /dev/null
+++ b/toolchains/arm-linux-androideabi-4.6/setup.mk
@@ -0,0 +1,132 @@
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# this file is used to prepare the NDK to build with the arm gcc-4.6
+# toolchain any number of source files
+#
+# its purpose is to define (or re-define) templates used to build
+# various sources into target object files, libraries or executables.
+#
+# Note that this file may end up being parsed several times in future
+# revisions of the NDK.
+#
+
+TARGET_CFLAGS := \
+    -fpic \
+    -ffunction-sections \
+    -funwind-tables \
+    -fstack-protector \
+    -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ \
+    -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \
+
+TARGET_LDFLAGS :=
+
+TARGET_C_INCLUDES := \
+    $(SYSROOT)/usr/include
+
+ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
+    TARGET_CFLAGS += -march=armv7-a \
+                     -mfloat-abi=softfp \
+                     -mfpu=vfp
+
+    TARGET_LDFLAGS += -Wl,--fix-cortex-a8
+else
+    TARGET_CFLAGS += -march=armv5te \
+                            -mtune=xscale \
+                            -msoft-float
+endif
+
+TARGET_CFLAGS.neon := -mfpu=neon
+
+TARGET_arm_release_CFLAGS :=  -O2 \
+                              -fomit-frame-pointer \
+                              -fstrict-aliasing    \
+                              -funswitch-loops     \
+                              -finline-limit=300
+
+TARGET_thumb_release_CFLAGS := -mthumb \
+                               -Os \
+                               -fomit-frame-pointer \
+                               -fno-strict-aliasing \
+                               -finline-limit=64
+
+# When building for debug, compile everything as arm.
+TARGET_arm_debug_CFLAGS := $(TARGET_arm_release_CFLAGS) \
+                           -fno-omit-frame-pointer \
+                           -fno-strict-aliasing
+
+TARGET_thumb_debug_CFLAGS := $(TARGET_thumb_release_CFLAGS) \
+                             -marm \
+                             -fno-omit-frame-pointer
+
+# This function will be called to determine the target CFLAGS used to build
+# a C or Assembler source file, based on its tags.
+#
+TARGET-process-src-files-tags = \
+$(eval __arm_sources := $(call get-src-files-with-tag,arm)) \
+$(eval __thumb_sources := $(call get-src-files-without-tag,arm)) \
+$(eval __debug_sources := $(call get-src-files-with-tag,debug)) \
+$(eval __release_sources := $(call get-src-files-without-tag,debug)) \
+$(call set-src-files-target-cflags, \
+    $(call set_intersection,$(__arm_sources),$(__debug_sources)), \
+    $(TARGET_arm_debug_CFLAGS)) \
+$(call set-src-files-target-cflags,\
+    $(call set_intersection,$(__arm_sources),$(__release_sources)),\
+    $(TARGET_arm_release_CFLAGS)) \
+$(call set-src-files-target-cflags,\
+    $(call set_intersection,$(__arm_sources),$(__debug_sources)),\
+    $(TARGET_arm_debug_CFLAGS)) \
+$(call set-src-files-target-cflags,\
+    $(call set_intersection,$(__thumb_sources),$(__release_sources)),\
+    $(TARGET_thumb_release_CFLAGS)) \
+$(call set-src-files-target-cflags,\
+    $(call set_intersection,$(__thumb_sources),$(__debug_sources)),\
+    $(TARGET_thumb_debug_CFLAGS)) \
+$(call add-src-files-target-cflags,\
+    $(call get-src-files-with-tag,neon),\
+    $(TARGET_CFLAGS.neon)) \
+$(call set-src-files-text,$(__arm_sources),arm$(space)$(space)) \
+$(call set-src-files-text,$(__thumb_sources),thumb)
+
+#
+# We need to add -lsupc++ to the final link command to make exceptions
+# and RTTI work properly (when -fexceptions and -frtti are used).
+#
+# Normally, the toolchain should be configured to do that automatically,
+# this will be debugged later.
+#
+define cmd-build-shared-library
+$(PRIVATE_CXX) \
+    $(PRIVATE_LDSCRIPT_XSC) \
+    -Wl,-soname,$(notdir $@) \
+    -shared \
+    --sysroot=$(call host-path,$(PRIVATE_SYSROOT)) \
+    $(PRIVATE_LINKER_OBJECTS_AND_LIBRARIES) \
+    $(PRIVATE_LDFLAGS) \
+    $(PRIVATE_LDLIBS) \
+    -o $(call host-path,$@)
+endef
+
+define cmd-build-executable
+$(PRIVATE_CXX) \
+    $(PRIVATE_LDSCRIPT_X) \
+    -Wl,--gc-sections \
+    -Wl,-z,nocopyreloc \
+    --sysroot=$(call host-path,$(PRIVATE_SYSROOT)) \
+    $(PRIVATE_LINKER_OBJECTS_AND_LIBRARIES) \
+    $(PRIVATE_LDFLAGS) \
+    $(PRIVATE_LDLIBS) \
+    -o $(call host-path,$@)
+endef
diff --git a/toolchains/mipsel-linux-android-4.4.3/config.mk b/toolchains/mipsel-linux-android-4.4.3/config.mk
index ae26c0a..b4dbc32 100644
--- a/toolchains/mipsel-linux-android-4.4.3/config.mk
+++ b/toolchains/mipsel-linux-android-4.4.3/config.mk
@@ -13,7 +13,7 @@
 # limitations under the License.
 #
 
-# config file for the mipsel 4.4.3 toolchain for the Android NDK
+# config file for the mipsel gcc-4.4.3 toolchain for the Android NDK
 # the real meat is in the setup.mk file adjacent to this one
 #
 TOOLCHAIN_ARCH := mips
diff --git a/toolchains/mipsel-linux-android-4.4.3/setup.mk b/toolchains/mipsel-linux-android-4.4.3/setup.mk
index 0e8f14e..1773340 100644
--- a/toolchains/mipsel-linux-android-4.4.3/setup.mk
+++ b/toolchains/mipsel-linux-android-4.4.3/setup.mk
@@ -13,7 +13,7 @@
 # limitations under the License.
 #
 
-# this file is used to prepare the NDK to build with the mipsel 4.4.3
+# this file is used to prepare the NDK to build with the mipsel gcc-4.4.3
 # toolchain any number of source files
 #
 # its purpose is to define (or re-define) templates used to build
diff --git a/toolchains/mipsel-linux-android-4.6/config.mk b/toolchains/mipsel-linux-android-4.6/config.mk
new file mode 100644
index 0000000..779e968
--- /dev/null
+++ b/toolchains/mipsel-linux-android-4.6/config.mk
@@ -0,0 +1,20 @@
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# config file for the mipsel gcc-4.6 toolchain for the Android NDK
+# the real meat is in the setup.mk file adjacent to this one
+#
+TOOLCHAIN_ARCH := mips
+TOOLCHAIN_ABIS := mips
diff --git a/toolchains/mipsel-linux-android-4.6/setup.mk b/toolchains/mipsel-linux-android-4.6/setup.mk
new file mode 100644
index 0000000..cb91fd0
--- /dev/null
+++ b/toolchains/mipsel-linux-android-4.6/setup.mk
@@ -0,0 +1,93 @@
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# this file is used to prepare the NDK to build with the mipsel gcc-4.6
+# toolchain any number of source files
+#
+# its purpose is to define (or re-define) templates used to build
+# various sources into target object files, libraries or executables.
+#
+# Note that this file may end up being parsed several times in future
+# revisions of the NDK.
+#
+
+TARGET_CFLAGS := \
+        -fpic \
+        -fno-strict-aliasing \
+        -finline-functions \
+        -ffunction-sections \
+        -funwind-tables \
+        -fmessage-length=0 \
+        -fno-inline-functions-called-once \
+        -fgcse-after-reload \
+        -frerun-cse-after-loop \
+        -frename-registers \
+
+TARGET_LDFLAGS :=
+
+TARGET_C_INCLUDES := \
+    $(SYSROOT)/usr/include
+
+TARGET_mips_release_CFLAGS :=  -O2 \
+                               -fomit-frame-pointer \
+                               -funswitch-loops     \
+                               -finline-limit=300
+
+TARGET_mips_debug_CFLAGS := -O0 -g \
+                            -fno-omit-frame-pointer
+
+
+# This function will be called to determine the target CFLAGS used to build
+# a C or Assembler source file, based on its tags.
+TARGET-process-src-files-tags = \
+$(eval __debug_sources := $(call get-src-files-with-tag,debug)) \
+$(eval __release_sources := $(call get-src-files-without-tag,debug)) \
+$(call set-src-files-target-cflags, \
+    $(__debug_sources),\
+    $(TARGET_mips_debug_CFLAGS)) \
+$(call set-src-files-target-cflags,\
+    $(__release_sources),\
+    $(TARGET_mips_release_CFLAGS)) \
+$(call set-src-files-text,$(__debug_sources),mips$(space)) \
+$(call set-src-files-text,$(__release_sources),mips$(space)) \
+
+#
+# We need to add -lsupc++ to the final link command to make exceptions
+# and RTTI work properly (when -fexceptions and -frtti are used).
+#
+# Normally, the toolchain should be configured to do that automatically,
+# this will be debugged later.
+#
+define cmd-build-shared-library
+$(PRIVATE_CXX) \
+    -Wl,-soname,$(notdir $@) \
+    -shared \
+    --sysroot=$(call host-path,$(PRIVATE_SYSROOT)) \
+    $(PRIVATE_LINKER_OBJECTS_AND_LIBRARIES) \
+    $(PRIVATE_LDFLAGS) \
+    $(PRIVATE_LDLIBS) \
+    -o $(call host-path,$@)
+endef
+
+define cmd-build-executable
+$(PRIVATE_CXX) \
+    -Wl,--gc-sections \
+    -Wl,-z,nocopyreloc \
+    --sysroot=$(call host-path,$(PRIVATE_SYSROOT)) \
+    $(PRIVATE_LINKER_OBJECTS_AND_LIBRARIES) \
+    $(PRIVATE_LDFLAGS) \
+    $(PRIVATE_LDLIBS) \
+    -o $(call host-path,$@)
+endef
diff --git a/toolchains/x86-4.4.3/config.mk b/toolchains/x86-4.4.3/config.mk
index 79761de..de7c84c 100644
--- a/toolchains/x86-4.4.3/config.mk
+++ b/toolchains/x86-4.4.3/config.mk
@@ -13,7 +13,7 @@
 # limitations under the License.
 #
 
-# config file for the x86-4.4.3 toolchain for the Android NDK
+# config file for the x86 gcc-4.4.3 toolchain for the Android NDK
 # the real meat is in the setup.mk file adjacent to this one
 #
 TOOLCHAIN_ARCH := x86
diff --git a/toolchains/x86-4.4.3/setup.mk b/toolchains/x86-4.4.3/setup.mk
index abe98a9..7a0c990 100644
--- a/toolchains/x86-4.4.3/setup.mk
+++ b/toolchains/x86-4.4.3/setup.mk
@@ -13,7 +13,7 @@
 # limitations under the License.
 #
 
-# this file is used to prepare the NDK to build with the x86-4.4.3
+# this file is used to prepare the NDK to build with the x86 gcc-4.4.3
 # toolchain any number of source files
 #
 # its purpose is to define (or re-define) templates used to build
diff --git a/toolchains/x86-4.6/config.mk b/toolchains/x86-4.6/config.mk
new file mode 100644
index 0000000..dd933f9
--- /dev/null
+++ b/toolchains/x86-4.6/config.mk
@@ -0,0 +1,20 @@
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# config file for the x86 gcc-4.6 toolchain for the Android NDK
+# the real meat is in the setup.mk file adjacent to this one
+#
+TOOLCHAIN_ARCH := x86
+TOOLCHAIN_ABIS := x86
diff --git a/toolchains/x86-4.6/setup.mk b/toolchains/x86-4.6/setup.mk
new file mode 100644
index 0000000..03e97b6
--- /dev/null
+++ b/toolchains/x86-4.6/setup.mk
@@ -0,0 +1,98 @@
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# this file is used to prepare the NDK to build with the x86 gcc-4.6
+# toolchain any number of source files
+#
+# its purpose is to define (or re-define) templates used to build
+# various sources into target object files, libraries or executables.
+#
+# Note that this file may end up being parsed several times in future
+# revisions of the NDK.
+#
+
+TOOLCHAIN_NAME   := x86-4.6
+TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREBUILT_ROOT)/bin/i686-linux-android-
+
+TARGET_CFLAGS := \
+    -ffunction-sections \
+    -funwind-tables
+
+TARGET_C_INCLUDES := \
+    $(SYSROOT)/usr/include
+
+# Add and LDFLAGS for the target here
+# TARGET_LDFLAGS :=
+
+# Fix this after ssp.c is fixed for x86
+# TARGET_CFLAGS += -fstack-protector
+
+TARGET_x86_release_CFLAGS :=  -O2 \
+                              -fomit-frame-pointer \
+                              -fstrict-aliasing    \
+                              -funswitch-loops     \
+                              -finline-limit=300
+
+# When building for debug, compile everything as x86.
+TARGET_x86_debug_CFLAGS := $(TARGET_x86_release_CFLAGS) \
+                           -fno-omit-frame-pointer \
+                           -fno-strict-aliasing
+
+# This function will be called to determine the target CFLAGS used to build
+# a C or Assembler source file, based on its tags.
+#
+TARGET-process-src-files-tags = \
+$(eval __debug_sources := $(call get-src-files-with-tag,debug)) \
+$(eval __release_sources := $(call get-src-files-without-tag,debug)) \
+$(call set-src-files-target-cflags, $(__debug_sources), $(TARGET_x86_debug_CFLAGS)) \
+$(call set-src-files-target-cflags, $(__release_sources),$(TARGET_x86_release_CFLAGS)) \
+$(call set-src-files-text,$(LOCAL_SRC_FILES),x86$(space)$(space)) \
+
+# The ABI-specific sub-directory that the SDK tools recognize for
+# this toolchain's generated binaries
+TARGET_ABI_SUBDIR := x86
+
+
+#
+# We need to add -lsupc++ to the final link command to make exceptions
+# and RTTI work properly (when -fexceptions and -frtti are used).
+#
+# Normally, the toolchain should be configured to do that automatically,
+# this will be debugged later.
+#
+
+define cmd-build-shared-library
+$(PRIVATE_CXX) \
+    $(PRIVATE_LDSCRIPT_XSC) \
+    -Wl,-soname,$(notdir $@) \
+    -shared \
+    --sysroot=$(call host-path,$(PRIVATE_SYSROOT)) \
+    $(PRIVATE_LINKER_OBJECTS_AND_LIBRARIES) \
+    $(PRIVATE_LDFLAGS) \
+    $(PRIVATE_LDLIBS) \
+    -o $(call host-path,$@)
+endef
+
+define cmd-build-executable
+$(PRIVATE_CXX) \
+    $(PRIVATE_LDSCRIPT_X) \
+    -Wl,--gc-sections \
+    -Wl,-z,nocopyreloc \
+    --sysroot=$(call host-path,$(PRIVATE_SYSROOT)) \
+    $(PRIVATE_LINKER_OBJECTS_AND_LIBRARIES) \
+    $(PRIVATE_LDFLAGS) \
+    $(PRIVATE_LDLIBS) \
+    -o $(call host-path,$@)
+endef