This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: big endian toolchains
- To: Nicolas Pitre <nico at cam dot org>
- Subject: Re: big endian toolchains
- From: Philip Blundell <philb at gnu dot org>
- Date: Sat, 26 May 2001 14:56:57 +0100
- Cc: gcc-patches at gcc dot gnu dot org
- References: <Pine.LNX.4.33.0105242025510.1215-100000@xanadu.home>
Does this do the trick for you? Use a target name of `armeb-linux' when you
configure.
(gcc-patches folk: I'd like to apply this to the mainline, assuming I can
still bootstrap a little-endian configuration.)
p.
2001-05-26 Philip Blundell <philb@gnu.org>
* config/arm/arm.h (CPP_ENDIAN_DEFAULT_SPEC): Only define if not
already defined.
* config/arm/elf.h (ASM_ENDIAN_SPEC): Provide default definition.
(ASM_SPEC): Replace explicit -EB with %(asm_endian_spec).
(SUBTARGET_EXTRA_SPECS): Add asm_endian_spec.
* config/arm/linux-elf.h (TARGET_DEFAULT): Include
DEFAULT_ENDIAN_FLAG.
(MULTILIB_DEFAULTS): Replace "mlittle-endian" with
MULTILIB_ENDIAN.
(SUBTARGET_EXTRA_LINK_SPEC): Delete.
(LINK_SPEC): Replace SUBTARGET_EXTRA_LINK_SPEC with "-m
armelf_linux -p". Replace "-EB" with %(link_endian_spec).
(SUBTARGET_EXTRA_SPECS): Define.
* config/arm/linux-le.h, config/arm/linux-be.h: New files.
* config.gcc (arm*-*-linux*): Use them as appropriate. Only set
thread_file if $enable_threads is "yes".
Index: config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.63
diff -u -p -u -r1.63 config.gcc
--- config.gcc 2001/05/25 23:08:55 1.63
+++ config.gcc 2001/05/26 13:51:32
@@ -571,13 +571,21 @@ arm*-*-netbsd*)
use_collect2=yes
;;
arm*-*-linux*) # ARM GNU/Linux with ELF
+ case $machine in
+ arm*b-*-linux*)
+ tm_file=arm/linux-be.h
+ ;;
+ *)
+ tm_file=arm/linux-le.h
+ ;;
+ esac
xmake_file=x-linux
- tm_file="arm/linux-elf.h"
+ tm_file="$tm_file arm/linux-elf.h"
tmake_file="t-slibgcc-elf-ver t-linux arm/t-linux"
extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
gnu_ld=yes
case x${enable_threads} in
- x | xyes | xpthreads | xposix)
+ xyes)
thread_file='posix'
;;
esac
Index: config/arm/arm.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm.h,v
retrieving revision 1.104
diff -u -p -u -r1.104 arm.h
--- arm.h 2001/05/26 01:31:37 1.104
+++ arm.h 2001/05/26 13:51:35
@@ -243,7 +243,9 @@ Unrecognized value in TARGET_CPU_DEFAULT
"
/* Default is little endian. */
+#ifndef CPP_ENDIAN_DEFAULT_SPEC
#define CPP_ENDIAN_DEFAULT_SPEC "-D__ARMEL__ %{mthumb:-D__THUMBEL__}"
+#endif
/* Add a define for interworking. Needed when building libgcc.a.
This must define __THUMB_INTERWORK__ to the pre-processor if
Index: config/arm/elf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/elf.h,v
retrieving revision 1.26
diff -u -p -u -r1.26 elf.h
--- elf.h 2001/05/04 16:16:43 1.26
+++ elf.h 2001/05/26 13:51:36
@@ -40,21 +40,26 @@ Boston, MA 02111-1307, USA. */
#ifndef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
{ "subtarget_extra_asm_spec", SUBTARGET_EXTRA_ASM_SPEC },
+ { "asm_endian_spec", ASM_ENDIAN_SPEC },
#endif
#ifndef SUBTARGET_EXTRA_ASM_SPEC
#define SUBTARGET_EXTRA_ASM_SPEC ""
#endif
+#ifndef ASM_ENDIAN_SPEC
+#define ASM_ENDIAN_SPEC "%{mbig-endian:-EB}"
+#endif
+
#ifndef ASM_SPEC
#define ASM_SPEC "\
-%{mbig-endian:-EB} \
%{mcpu=*:-m%*} \
%{march=*:-m%*} \
%{mapcs-*:-mapcs-%*} \
%{mapcs-float:-mfloat} \
%{msoft-float:-mno-fpu} \
%{mthumb-interwork:-mthumb-interwork} \
+%(asm_endian_spec) \
%(subtarget_extra_asm_spec)"
#endif
Index: config/arm/linux-elf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/linux-elf.h,v
retrieving revision 1.25
diff -u -p -u -r1.25 linux-elf.h
--- linux-elf.h 2001/04/16 18:30:36 1.25
+++ linux-elf.h 2001/05/26 13:51:36
@@ -27,10 +27,9 @@ Boston, MA 02111-1307, USA. */
#define NO_IMPLICIT_EXTERN_C
/* Default is to use APCS-32 mode. */
-#define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_MMU_TRAPS)
-#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
+#define TARGET_DEFAULT (DEFAULT_ENDIAN_FLAG | ARM_FLAG_APCS_32 | ARM_FLAG_MMU_TRAPS)
#define MULTILIB_DEFAULTS \
- { "marm", "mlittle-endian", "mhard-float", "mapcs-32", "mno-thumb-interwork" }
+ { "marm", MULTILIB_ENDIAN, "mhard-float", "mapcs-32", "mno-thumb-interwork" }
#define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
/* This was defined in linux.h. Define it here also. */
@@ -46,7 +45,6 @@ Boston, MA 02111-1307, USA. */
%{!shared: %{pthread:-lpthread} \
%{profile:-lc_p} %{!profile: -lc}}"
-
#define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
/* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
@@ -77,9 +75,12 @@ Boston, MA 02111-1307, USA. */
%{symbolic:-Bsymbolic} \
%{rdynamic:-export-dynamic} \
%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
- -X \
- %{mbig-endian:-EB}" \
- SUBTARGET_EXTRA_LINK_SPEC
+ -X -m armelf_linux -p \
+ %(link_endian_spec)"
+
+#define SUBTARGET_EXTRA_SPECS \
+ { "link_endian_spec", LINK_ENDIAN_SPEC }, \
+ { "asm_endian_spec", ASM_ENDIAN_SPEC },
#undef CPP_PREDEFINES
#define CPP_PREDEFINES \
--- /dev/null Tue Apr 10 10:26:39 2001
+++ config/arm/linux-le.h Sat May 26 10:43:59 2001
@@ -0,0 +1,4 @@
+#define DEFAULT_ENDIAN_FLAG 0
+#define MULTILIB_ENDIAN "mlittle-endian"
+#define LINK_ENDIAN_SPEC "%{mbig-endian:-EB} %{!mbig-endian:-EL}"
+#define ASM_ENDIAN_SPEC "%{mbig-endian:-EB} %{!mbig-endian:-EL}"
--- /dev/null Tue Apr 10 10:26:39 2001
+++ config/arm/linux-be.h Sat May 26 10:44:30 2001
@@ -0,0 +1,5 @@
+#define DEFAULT_ENDIAN_FLAG ARM_FLAG_BIG_END
+#define MULTILIB_ENDIAN "mbig-endian"
+#define LINK_ENDIAN_SPEC "%{mlittle-endian:-EL} %{!mlittle-endian:-EB}"
+#define ASM_ENDIAN_SPEC "%{mlittle-endian:-EL} %{!mlittle-endian:-EB}"
+#define CPP_ENDIAN_DEFAULT_SPEC "-D__ARMEB__ %{mthumb:-D__THUMBEB__}"