This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: ARM fix for big endian linux-elf targets
Paul Brook wrote:
> > +/* Redefine LINK_SPEC with armelfb_linux. */
> > +#undef SUBTARGET_EXTRA_LINK_SPEC
> > +#define SUBTARGET_EXTRA_LINK_SPEC " -m armelfb_linux -p"
>
> Why is the big-endian flag unconditional here...
>
> > +#undef LINUX_TARGET_LINK_SPEC
> > +#define LINUX_TARGET_LINK_SPEC "%{h*} %{version:-v} \
> > + %{b} \
> > + %{static:-Bstatic} \
> > + %{shared:-shared} \
> > + %{symbolic:-Bsymbolic} \
> > + %{rdynamic:-export-dynamic} \
> > + %{!dynamic-linker:-dynamic-linker " LINUX_TARGET_INTERPRETER "} \
> > + -X \
> > + %{mbig-endian:-EB}" \
>
> But conditional here?
>
I have just copied that part from linux-elf.h
> Also, I don't see any differences between this definition and the one in
> linux-elf.h
>
The complete definition is:
#define LINUX_TARGET_LINK_SPEC "%{h*} %{version:-v} \
%{b} \
%{static:-Bstatic} \
%{shared:-shared} \
%{symbolic:-Bsymbolic} \
%{rdynamic:-export-dynamic} \
%{!dynamic-linker:-dynamic-linker " LINUX_TARGET_INTERPRETER "} \
-X \
%{mbig-endian:-EB}" \
SUBTARGET_EXTRA_LINK_SPEC
and SUBTARGET_EXTRA_LINK_SPEC is modified to another value than in
linux-elf.h:
#define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
vs.
#define SUBTARGET_EXTRA_LINK_SPEC " -m armelfb_linux -p"
linux-elf.h is included before linux-elfb.h and thus we have to
redefine LINUX_TARGET_LINK_SPEC with the new value for
SUBTARGET_EXTRA_LINK_SPEC.
I can propose the following patch that also fixes the problem
described by Hans-Peter Nilsson. Tested by building c,c++,fortran
with --target=armeb-linux --host=x86_64-host_unknown-linux-gnu.
Sebastian
* config.gcc (arm*-*-linux-gnueabi): Refine for arm*b-*-*: include
linux-elfb.h.
(arm*b-*-linux*): Added. Include linux-elfb.h.
* config/arm/linux-elfb.h: New file. Redefine LINK_SPEC and
MULTILIB_DEFAULTS.
Index: config.gcc
===================================================================
--- config.gcc (revision 107303)
+++ config.gcc (working copy)
@@ -675,7 +675,14 @@ arm*-*-linux*) # ARM GNU/Linux with EL
tmake_file="${tmake_file} t-linux arm/t-arm"
case ${target} in
arm*-*-linux-gnueabi)
- tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
+ case ${target} in
+ arm*b-*-*)
+ tm_file="$tm_file arm/linux-elfb.h arm/bpabi.h arm/linux-eabi.h"
+ ;;
+ *)
+ tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
+ ;;
+ esac
tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi"
# The BPABI long long divmod functions return a 128-bit value in
# registers r0-r3. Correctly modeling that requires the use of
@@ -684,6 +691,9 @@ arm*-*-linux*) # ARM GNU/Linux with EL
# The EABI requires the use of __cxa_atexit.
default_use_cxa_atexit=yes
;;
+ arm*b-*-linux*)
+ tm_file="$tm_file arm/linux-elfb.h"
+ ;;
*)
tmake_file="$tmake_file arm/t-linux"
;;
Index: config/arm/linux-elfb.h
===================================================================
--- config/arm/linux-elfb.h (revision 0)
+++ config/arm/linux-elfb.h (revision 0)
@@ -0,0 +1,45 @@
+/* Configuration file for big endian ARM GNU/Linux targets.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ Contributed by Sebastian Pop <pop@cri.ensmp.fr>
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING. If not, write to the Free
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA. */
+
+/* Redefine MULTILIB_DEFAULTS with mbig-endian. */
+#undef MULTILIB_DEFAULTS
+#define MULTILIB_DEFAULTS \
+ { "marm", "mbig-endian", "mhard-float", "mno-thumb-interwork" }
+
+/* Redefine LINK_SPEC with armelfb_linux. */
+#undef SUBTARGET_EXTRA_LINK_SPEC
+#define SUBTARGET_EXTRA_LINK_SPEC " -m armelfb_linux -p"
+
+/* Redefine LINK_SPEC. */
+#undef LINUX_TARGET_LINK_SPEC
+#define LINUX_TARGET_LINK_SPEC "%{h*} %{version:-v} \
+ %{b} \
+ %{static:-Bstatic} \
+ %{shared:-shared} \
+ %{symbolic:-Bsymbolic} \
+ %{rdynamic:-export-dynamic} \
+ %{!dynamic-linker:-dynamic-linker " LINUX_TARGET_INTERPRETER "} \
+ -X -EB" \
+ SUBTARGET_EXTRA_LINK_SPEC
+
+#undef LINK_SPEC
+#define LINK_SPEC LINUX_TARGET_LINK_SPEC
+