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