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