x86: Add proper gcc-4.4.3 x86 toolchain support.

This patch combines 7 AOSP patches to add proper support
to build x86 platform images using the 4.4.3 toolchain.

The Orig-Changed-Id fields below correspond to the change ids
of the original changes in the AOSP master branch history.

    Define __ANDROID__ for x86 to be on par with ARM build requirements
    Orig-Change-Id: I79c8f29af1f20b694f22a39f848216022809a5c6
    Signed-off-by: Bruce Beare <brucex.j.beare@intel.com>

    Enables x86-atom as a valid TARGET_ARCH_VARIANT for the simulator build.
    Orig-Change-Id: Idbceb6c7d4117fbecd35e4261330e6405666189e

    IA: enable SSE fpmath, Separate ARCH_VARIANT and ARCH makefile settings
    Change-Id: I9ba661d68a3b375c21eb6b56442d8ba66a5369b3
    Orig-Change-Id: I60b8121c92b39a60b513bc2496a1e0a21015c586
    Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>

    x86: Use GCC 4.4.3
    Orig-Change-Id: I083c1afcbb98cfeb48d7bcb7681e5c34db52e767
    Author:    H.J. Lu <hjl.tools@gmail.com>
    Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>

    x86: the -mbionic flag is needed for IA builds.
    Orig-Change-Id: I00c75f37d7ea46b9f8ad3d7b2ff7094477ff0916
    Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>

    x86: Disable stack-protector until bionic is fixed
    Orig-Change-Id: I2862de5c1b02490197704f4578a8a91d0565eef0
    Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>

    Clean up of X86 build flags
    Orig-Change-Id: Ife75c32cd49b32345712dee28fa5f2283069a90e
    Signed-off-by: Mark D Horn <mark.d.horn@intel.com>
    Author: Bruce Beare <bruce.j.beare@intel.com>

    x86: Enable -fstack-protector
    Orig-Change-Id: I1fe10159b7a29452ecfc6ba328164948cf9950d6
    Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index d5bcba2..a683a0e 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -25,7 +25,9 @@
 TARGET_GLOBAL_CFLAGS := $(HOST_GLOBAL_CFLAGS) -m32
 TARGET_GLOBAL_LDFLAGS := $(HOST_GLOBAL_LDFLAGS) -m32 -lpthread
 TARGET_NO_UNDEFINED_LDFLAGS := $(HOST_NO_UNDEFINED_LDFLAGS)
+ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
 TARGET_ARCH_VARIANT := x86
+endif
 else #simulator
 
 # Provide a default variant.
@@ -36,7 +38,7 @@
 # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
 ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
 TARGET_TOOLS_PREFIX := \
-	prebuilt/$(HOST_PREBUILT_TAG)/toolchain/i686-unknown-linux-gnu-4.2.1/bin/i686-unknown-linux-gnu-
+	prebuilt/$(HOST_PREBUILT_TAG)/toolchain/i686-android-linux-4.4.3/bin/i686-android-linux-
 endif
 
 TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
@@ -49,8 +51,7 @@
 
 ifneq ($(wildcard $(TARGET_CC)),)
 TARGET_LIBGCC := \
-	$(shell $(TARGET_CC) -m32 -print-file-name=libgcc.a) \
-        $(shell $(TARGET_CC) -m32 -print-file-name=libgcc_eh.a)
+	$(shell $(TARGET_CC) -m32 -print-file-name=libgcc.a)
 endif
 
 TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
@@ -74,14 +75,48 @@
 KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
 
 TARGET_GLOBAL_CFLAGS += \
-			-march=i686 \
-			-m32 \
+			-O2 \
+			-Ulinux \
+			-Wa,--noexecstack \
+			-Werror=format-security \
+			-Wstrict-aliasing=2 \
 			-fPIC \
+			-ffunction-sections \
+			-finline-functions \
+			-finline-limit=300 \
+			-fno-inline-functions-called-once \
+			-fno-short-enums \
+			-fstrict-aliasing \
+			-funswitch-loops \
+			-funwind-tables \
 			-include $(call select-android-config-h,target_linux-x86)
 
+TARGET_GLOBAL_CFLAGS += -fstack-protector
+
+# Needs to be added for RELEASE
+#TARGET_GLOBAL_CFLAGS += \
+#			-DNDEBUG
+
+
+# Fix this after ssp.c is fixed for x86
+# TARGET_GLOBAL_CFLAGS += -fstack-protector
+
 TARGET_GLOBAL_CPPFLAGS += \
 			-fno-use-cxa-atexit
 
+ifeq ($(TARGET_ARCH_VARIANT),x86-atom)
+    TARGET_GLOBAL_CFLAGS += -march=atom -mstackrealign -DUSE_SSSE3 -DUSE_SSE2 -mfpmath=sse
+else
+    TARGET_GLOBAL_CFLAGS += -march=i686
+endif
+
+TARGET_GLOBAL_CFLAGS += -mbionic
+TARGET_GLOBAL_CFLAGS += -D__ANDROID__
+
+TARGET_GLOBAL_LDFLAGS += -m32
+TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
+TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
+
 TARGET_C_INCLUDES := \
 	$(libc_root)/arch-x86/include \
 	$(libc_root)/include \
@@ -109,7 +144,7 @@
 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
 	 -nostdlib -Wl,-soname,$(notdir $@) \
 	 -shared -Bsymbolic \
-	-fPIC -march=i686 \
+	$(TARGET_GLOBAL_CFLAGS) \
 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
 	$(PRIVATE_TARGET_CRTBEGIN_SO_O) \
 	$(PRIVATE_ALL_OBJECTS) \
@@ -159,7 +194,4 @@
 	$(TARGET_CRTEND_O)
 endef
 
-TARGET_GLOBAL_CFLAGS += -m32
-TARGET_GLOBAL_LDFLAGS += -m32
-
 endif #simulator