1 From f6dc24bd84625469770a955609b467d3d7c4c829 Mon Sep 17 00:00:00 2001 2 From: David 'Digit' Turner <digit (a] google.com> 3 Date: Fri, 13 Apr 2012 16:14:11 +0200 4 Subject: Add MIPS Android support and default to Little Endian 5 6 Change-Id: I6e8e5ab1d773a8eef02287725246f57c861e0dd6 7 --- 8 gcc-4.4.3/gcc/config.gcc | 6 ++++ 9 gcc-4.4.3/gcc/config/mips/linux.h | 40 ++++++++++++++++++++++++---- 10 gcc-4.4.3/gcc/config/mips/t-linux-android | 3 ++ 11 gcc-4.4.3/gcc/unwind-dw2-fde-glibc.c | 6 +++- 12 4 files changed, 47 insertions(+), 8 deletions(-) 13 create mode 100644 gcc-4.4.3/gcc/config/mips/t-linux-android 14 15 diff --git a/gcc-4.4.3/gcc/config.gcc b/gcc-4.4.3/gcc/config.gcc 16 index e758dc4..755b90d 100644 17 --- a/gcc-4.4.3/gcc/config.gcc 18 +++ b/gcc-4.4.3/gcc/config.gcc 19 @@ -1628,6 +1628,12 @@ mips*-*-linux*) # Linux MIPS, either endian. 20 mipsisa32*) 21 tm_defines="${tm_defines} MIPS_ISA_DEFAULT=32" 22 esac 23 + case ${target} in 24 + *android*) 25 + # Default to little-endian for MIPS Android 26 + # tm_defines="${tm_defines} TARGET_ENDIAN_DEFAULT=0" 27 + tmake_file="$tmake_file mips/t-linux-android" 28 + esac 29 test x$with_llsc != x || with_llsc=yes 30 ;; 31 mips*-*-openbsd*) 32 diff --git a/gcc-4.4.3/gcc/config/mips/linux.h b/gcc-4.4.3/gcc/config/mips/linux.h 33 index 0512ef7..9e3ec05 100644 34 --- a/gcc-4.4.3/gcc/config/mips/linux.h 35 +++ b/gcc-4.4.3/gcc/config/mips/linux.h 36 @@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see 37 /* The GNU C++ standard library requires this. */ \ 38 if (c_dialect_cxx ()) \ 39 builtin_define ("_GNU_SOURCE"); \ 40 + ANDROID_TARGET_OS_CPP_BUILTINS(); \ 41 } while (0) 42 43 #undef SUBTARGET_CPP_SPEC 44 @@ -55,8 +56,8 @@ along with GCC; see the file COPYING3. If not see 45 /* A standard GNU/Linux mapping. On most targets, it is included in 46 CC1_SPEC itself by config/linux.h, but mips.h overrides CC1_SPEC 47 and provides this hook instead. */ 48 -#undef SUBTARGET_CC1_SPEC 49 -#define SUBTARGET_CC1_SPEC "%{profile:-p}" 50 +#undef LINUX_SUBTARGET_CC1_SPEC 51 +#define LINUX_SUBTARGET_CC1_SPEC "%{profile:-p}" 52 53 /* From iris5.h */ 54 /* -G is incompatible with -KPIC which is the default, so only allow objects 55 @@ -67,8 +68,8 @@ along with GCC; see the file COPYING3. If not see 56 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" 57 58 /* Borrowed from sparc/linux.h */ 59 -#undef LINK_SPEC 60 -#define LINK_SPEC \ 61 +#undef LINUX_SUBTARGET_LINK_SPEC 62 +#define LINUX_SUBTARGET_LINK_SPEC \ 63 "%(endian_spec) \ 64 %{shared:-shared} \ 65 %{!shared: \ 66 @@ -103,8 +104,8 @@ along with GCC; see the file COPYING3. If not see 67 #undef ASM_OUTPUT_REG_PUSH 68 #undef ASM_OUTPUT_REG_POP 69 70 -#undef LIB_SPEC 71 -#define LIB_SPEC "\ 72 +#undef LINUX_SUBTARGET_LIB_SPEC 73 +#define LINUX_SUBTARGET_LIB_SPEC "\ 74 %{pthread:-lpthread} \ 75 %{shared:-lc} \ 76 %{!shared: \ 77 @@ -135,7 +135,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); 78 #endif 79 80 #define LINUX_DRIVER_SELF_SPECS \ 81 - NO_SHARED_SPECS \ 82 + LINUX_OR_ANDROID_CC(NO_SHARED_SPECS, "") \ 83 MARCH_MTUNE_NATIVE_SPECS, \ 84 /* -mplt has no effect without -mno-shared. Simplify later \ 85 specs handling by removing a redundant option. */ \ 86 @@ -147,3 +148,30 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); 87 #define DRIVER_SELF_SPECS \ 88 BASE_DRIVER_SELF_SPECS, \ 89 LINUX_DRIVER_SELF_SPECS 90 + 91 +#undef LINK_SPEC 92 +#define LINK_SPEC \ 93 + LINUX_OR_ANDROID_LD (LINUX_SUBTARGET_LINK_SPEC, \ 94 + LINUX_SUBTARGET_LINK_SPEC " " ANDROID_LINK_SPEC) 95 + 96 +#undef SUBTARGET_CC1_SPEC 97 +#define SUBTARGET_CC1_SPEC \ 98 + LINUX_OR_ANDROID_CC (LINUX_SUBTARGET_CC1_SPEC, \ 99 + LINUX_SUBTARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic")) 100 + 101 +#undef CC1PLUS_SPEC 102 +#define CC1PLUS_SPEC \ 103 + LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) 104 + 105 +#undef LIB_SPEC 106 +#define LIB_SPEC \ 107 + LINUX_OR_ANDROID_LD (LINUX_SUBTARGET_LIB_SPEC, \ 108 + LINUX_SUBTARGET_LIB_SPEC " " ANDROID_LIB_SPEC) 109 + 110 +#undef STARTFILE_SPEC 111 +#define STARTFILE_SPEC \ 112 + LINUX_OR_ANDROID_LD (LINUX_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC) 113 + 114 +#undef ENDFILE_SPEC 115 +#define ENDFILE_SPEC \ 116 + LINUX_OR_ANDROID_LD (LINUX_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC) 117 diff --git a/gcc-4.4.3/gcc/config/mips/t-linux-android b/gcc-4.4.3/gcc/config/mips/t-linux-android 118 new file mode 100644 119 index 0000000..298cad9 120 --- /dev/null 121 +++ b/gcc-4.4.3/gcc/config/mips/t-linux-android 122 @@ -0,0 +1,3 @@ 123 +MULTILIB_OPTIONS = mips32r2 124 +MULTILIB_DIRNAMES = mips-r2 125 +MULTILIB_EXCLUSIONS := 126 diff --git a/gcc-4.4.3/gcc/unwind-dw2-fde-glibc.c b/gcc-4.4.3/gcc/unwind-dw2-fde-glibc.c 127 index 11f53dd..bad6082 100644 128 --- a/gcc-4.4.3/gcc/unwind-dw2-fde-glibc.c 129 +++ b/gcc-4.4.3/gcc/unwind-dw2-fde-glibc.c 130 @@ -46,8 +46,10 @@ 131 #include "gthr.h" 132 133 #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ 134 - && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ 135 - || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) 136 + && ((defined(__BIONIC__) && (defined(mips) || defined(__mips__))) \ 137 + || (__GLIBC__ > 2 \ 138 + || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ 139 + || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))) 140 141 #include <link.h> 142 143 -- 144 1.7.6.rc0 145 146