This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PR16350 patch ping - gcc doesn't understand big-endian ARM
- From: Lennert Buytenhek <buytenh at wantstofly dot org>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dank at kegel dot com, David Mentre <Mentre at tcl dot ite dot mee dot com>,vapier at gentoo dot org, ralphs at netwinder dot org
- Date: Thu, 24 Mar 2005 10:57:59 +0100
- Subject: PR16350 patch ping - gcc doesn't understand big-endian ARM
(please CC, I'm not on the list)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16350
arm*b-*-linux-* targets are big-endian ARM targets, but gcc insists on
building a compiler that is little-endian by default, requiring the user
to pass -EB by hand on every gcc invocation. A very simple patch (gcc
4.0 version attached) fixes this and allows plain 'gcc' to create working
binaries.
This is not a regression since it has never worked properly in any gcc
version (3.3, 3.4, 4.0 or 4.1.)
gcc 3.4.2 plus the patch from the PR manages to compile most of Fedora
Core 3 for big-endian ARM (http://skrybele.wantstofly.org/fc3/), modulo
one or two other ICEs (like the one in PR17810.)
--- gcc-4.0-20050305/gcc/config/arm/linux-elf.h.orig 2005-03-23 18:44:54.822707377 +0100
+++ gcc-4.0-20050305/gcc/config/arm/linux-elf.h 2005-03-23 18:46:18.228560206 +0100
@@ -31,19 +31,33 @@
/* Do not assume anything about header files. */
#define NO_IMPLICIT_EXTERN_C
+/*
+ * 'config.gcc' defines TARGET_BIG_ENDIAN_DEFAULT as 1 for arm*b-*
+ * (big endian) configurations.
+ */
+#if TARGET_BIG_ENDIAN_DEFAULT
+#define TARGET_ENDIAN_DEFAULT ARM_FLAG_BIG_END
+#define TARGET_ENDIAN_OPTION "mbig-endian"
+#define TARGET_LINKER_EMULATION "armelfb_linux"
+#else
+#define TARGET_ENDIAN_DEFAULT 0
+#define TARGET_ENDIAN_OPTION "mlittle-endian"
+#define TARGET_LINKER_EMULATION "armelf_linux"
+#endif
+
#undef TARGET_DEFAULT_FLOAT_ABI
#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
#undef TARGET_DEFAULT
-#define TARGET_DEFAULT (0)
+#define TARGET_DEFAULT (TARGET_ENDIAN_DEFAULT)
#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6
-#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
+#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION " -p"
#undef MULTILIB_DEFAULTS
#define MULTILIB_DEFAULTS \
- { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" }
+ { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" }
/* The GNU C++ standard library requires that these macros be defined. */
#undef CPLUSPLUS_CPP_SPEC
@@ -90,7 +104,7 @@
%{rdynamic:-export-dynamic} \
%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
-X \
- %{mbig-endian:-EB}" \
+ %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
SUBTARGET_EXTRA_LINK_SPEC
#define TARGET_OS_CPP_BUILTINS() \
--- gcc-4.0-20050305/gcc/config.gcc.orig 2005-03-23 18:46:23.318105335 +0100
+++ gcc-4.0-20050305/gcc/config.gcc 2005-03-23 18:47:41.592546386 +0100
@@ -650,6 +650,11 @@
;;
arm*-*-linux*) # ARM GNU/Linux with ELF
tm_file="dbxelf.h elfos.h linux.h arm/elf.h arm/linux-gas.h arm/linux-elf.h arm/aout.h arm/arm.h"
+ case $target in
+ arm*b-*)
+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
+ ;;
+ esac
tmake_file="${tmake_file} arm/t-arm arm/t-linux"
extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
gnu_ld=yes