diff options
25 files changed, 288 insertions, 69 deletions
diff --git a/gcc-4.4.3/gcc/config.gcc b/gcc-4.4.3/gcc/config.gcc index 321cf5543..755b90dd0 100644 --- a/gcc-4.4.3/gcc/config.gcc +++ b/gcc-4.4.3/gcc/config.gcc @@ -515,7 +515,7 @@ case ${target} in tm_defines="$tm_defines OPTION_GLIBC=1";; esac case $target in - *-*-*android*) + *-*-*android* | *-android-linux-*) tm_defines="$tm_defines DEFAULT_LIBC=LIBC_BIONIC" ;; *-*-*uclibc*) @@ -538,7 +538,7 @@ case ${target} in esac # Enable compilation for Android by default for *android* targets. case $target in - *-*-*android*) + *-*-*android* | *-android-linux-*) tm_defines="$tm_defines ANDROID_DEFAULT=1" ;; *) @@ -1628,6 +1628,12 @@ mips*-*-linux*) # Linux MIPS, either endian. mipsisa32*) tm_defines="${tm_defines} MIPS_ISA_DEFAULT=32" esac + case ${target} in + *android*) + # Default to little-endian for MIPS Android + # tm_defines="${tm_defines} TARGET_ENDIAN_DEFAULT=0" + tmake_file="$tmake_file mips/t-linux-android" + esac test x$with_llsc != x || with_llsc=yes ;; mips*-*-openbsd*) diff --git a/gcc-4.4.3/gcc/config/arm/elf.h b/gcc-4.4.3/gcc/config/arm/elf.h index 7c3eddbe0..018319b07 100644 --- a/gcc-4.4.3/gcc/config/arm/elf.h +++ b/gcc-4.4.3/gcc/config/arm/elf.h @@ -52,8 +52,7 @@ #undef SUBSUBTARGET_EXTRA_SPECS #define SUBSUBTARGET_EXTRA_SPECS -#ifndef ASM_SPEC -#define ASM_SPEC "\ +#define LINUX_ASM_SPEC "\ %{mbig-endian:-EB} \ %{mlittle-endian:-EL} \ %{mcpu=*:-mcpu=%*} \ @@ -64,6 +63,9 @@ %{msoft-float:-mfloat-abi=soft} %{mhard-float:-mfloat-abi=hard} \ %{mfloat-abi=*} %{mfpu=*} \ %(subtarget_extra_asm_spec)" + +#ifndef ASM_SPEC +#define ASM_SPEC LINUX_ASM_SPEC #endif /* The ARM uses @ are a comment character so we need to redefine diff --git a/gcc-4.4.3/gcc/config/arm/linux-eabi.h b/gcc-4.4.3/gcc/config/arm/linux-eabi.h index 2ca881890..9004f0171 100644 --- a/gcc-4.4.3/gcc/config/arm/linux-eabi.h +++ b/gcc-4.4.3/gcc/config/arm/linux-eabi.h @@ -74,11 +74,16 @@ #undef CC1_SPEC #define CC1_SPEC \ LINUX_OR_ANDROID_CC (LINUX_TARGET_CC1_SPEC, \ - LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) + LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic")) #define CC1PLUS_SPEC \ LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) +#undef ASM_SPEC +#define ASM_SPEC \ + LINUX_OR_ANDROID_CC (LINUX_ASM_SPEC, \ + LINUX_ASM_SPEC " " ANDROID_ASM_SPEC) + #undef LIB_SPEC #define LIB_SPEC \ LINUX_OR_ANDROID_LD (LINUX_TARGET_LIB_SPEC, \ diff --git a/gcc-4.4.3/gcc/config/i386/linux.h b/gcc-4.4.3/gcc/config/i386/linux.h index f3a98c26a..12451fef8 100644 --- a/gcc-4.4.3/gcc/config/i386/linux.h +++ b/gcc-4.4.3/gcc/config/i386/linux.h @@ -72,15 +72,36 @@ along with GCC; see the file COPYING3. If not see #define TARGET_OS_CPP_BUILTINS() \ do \ { \ - LINUX_TARGET_OS_CPP_BUILTINS(); \ + LINUX_TARGET_OS_CPP_BUILTINS(); \ + ANDROID_TARGET_OS_CPP_BUILTINS(); \ } \ while (0) #undef CPP_SPEC #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" +#define OVERRIDE_LINUX_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}" #undef CC1_SPEC -#define CC1_SPEC "%(cc1_cpu) %{profile:-p}" +#define CC1_SPEC \ + LINUX_OR_ANDROID_CC (OVERRIDE_LINUX_TARGET_CC1_SPEC, \ + OVERRIDE_LINUX_TARGET_CC1_SPEC \ + " -march=i686 -mtune=atom" \ + " -mstackrealign -msse3 -mfpmath=sse" \ + " -m32 -fno-short-enums" \ + " " \ + ANDROID_CC1_SPEC("-fPIC")) + +#define CC1PLUS_SPEC \ + LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) + +#undef LIB_SPEC +#define LIB_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_TARGET_LIB_SPEC, \ + LINUX_TARGET_LIB_SPEC " " ANDROID_LIB_SPEC) + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC) /* Provide a LINK_SPEC appropriate for Linux. Here we provide support for the special GCC options -static and -shared, which allow us to @@ -108,7 +129,8 @@ along with GCC; see the file COPYING3. If not see #undef ASM_SPEC #define ASM_SPEC \ "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} --32 \ - %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}" + %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}} " \ + LINUX_OR_ANDROID_CC ("", ANDROID_ASM_SPEC) /* These may be provided by config/linux-grtev2.h. */ #ifndef LINUX_GRTE_EXTRA_SPECS @@ -121,23 +143,28 @@ along with GCC; see the file COPYING3. If not see { "link_emulation", LINK_EMULATION },\ { "dynamic_linker", LINUX_DYNAMIC_LINKER } -#undef LINK_SPEC -#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \ +#define OVERRIDE_LINUX_TARGET_LINK_SPEC "-m %(link_emulation) %{shared:-shared} \ %{!shared: \ %{!ibcs: \ %{!static: \ %{rdynamic:-export-dynamic} \ %{!dynamic-linker:-dynamic-linker %(dynamic_linker)}} \ %{static:-static}}}" +#undef LINK_SPEC +#define LINK_SPEC \ + LINUX_OR_ANDROID_LD (OVERRIDE_LINUX_TARGET_LINK_SPEC, \ + OVERRIDE_LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC) /* Similar to standard Linux, but adding -ffast-math support. */ -#undef ENDFILE_SPEC -#define ENDFILE_SPEC \ +#define OVERRIDE_LINUX_TARGET_ENDFILE_SPEC \ "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ %{mpc32:crtprec32.o%s} \ %{mpc64:crtprec64.o%s} \ %{mpc80:crtprec80.o%s} \ %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + LINUX_OR_ANDROID_LD (OVERRIDE_LINUX_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC) /* A C statement (sans semicolon) to output to the stdio stream FILE the assembler definition of uninitialized global DECL named diff --git a/gcc-4.4.3/gcc/config/linux-android.h b/gcc-4.4.3/gcc/config/linux-android.h index 5ca3858a2..f9fcf5ba3 100644 --- a/gcc-4.4.3/gcc/config/linux-android.h +++ b/gcc-4.4.3/gcc/config/linux-android.h @@ -39,22 +39,25 @@ "%{" NOANDROID "|tno-android-ld:" LINUX_SPEC ";:" ANDROID_SPEC "}" #define ANDROID_LINK_SPEC \ - "%{shared: -Bsymbolic}" + "%{shared: -Bsymbolic} -z noexecstack -z relro -z now" -#define ANDROID_CC1_SPEC \ +#define ANDROID_CC1_SPEC(ANDROID_PIC_DEFAULT) \ "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " \ - "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}" + "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: " ANDROID_PIC_DEFAULT "}}}}" #define ANDROID_CC1PLUS_SPEC \ "%{!fexceptions:%{!fno-exceptions: -fno-exceptions}} " \ "%{!frtti:%{!fno-rtti: -fno-rtti}}" +#define ANDROID_ASM_SPEC \ + "--noexecstack" + #define ANDROID_LIB_SPEC \ "%{!static: -ldl}" #define ANDROID_STARTFILE_SPEC \ "%{!shared:" \ - " %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s}}" + " %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s};: crtbegin_so%O%s}" #define ANDROID_ENDFILE_SPEC \ - "%{!shared: crtend_android%O%s}" + "%{!shared: crtend_android%O%s;: crtend_so%O%s}" diff --git a/gcc-4.4.3/gcc/config/mips/linux.h b/gcc-4.4.3/gcc/config/mips/linux.h index 0512ef7d1..280d6fbda 100644 --- a/gcc-4.4.3/gcc/config/mips/linux.h +++ b/gcc-4.4.3/gcc/config/mips/linux.h @@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see /* The GNU C++ standard library requires this. */ \ if (c_dialect_cxx ()) \ builtin_define ("_GNU_SOURCE"); \ + ANDROID_TARGET_OS_CPP_BUILTINS(); \ } while (0) #undef SUBTARGET_CPP_SPEC @@ -55,8 +56,8 @@ along with GCC; see the file COPYING3. If not see /* A standard GNU/Linux mapping. On most targets, it is included in CC1_SPEC itself by config/linux.h, but mips.h overrides CC1_SPEC and provides this hook instead. */ -#undef SUBTARGET_CC1_SPEC -#define SUBTARGET_CC1_SPEC "%{profile:-p}" +#undef LINUX_SUBTARGET_CC1_SPEC +#define LINUX_SUBTARGET_CC1_SPEC "%{profile:-p}" /* From iris5.h */ /* -G is incompatible with -KPIC which is the default, so only allow objects @@ -67,8 +68,8 @@ along with GCC; see the file COPYING3. If not see #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" /* Borrowed from sparc/linux.h */ -#undef LINK_SPEC -#define LINK_SPEC \ +#undef LINUX_SUBTARGET_LINK_SPEC +#define LINUX_SUBTARGET_LINK_SPEC \ "%(endian_spec) \ %{shared:-shared} \ %{!shared: \ @@ -80,7 +81,8 @@ along with GCC; see the file COPYING3. If not see #undef SUBTARGET_ASM_SPEC #define SUBTARGET_ASM_SPEC \ - "%{!mno-abicalls:%{mplt:-call_nonpic;:-KPIC}}" + "%{!mno-abicalls:%{mplt:-call_nonpic;:-KPIC}} " \ + LINUX_OR_ANDROID_CC ("", ANDROID_ASM_SPEC) /* The MIPS assembler has different syntax for .set. We set it to .dummy to trap any errors. */ @@ -103,8 +105,8 @@ along with GCC; see the file COPYING3. If not see #undef ASM_OUTPUT_REG_PUSH #undef ASM_OUTPUT_REG_POP -#undef LIB_SPEC -#define LIB_SPEC "\ +#undef LINUX_SUBTARGET_LIB_SPEC +#define LINUX_SUBTARGET_LIB_SPEC "\ %{pthread:-lpthread} \ %{shared:-lc} \ %{!shared: \ @@ -135,7 +137,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); #endif #define LINUX_DRIVER_SELF_SPECS \ - NO_SHARED_SPECS \ + LINUX_OR_ANDROID_CC(NO_SHARED_SPECS, "") \ MARCH_MTUNE_NATIVE_SPECS, \ /* -mplt has no effect without -mno-shared. Simplify later \ specs handling by removing a redundant option. */ \ @@ -147,3 +149,30 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); #define DRIVER_SELF_SPECS \ BASE_DRIVER_SELF_SPECS, \ LINUX_DRIVER_SELF_SPECS + +#undef LINK_SPEC +#define LINK_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_SUBTARGET_LINK_SPEC, \ + LINUX_SUBTARGET_LINK_SPEC " " ANDROID_LINK_SPEC) + +#undef SUBTARGET_CC1_SPEC +#define SUBTARGET_CC1_SPEC \ + LINUX_OR_ANDROID_CC (LINUX_SUBTARGET_CC1_SPEC, \ + LINUX_SUBTARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic")) + +#undef CC1PLUS_SPEC +#define CC1PLUS_SPEC \ + LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) + +#undef LIB_SPEC +#define LIB_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_SUBTARGET_LIB_SPEC, \ + LINUX_SUBTARGET_LIB_SPEC " " ANDROID_LIB_SPEC) + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC) + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC) diff --git a/gcc-4.4.3/gcc/config/mips/t-linux-android b/gcc-4.4.3/gcc/config/mips/t-linux-android new file mode 100644 index 000000000..298cad9d5 --- /dev/null +++ b/gcc-4.4.3/gcc/config/mips/t-linux-android @@ -0,0 +1,3 @@ +MULTILIB_OPTIONS = mips32r2 +MULTILIB_DIRNAMES = mips-r2 +MULTILIB_EXCLUSIONS := diff --git a/gcc-4.4.3/gcc/unwind-dw2-fde-glibc.c b/gcc-4.4.3/gcc/unwind-dw2-fde-glibc.c index 11f53dd31..bad608280 100644 --- a/gcc-4.4.3/gcc/unwind-dw2-fde-glibc.c +++ b/gcc-4.4.3/gcc/unwind-dw2-fde-glibc.c @@ -46,8 +46,10 @@ #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))) + && ((defined(__BIONIC__) && (defined(mips) || defined(__mips__))) \ + || (__GLIBC__ > 2 \ + || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ + || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))) #include <link.h> diff --git a/gcc-4.4.3/libstdc++-v3/libsupc++/eh_globals.cc b/gcc-4.4.3/libstdc++-v3/libsupc++/eh_globals.cc index 63f46a99e..845b6d1ae 100644 --- a/gcc-4.4.3/libstdc++-v3/libsupc++/eh_globals.cc +++ b/gcc-4.4.3/libstdc++-v3/libsupc++/eh_globals.cc @@ -101,6 +101,14 @@ struct __eh_globals_init ~__eh_globals_init() { + /* Work-around for an Android-specific bug, where this destructor + * is called with a NULL object pointer. This is due to a bug in the + * __cxa_finalize() implementation that was only fixed in 2.2. + */ +#ifdef __ANDROID__ + if (this == NULL) + return; +#endif if (_M_init) __gthread_key_delete(_M_key); _M_init = false; diff --git a/gcc-4.6/gcc/config.gcc b/gcc-4.6/gcc/config.gcc index d9ac0fae9..3f1fab3ba 100644 --- a/gcc-4.6/gcc/config.gcc +++ b/gcc-4.6/gcc/config.gcc @@ -585,7 +585,7 @@ case ${target} in tm_defines="$tm_defines SINGLE_LIBC";; esac case $target in - *-*-*android*) + *-*-*android* | *-android-linux-*) tm_defines="$tm_defines DEFAULT_LIBC=LIBC_BIONIC" ;; *-*-*uclibc*) @@ -609,7 +609,7 @@ case ${target} in esac # Enable compilation for Android by default for *android* targets. case $target in - *-*-*android*) + *-*-*android* | *-android-linux-*) tm_defines="$tm_defines ANDROID_DEFAULT=1" ;; *) @@ -1918,6 +1918,12 @@ mips*-*-linux*) # Linux MIPS, either endian. mipsisa32*) tm_defines="${tm_defines} MIPS_ISA_DEFAULT=32" esac + case ${target} in + *android*) + # Default to little-endian for MIPS Android + # tm_defines="${tm_defines} TARGET_ENDIAN_DEFAULT=0" + tmake_file="$tmake_file mips/t-linux-android" + esac extra_parts="$extra_parts crtfastmath.o" test x$with_llsc != x || with_llsc=yes ;; diff --git a/gcc-4.6/gcc/config/arm/elf.h b/gcc-4.6/gcc/config/arm/elf.h index 88400884e..44d840b39 100644 --- a/gcc-4.6/gcc/config/arm/elf.h +++ b/gcc-4.6/gcc/config/arm/elf.h @@ -52,8 +52,7 @@ #undef SUBSUBTARGET_EXTRA_SPECS #define SUBSUBTARGET_EXTRA_SPECS -#ifndef ASM_SPEC -#define ASM_SPEC "\ +#define LINUX_ASM_SPEC "\ %{mbig-endian:-EB} \ %{mlittle-endian:-EL} \ %{mcpu=*:-mcpu=%*} \ @@ -64,6 +63,9 @@ %{msoft-float:-mfloat-abi=soft} %{mhard-float:-mfloat-abi=hard} \ %{mfloat-abi=*} %{mfpu=*} \ %(subtarget_extra_asm_spec)" + +#ifndef ASM_SPEC +#define ASM_SPEC LINUX_ASM_SPEC #endif /* The ARM uses @ are a comment character so we need to redefine diff --git a/gcc-4.6/gcc/config/arm/linux-eabi.h b/gcc-4.6/gcc/config/arm/linux-eabi.h index 3a3218853..72f9bdd5f 100644 --- a/gcc-4.6/gcc/config/arm/linux-eabi.h +++ b/gcc-4.6/gcc/config/arm/linux-eabi.h @@ -74,11 +74,16 @@ #undef CC1_SPEC #define CC1_SPEC \ LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \ - GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) + GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic")) #define CC1PLUS_SPEC \ LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) +#undef ASM_SPEC +#define ASM_SPEC \ + LINUX_OR_ANDROID_CC (LINUX_ASM_SPEC, \ + LINUX_ASM_SPEC " " ANDROID_ASM_SPEC) + #undef LIB_SPEC #define LIB_SPEC \ LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LIB_SPEC, \ diff --git a/gcc-4.6/gcc/config/i386/linux.h b/gcc-4.6/gcc/config/i386/linux.h index 414dc65bf..57a8758aa 100644 --- a/gcc-4.6/gcc/config/i386/linux.h +++ b/gcc-4.6/gcc/config/i386/linux.h @@ -85,7 +85,15 @@ along with GCC; see the file COPYING3. If not see #undef CC1_SPEC #define CC1_SPEC \ LINUX_OR_ANDROID_CC (LINUX_TARGET_CC1_SPEC, \ - LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) + LINUX_TARGET_CC1_SPEC \ + " -march=i686 -mtune=atom" \ + " -mstackrealign -msse3 -mfpmath=sse" \ + " -m32 -fno-short-enums" \ + " " \ + ANDROID_CC1_SPEC("-fPIC")) + +#define CC1PLUS_SPEC \ + LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) /* Provide a LINK_SPEC appropriate for Linux. Here we provide support for the special GCC options -static and -shared, which allow us to @@ -104,7 +112,8 @@ along with GCC; see the file COPYING3. If not see #undef ASM_SPEC #define ASM_SPEC \ - "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}" + "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}} " \ + LINUX_OR_ANDROID_CC ("", ANDROID_ASM_SPEC) /* These may be provided by config/linux-grtev2.h. */ #ifndef LINUX_GRTE_EXTRA_SPECS diff --git a/gcc-4.6/gcc/config/linux-android.h b/gcc-4.6/gcc/config/linux-android.h index acbc6627f..033cfefd1 100644 --- a/gcc-4.6/gcc/config/linux-android.h +++ b/gcc-4.6/gcc/config/linux-android.h @@ -39,16 +39,19 @@ "%{" NOANDROID "|tno-android-ld:" LINUX_SPEC ";:" ANDROID_SPEC "}" #define ANDROID_LINK_SPEC \ - "%{shared: -Bsymbolic}" + "%{shared: -Bsymbolic} -z noexecstack -z relro -z now" -#define ANDROID_CC1_SPEC \ +#define ANDROID_CC1_SPEC(ANDROID_PIC_DEFAULT) \ "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " \ - "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}" + "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: " ANDROID_PIC_DEFAULT "}}}}" #define ANDROID_CC1PLUS_SPEC \ "%{!fexceptions:%{!fno-exceptions: -fno-exceptions}} " \ "%{!frtti:%{!fno-rtti: -fno-rtti}}" +#define ANDROID_ASM_SPEC \ + "--noexecstack" + #define ANDROID_LIB_SPEC \ "%{!static: -ldl}" diff --git a/gcc-4.6/gcc/config/mips/linux.h b/gcc-4.6/gcc/config/mips/linux.h index a78f6bcbb..7a292bfd6 100644 --- a/gcc-4.6/gcc/config/mips/linux.h +++ b/gcc-4.6/gcc/config/mips/linux.h @@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see /* The GNU C++ standard library requires this. */ \ if (c_dialect_cxx ()) \ builtin_define ("_GNU_SOURCE"); \ + ANDROID_TARGET_OS_CPP_BUILTINS(); \ } while (0) #undef SUBTARGET_CPP_SPEC @@ -52,8 +53,8 @@ along with GCC; see the file COPYING3. If not see /* A standard GNU/Linux mapping. On most targets, it is included in CC1_SPEC itself by config/linux.h, but mips.h overrides CC1_SPEC and provides this hook instead. */ -#undef SUBTARGET_CC1_SPEC -#define SUBTARGET_CC1_SPEC "%{profile:-p}" +#undef LINUX_SUBTARGET_CC1_SPEC +#define LINUX_SUBTARGET_CC1_SPEC "%{profile:-p}" /* From iris5.h */ /* -G is incompatible with -KPIC which is the default, so only allow objects @@ -64,8 +65,8 @@ along with GCC; see the file COPYING3. If not see #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" /* Borrowed from sparc/linux.h */ -#undef LINK_SPEC -#define LINK_SPEC \ +#undef LINUX_SUBTARGET_LINK_SPEC +#define LINUX_SUBTARGET_LINK_SPEC \ "%(endian_spec) \ %{shared:-shared} \ %{!shared: \ @@ -76,7 +77,8 @@ along with GCC; see the file COPYING3. If not see #undef SUBTARGET_ASM_SPEC #define SUBTARGET_ASM_SPEC \ - "%{!mno-abicalls:%{mplt:-call_nonpic;:-KPIC}}" + "%{!mno-abicalls:%{mplt:-call_nonpic;:-KPIC}} " \ + LINUX_OR_ANDROID_CC ("", ANDROID_ASM_SPEC) /* The MIPS assembler has different syntax for .set. We set it to .dummy to trap any errors. */ @@ -99,8 +101,8 @@ along with GCC; see the file COPYING3. If not see #undef ASM_OUTPUT_REG_PUSH #undef ASM_OUTPUT_REG_POP -#undef LIB_SPEC -#define LIB_SPEC "\ +#undef LINUX_SUBTARGET_LIB_SPEC +#define LINUX_SUBTARGET_LIB_SPEC "\ %{pthread:-lpthread} \ %{shared:-lc} \ %{!shared: \ @@ -131,7 +133,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); #endif #define LINUX_DRIVER_SELF_SPECS \ - NO_SHARED_SPECS \ + LINUX_OR_ANDROID_CC(NO_SHARED_SPECS, "") \ MARCH_MTUNE_NATIVE_SPECS, \ /* -mplt has no effect without -mno-shared. Simplify later \ specs handling by removing a redundant option. */ \ @@ -145,7 +147,36 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); LINUX_DRIVER_SELF_SPECS /* Similar to standard Linux, but adding -ffast-math support. */ -#undef ENDFILE_SPEC -#define ENDFILE_SPEC \ - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ - %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" +#undef LINUX_TARGET_MATHFILE_SPEC +#define LINUX_TARGET_MATHFILE_SPEC \ + "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" + +#undef LINK_SPEC +#define LINK_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_SUBTARGET_LINK_SPEC, \ + LINUX_SUBTARGET_LINK_SPEC " " ANDROID_LINK_SPEC) + +#undef SUBTARGET_CC1_SPEC +#define SUBTARGET_CC1_SPEC \ + LINUX_OR_ANDROID_CC (LINUX_SUBTARGET_CC1_SPEC, \ + LINUX_SUBTARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic")) + +#undef CC1PLUS_SPEC +#define CC1PLUS_SPEC \ + LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) + +#undef LIB_SPEC +#define LIB_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_SUBTARGET_LIB_SPEC, \ + LINUX_SUBTARGET_LIB_SPEC " " ANDROID_LIB_SPEC) + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC) + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_TARGET_MATHFILE_SPEC " " \ + GNU_USER_TARGET_ENDFILE_SPEC, \ + LINUX_TARGET_MATHFILE_SPEC " " \ + ANDROID_ENDFILE_SPEC) diff --git a/gcc-4.6/gcc/config/mips/t-linux-android b/gcc-4.6/gcc/config/mips/t-linux-android new file mode 100644 index 000000000..298cad9d5 --- /dev/null +++ b/gcc-4.6/gcc/config/mips/t-linux-android @@ -0,0 +1,3 @@ +MULTILIB_OPTIONS = mips32r2 +MULTILIB_DIRNAMES = mips-r2 +MULTILIB_EXCLUSIONS := diff --git a/gcc-4.6/libstdc++-v3/libsupc++/eh_globals.cc b/gcc-4.6/libstdc++-v3/libsupc++/eh_globals.cc index 63f46a99e..845b6d1ae 100644 --- a/gcc-4.6/libstdc++-v3/libsupc++/eh_globals.cc +++ b/gcc-4.6/libstdc++-v3/libsupc++/eh_globals.cc @@ -101,6 +101,14 @@ struct __eh_globals_init ~__eh_globals_init() { + /* Work-around for an Android-specific bug, where this destructor + * is called with a NULL object pointer. This is due to a bug in the + * __cxa_finalize() implementation that was only fixed in 2.2. + */ +#ifdef __ANDROID__ + if (this == NULL) + return; +#endif if (_M_init) __gthread_key_delete(_M_key); _M_init = false; diff --git a/gcc-4.7/gcc/config.gcc b/gcc-4.7/gcc/config.gcc index 5fcd1928c..44befba79 100644 --- a/gcc-4.7/gcc/config.gcc +++ b/gcc-4.7/gcc/config.gcc @@ -1790,6 +1790,12 @@ mips*-*-linux*) # Linux MIPS, either endian. mipsisa32*) tm_defines="${tm_defines} MIPS_ISA_DEFAULT=32" esac + case ${target} in + *android*) + # Default to little-endian for MIPS Android + # tm_defines="${tm_defines} TARGET_ENDIAN_DEFAULT=0" + tmake_file="$tmake_file mips/t-linux-android" + esac test x$with_llsc != x || with_llsc=yes ;; mips*-*-openbsd*) diff --git a/gcc-4.7/gcc/config/arm/elf.h b/gcc-4.7/gcc/config/arm/elf.h index e0a0aa06c..417adf8a2 100644 --- a/gcc-4.7/gcc/config/arm/elf.h +++ b/gcc-4.7/gcc/config/arm/elf.h @@ -52,8 +52,7 @@ #undef SUBSUBTARGET_EXTRA_SPECS #define SUBSUBTARGET_EXTRA_SPECS -#ifndef ASM_SPEC -#define ASM_SPEC "\ +#define LINUX_ASM_SPEC "\ %{mbig-endian:-EB} \ %{mlittle-endian:-EL} \ %(asm_cpu_spec) \ @@ -62,6 +61,9 @@ %{mthumb-interwork:-mthumb-interwork} \ %{mfloat-abi=*} %{mfpu=*} \ %(subtarget_extra_asm_spec)" + +#ifndef ASM_SPEC +#define ASM_SPEC LINUX_ASM_SPEC #endif /* The ARM uses @ are a comment character so we need to redefine diff --git a/gcc-4.7/gcc/config/arm/linux-eabi.h b/gcc-4.7/gcc/config/arm/linux-eabi.h index 80bd82593..88811b7ec 100644 --- a/gcc-4.7/gcc/config/arm/linux-eabi.h +++ b/gcc-4.7/gcc/config/arm/linux-eabi.h @@ -74,11 +74,16 @@ #undef CC1_SPEC #define CC1_SPEC \ LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \ - GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) + GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic")) #define CC1PLUS_SPEC \ LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) +#undef ASM_SPEC +#define ASM_SPEC \ + LINUX_OR_ANDROID_CC (LINUX_ASM_SPEC, \ + LINUX_ASM_SPEC " " ANDROID_ASM_SPEC) + #undef LIB_SPEC #define LIB_SPEC \ LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LIB_SPEC, \ diff --git a/gcc-4.7/gcc/config/i386/gnu-user.h b/gcc-4.7/gcc/config/i386/gnu-user.h index 5232bd603..12b00e164 100644 --- a/gcc-4.7/gcc/config/i386/gnu-user.h +++ b/gcc-4.7/gcc/config/i386/gnu-user.h @@ -83,7 +83,15 @@ along with GCC; see the file COPYING3. If not see #undef CC1_SPEC #define CC1_SPEC \ LINUX_OR_ANDROID_CC (LINUX_TARGET_CC1_SPEC, \ - LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) + LINUX_TARGET_CC1_SPEC \ + " -march=i686 -mtune=atom" \ + " -mstackrealign -msse3 -mfpmath=sse" \ + " -m32 -fno-short-enums" \ + " " \ + ANDROID_CC1_SPEC("-fPIC")) + +#define CC1PLUS_SPEC \ + LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) /* Provide a LINK_SPEC appropriate for GNU userspace. Here we provide support for the special GCC options -static and -shared, which allow us to @@ -95,7 +103,8 @@ along with GCC; see the file COPYING3. If not see #undef ASM_SPEC #define ASM_SPEC \ - "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}" + "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}} " \ + LINUX_OR_ANDROID_CC ("", ANDROID_ASM_SPEC) #undef SUBTARGET_EXTRA_SPECS #define SUBTARGET_EXTRA_SPECS \ diff --git a/gcc-4.7/gcc/config/linux-android.h b/gcc-4.7/gcc/config/linux-android.h index acbc6627f..033cfefd1 100644 --- a/gcc-4.7/gcc/config/linux-android.h +++ b/gcc-4.7/gcc/config/linux-android.h @@ -39,16 +39,19 @@ "%{" NOANDROID "|tno-android-ld:" LINUX_SPEC ";:" ANDROID_SPEC "}" #define ANDROID_LINK_SPEC \ - "%{shared: -Bsymbolic}" + "%{shared: -Bsymbolic} -z noexecstack -z relro -z now" -#define ANDROID_CC1_SPEC \ +#define ANDROID_CC1_SPEC(ANDROID_PIC_DEFAULT) \ "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " \ - "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}" + "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: " ANDROID_PIC_DEFAULT "}}}}" #define ANDROID_CC1PLUS_SPEC \ "%{!fexceptions:%{!fno-exceptions: -fno-exceptions}} " \ "%{!frtti:%{!fno-rtti: -fno-rtti}}" +#define ANDROID_ASM_SPEC \ + "--noexecstack" + #define ANDROID_LIB_SPEC \ "%{!static: -ldl}" diff --git a/gcc-4.7/gcc/config/mips/gnu-user.h b/gcc-4.7/gcc/config/mips/gnu-user.h index 49c459bc7..ebce0822f 100644 --- a/gcc-4.7/gcc/config/mips/gnu-user.h +++ b/gcc-4.7/gcc/config/mips/gnu-user.h @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see /* The GNU C++ standard library requires this. */ \ if (c_dialect_cxx ()) \ builtin_define ("_GNU_SOURCE"); \ + ANDROID_TARGET_OS_CPP_BUILTINS(); \ } while (0) #undef SUBTARGET_CPP_SPEC @@ -45,8 +46,8 @@ along with GCC; see the file COPYING3. If not see /* A standard GNU/Linux mapping. On most targets, it is included in CC1_SPEC itself by config/linux.h, but mips.h overrides CC1_SPEC and provides this hook instead. */ -#undef SUBTARGET_CC1_SPEC -#define SUBTARGET_CC1_SPEC "%{profile:-p}" +#undef LINUX_SUBTARGET_CC1_SPEC +#define LINUX_SUBTARGET_CC1_SPEC "%{profile:-p}" /* From iris5.h */ /* -G is incompatible with -KPIC which is the default, so only allow objects @@ -55,8 +56,8 @@ along with GCC; see the file COPYING3. If not see #define MIPS_DEFAULT_GVALUE 0 /* Borrowed from sparc/linux.h */ -#undef LINK_SPEC -#define LINK_SPEC \ +#undef LINUX_SUBTARGET_LINK_SPEC +#define LINUX_SUBTARGET_LINK_SPEC \ "%(endian_spec) \ %{shared:-shared} \ %{!shared: \ @@ -67,7 +68,8 @@ along with GCC; see the file COPYING3. If not see #undef SUBTARGET_ASM_SPEC #define SUBTARGET_ASM_SPEC \ - "%{!mno-abicalls:%{mplt:-call_nonpic;:-KPIC}}" + "%{!mno-abicalls:%{mplt:-call_nonpic;:-KPIC}} " \ + LINUX_OR_ANDROID_CC ("", ANDROID_ASM_SPEC) /* The MIPS assembler has different syntax for .set. We set it to .dummy to trap any errors. */ @@ -90,8 +92,8 @@ along with GCC; see the file COPYING3. If not see #undef ASM_OUTPUT_REG_PUSH #undef ASM_OUTPUT_REG_POP -#undef LIB_SPEC -#define LIB_SPEC "\ +#undef LINUX_SUBTARGET_LIB_SPEC +#define LINUX_SUBTARGET_LIB_SPEC "\ %{pthread:-lpthread} \ %{shared:-lc} \ %{!shared: \ @@ -120,7 +122,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); #endif #define LINUX_DRIVER_SELF_SPECS \ - NO_SHARED_SPECS \ + LINUX_OR_ANDROID_CC(NO_SHARED_SPECS, "") \ MARCH_MTUNE_NATIVE_SPECS, \ /* -mplt has no effect without -mno-shared. Simplify later \ specs handling by removing a redundant option. */ \ @@ -134,7 +136,36 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); LINUX_DRIVER_SELF_SPECS /* Similar to standard Linux, but adding -ffast-math support. */ -#undef ENDFILE_SPEC -#define ENDFILE_SPEC \ - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ - %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" +#undef LINUX_TARGET_MATHFILE_SPEC +#define LINUX_TARGET_MATHFILE_SPEC \ + "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" + +#undef LINK_SPEC +#define LINK_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_SUBTARGET_LINK_SPEC, \ + LINUX_SUBTARGET_LINK_SPEC " " ANDROID_LINK_SPEC) + +#undef SUBTARGET_CC1_SPEC +#define SUBTARGET_CC1_SPEC \ + LINUX_OR_ANDROID_CC (LINUX_SUBTARGET_CC1_SPEC, \ + LINUX_SUBTARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic")) + +#undef CC1PLUS_SPEC +#define CC1PLUS_SPEC \ + LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) + +#undef LIB_SPEC +#define LIB_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_SUBTARGET_LIB_SPEC, \ + LINUX_SUBTARGET_LIB_SPEC " " ANDROID_LIB_SPEC) + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC) + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_TARGET_MATHFILE_SPEC " " \ + GNU_USER_TARGET_ENDFILE_SPEC, \ + LINUX_TARGET_MATHFILE_SPEC " " \ + ANDROID_ENDFILE_SPEC) diff --git a/gcc-4.7/gcc/config/mips/t-linux-android b/gcc-4.7/gcc/config/mips/t-linux-android new file mode 100644 index 000000000..298cad9d5 --- /dev/null +++ b/gcc-4.7/gcc/config/mips/t-linux-android @@ -0,0 +1,3 @@ +MULTILIB_OPTIONS = mips32r2 +MULTILIB_DIRNAMES = mips-r2 +MULTILIB_EXCLUSIONS := diff --git a/gcc-4.7/libstdc++-v3/libsupc++/eh_globals.cc b/gcc-4.7/libstdc++-v3/libsupc++/eh_globals.cc index 0c7f6b760..fa9b5196b 100644 --- a/gcc-4.7/libstdc++-v3/libsupc++/eh_globals.cc +++ b/gcc-4.7/libstdc++-v3/libsupc++/eh_globals.cc @@ -101,6 +101,14 @@ struct __eh_globals_init ~__eh_globals_init() { + /* Work-around for an Android-specific bug, where this destructor + * is called with a NULL object pointer. This is due to a bug in the + * __cxa_finalize() implementation that was only fixed in 2.2. + */ +#ifdef __ANDROID__ + if (this == NULL) + return; +#endif if (_M_init) __gthread_key_delete(_M_key); _M_init = false; |