fixup ARM EABI on GCC 4.1.2
[openwrt/staging/wigyori.git] / toolchain / gcc / patches / 4.1.2 / 800-arm-bigendian.patch
1 By Lennert Buytenhek <buytenh@wantstofly.org>
2 Adds support for arm*b-linux* big-endian ARM targets
3
4 See http://gcc.gnu.org/PR16350
5
6 Index: gcc-4.1.1/gcc/config/arm/linux-elf.h
7 ===================================================================
8 --- gcc-4.1.1.orig/gcc/config/arm/linux-elf.h
9 +++ gcc-4.1.1/gcc/config/arm/linux-elf.h
10 @@ -28,19 +28,33 @@
11 #undef TARGET_VERSION
12 #define TARGET_VERSION fputs (" (ARM GNU/Linux with ELF)", stderr);
13
14 +/*
15 + * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
16 + * (big endian) configurations.
17 + */
18 +#if TARGET_BIG_ENDIAN_DEFAULT
19 +#define TARGET_ENDIAN_DEFAULT MASK_BIG_END
20 +#define TARGET_ENDIAN_OPTION "mbig-endian"
21 +#define TARGET_LINKER_EMULATION "armelfb_linux"
22 +#else
23 +#define TARGET_ENDIAN_DEFAULT 0
24 +#define TARGET_ENDIAN_OPTION "mlittle-endian"
25 +#define TARGET_LINKER_EMULATION "armelf_linux"
26 +#endif
27 +
28 #undef TARGET_DEFAULT_FLOAT_ABI
29 #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
30
31 #undef TARGET_DEFAULT
32 -#define TARGET_DEFAULT (0)
33 +#define TARGET_DEFAULT (TARGET_ENDIAN_DEFAULT)
34
35 #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
36
37 -#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
38 +#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION " -p"
39
40 #undef MULTILIB_DEFAULTS
41 #define MULTILIB_DEFAULTS \
42 - { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" }
43 + { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" }
44
45 /* Now we define the strings used to build the spec file. */
46 #undef LIB_SPEC
47 @@ -61,7 +75,7 @@
48 %{rdynamic:-export-dynamic} \
49 %{!dynamic-linker:-dynamic-linker " LINUX_TARGET_INTERPRETER "} \
50 -X \
51 - %{mbig-endian:-EB}" \
52 + %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
53 SUBTARGET_EXTRA_LINK_SPEC
54
55 #undef LINK_SPEC
56 Index: gcc-4.1.1/gcc/config.gcc
57 ===================================================================
58 --- gcc-4.1.1.orig/gcc/config.gcc
59 +++ gcc-4.1.1/gcc/config.gcc
60 @@ -672,6 +672,11 @@ arm*-*-netbsd*)
61 ;;
62 arm*-*-linux*) # ARM GNU/Linux with ELF
63 tm_file="dbxelf.h elfos.h linux.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
64 + case $target in
65 + arm*b-*)
66 + tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
67 + ;;
68 + esac
69 tmake_file="${tmake_file} t-linux arm/t-arm"
70 case ${target} in
71 arm*-*-linux-gnueabi)
72 Index: gcc-4.1.1/gcc/config/arm/linux-eabi.h
73 ===================================================================
74 --- gcc-4.1.1.orig/gcc/config/arm/linux-eabi.h
75 +++ gcc-4.1.1/gcc/config/arm/linux-eabi.h
76 @@ -20,6 +20,17 @@
77 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
78 Boston, MA 02110-1301, USA. */
79
80 +/*
81 + * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
82 + * (big endian) configurations.
83 + */
84 +#undef TARGET_LINKER_EMULATION
85 +#if TARGET_BIG_ENDIAN_DEFAULT
86 +#define TARGET_LINKER_EMULATION "armelfb_linux_eabi"
87 +#else
88 +#define TARGET_LINKER_EMULATION "armelf_linux_eabi"
89 +#endif
90 +
91 /* On EABI GNU/Linux, we want both the BPABI builtins and the
92 GNU/Linux builtins. */
93 #undef TARGET_OS_CPP_BUILTINS
94 @@ -48,7 +59,7 @@
95 #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm10tdmi
96
97 #undef SUBTARGET_EXTRA_LINK_SPEC
98 -#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux_eabi"
99 +#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION
100
101 /* Use ld-linux.so.3 so that it will be possible to run "classic"
102 GNU/Linux binaries on an EABI system. */
103 Index: gcc-4.1.1/gcc/config/arm/bpabi.h
104 ===================================================================
105 --- gcc-4.1.1.orig/gcc/config/arm/bpabi.h
106 +++ gcc-4.1.1/gcc/config/arm/bpabi.h
107 @@ -33,9 +33,19 @@
108 #undef FPUTYPE_DEFAULT
109 #define FPUTYPE_DEFAULT FPUTYPE_VFP
110
111 +/*
112 + * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
113 + * (big endian) configurations.
114 + */
115 +#if TARGET_BIG_ENDIAN_DEFAULT
116 +#define TARGET_ENDIAN_DEFAULT MASK_BIG_END
117 +#else
118 +#define TARGET_ENDIAN_DEFAULT 0
119 +#endif
120 +
121 /* EABI targets should enable interworking by default. */
122 #undef TARGET_DEFAULT
123 -#define TARGET_DEFAULT MASK_INTERWORK
124 +#define TARGET_DEFAULT (MASK_INTERWORK | TARGET_ENDIAN_DEFAULT)
125
126 /* The ARM BPABI functions return a boolean; they use no special
127 calling convention. */