The triplet armv5b-softfloat-linux gives a binutils package that generates ARM big endian object files by default, but gcc insists that armv5b-softfloat-linux is little endian.
Created attachment 6680 [details] This is a suggested fix to make gcc understand arm*b-*
As aways patches goto gcc-patches@gcc.gnu.org after reading <http://gcc.gnu.org/contribute.html>.
He did submit it to gcc-patches; see http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00233.html The patch seems to fix a real gcc build problem here; I'm adding it to crosstool for gcc-3.4.[01].
Confirmed.
this also applies pretty nicely to 3.3.5, 3.4.2, 3.4.3, and even gcc cvs HEAD :( one question though ... going by config/arm/arm.h, wouldnt you want to use this logic instead ? #if TARGET_BIG_ENDIAN_DEFAULT #define TARGET_ENDIAN_DEFAULT ARM_FLAG_BIG_END #else #define TARGET_ENDIAN_DEFAULT -ARM_FLAG_BIG_END #endif granted i havent fully tested this change from '0' to '-ARM_FLAG_BIG_END', but it *seems* to work :) also, what do we have to do in order to get this into mainline gcc ? this simple patch has been hanging around for a while :/
Created attachment 8444 [details] equivalent patch for gcc 4.0 20050305
Created attachment 8445 [details] proposed patch for gcc 3.4.0 fixes regex for big-endian target triples
Created attachment 8446 [details] proposed patch for gcc 4.0-20050305 fix regex for big-endian target triples
Created attachment 11245 [details] gcc-4.1.0-arm-bigendian.patch gcc-4.1.x needs slight tweak since all the ARM_FLAG_* defines have been cut this patch applies with a little fuzz to mainline
Created attachment 12042 [details] fix target linker emulation for arm elf and eabi
(In reply to comment #9) > Created an attachment (id=11245) [edit] > gcc-4.1.0-arm-bigendian.patch > > gcc-4.1.x needs slight tweak since all the ARM_FLAG_* defines have been cut > this patch applies with a little fuzz to mainline I've rediffed that patch against 4.1.1. If you try to build a big-endian eabi toolchain, you need another fix (see patch of gcc/config/arm/linux-eabi.h)
Created attachment 12542 [details] fix target linker emulation for arm elf and eabi (take 2) If you try to build a big-endian eabi toolchain, you need another fix (see patch of gcc/config/arm/linux-eabi.h)
Created attachment 12705 [details] fix target linker emulation for arm elf and eabi (take 3) If you try to build a big-endian eabi toolchain, you need another fix (see patch of gcc/config/arm/linux-eabi.h)
Created attachment 14503 [details] updated to gcc-4.3 trunk updated against gcc-trunk (for 4.3.0)
Subject: Bug 16350 Author: nickc Date: Thu Nov 8 13:44:09 2007 New Revision: 129999 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129999 Log: PR target/16350 * config.gcc: For arm*b-* define TARGET_BIG_ENDIAN_DEFAULT. * config/arm/linux-elf.h (TARGET_ENDIAN_DEFAULT): Define based on TARGET_BIG_ENDIAN_DEFAULT. Use for MULTILIB_DEFAULTS. (TARGET_DEFAULT): Set according to TARGET_ENDIAN_DEFAULT. (LINUX_TARGET_LINK_SPEC): Pass -mlittle-endian on to the assembler. * config/arm/linux-eabi.h (TARGET_LINKER_EMULATION): Set according to TARGET_BIG_ENDIAN_DEFAULT. (SUBTARGET_EXTRA_LINK_SPEC): Likewise. * gcc/config/arm/bpabi.h (TARGET_DEFAULT_MASK): Set according to TARGET_BIG_ENDIAN_DEFAULT. Modified: trunk/gcc/ChangeLog trunk/gcc/config.gcc trunk/gcc/config/arm/bpabi.h trunk/gcc/config/arm/linux-eabi.h trunk/gcc/config/arm/linux-elf.h
Hi Bernhard, I have applied your patch. I made one small change: I adjusted the new comments in the header files to: /* TARGET_BIG_ENDIAN_DEFAULT is set in config.gcc for big endian configurations. */ This was conformance with the GNU Coding Standards and also for brevity. Cheers Nick
Subject: Re: gcc only understands little endian ARM systems When I (not Bernhard) wrote the original patch, Richard Earnshaw didn't like the approach. See: http://gcc.gnu.org/ml/gcc-patches/2005-03/msg02265.html
Subject: Bug number PR16350 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00358.html
Subject: Bug number PR16350 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00362.html
I notice that the latest patch attached to this bug report doesn't quite match up with what was committed as per comment #15: this bit in gcc/config/arm/linux-elf.h wasn't changed: #undef MULTILIB_DEFAULTS #define MULTILIB_DEFAULTS \ - { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" } + { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" } I don't know if that was deliberate or not, but my guess based on the revision log for the change is that it was accidental, since the log explicitly says "use it for MULTILIB_DEFAULTS".
*** Bug 39975 has been marked as a duplicate of this bug. ***
Nick, As mentioned in #22 the following hunk that was in the patch was not applied: diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h index 07455ee..d8e65d2 100644 --- a/gcc/config/arm/linux-elf.h +++ b/gcc/config/arm/linux-elf.h @@ -51,7 +51,7 @@ #undef MULTILIB_DEFAULTS #define MULTILIB_DEFAULTS \ - { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" } + { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" } /* Now we define the strings used to build the spec file. */ #undef LIB_SPEC Please install.
*** Bug 42081 has been marked as a duplicate of this bug. ***
ping. Although nick's ChangeLog in comment #c15 mentiones the "Use for MULTILIB_DEFAULTS" the hunk in comment #22 and #24 did not end up in svn: * config/arm/linux-elf.h (TARGET_ENDIAN_DEFAULT): Define based on TARGET_BIG_ENDIAN_DEFAULT. Use for MULTILIB_DEFAULTS. (TARGET_DEFAULT): Set according to TARGET_ENDIAN_DEFAULT.
The precise scope of this bug is unclear to me. Big endian Linux targets _do_ seem to work now, and -mbig-endian generates correct code regardless; however, non-Linux big-endian targets do not seem to be recognized as big-endian by default (which means libgcc is built in little endian mode, etc.). See bug 52187 (which may be a dupe of this one, depending on how you interpret the scope of this bug).
(In reply to comment #27) > The precise scope of this bug is unclear to me. It's linux specific. > Big endian Linux targets _do_ seem to work now, and -mbig-endian generates > correct code regardless; however, non-Linux big-endian targets do not seem to > be recognized as big-endian by default (which means libgcc is built in little > endian mode, etc.). > > See bug 52187 (which may be a dupe of this one, depending on how you interpret > the scope of this bug). As Richard sid (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52187#c3) you can activate multilib on non-linux target and have both big and little endian libgcc. regards, Marc
(In reply to comment #27) > The precise scope of this bug is unclear to me. It's linux specific. > Big endian Linux targets _do_ seem to work now, and -mbig-endian generates > correct code regardless; however, non-Linux big-endian targets do not seem to > be recognized as big-endian by default (which means libgcc is built in little > endian mode, etc.). > > See bug 52187 (which may be a dupe of this one, depending on how you interpret > the scope of this bug). As Richard said (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52187#c3) you can activate multilib on non-linux target and have both big and little endian libgcc. regards, Marc
I hit this bug trying to build a GCC 4.6.2 that defaulted to ARMv7-a big-endian. Correct code would only be produced if "-mbig-endian" was passed during linking so that the --be8 flag was passed to the linker, but this meant that the compiler on my target system defaulted to producing code that didn't work on the target system -- not pretty. This particular issue has been fixed in 4.7.3 and later, however: 2012-07-25 Bharathi Seshadri <bseshadr@cisco.com> Jim Wilson <jimwilso@cisco.com> * config/arm/bpabi.h (BE8_LINK_SPEC): Set according to TARGET_BIG_ENDIAN_DEFAULT. From http://gcc.gnu.org/git/gcc.git: commit c6e19dd6c296449f6d9e54d630f8198acf103d24 Author: wilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed Jul 25 20:13:46 2012 +0000 Pass -be8 by default for armv7-a when configured big-endian. config/arm/bpabi.h (BE8_LINK_SPEC): Set according to TARGET_BIG_ENDIAN_DEFAULT. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@189867 138bc75d-0d04-0410-961f-82ee72b054a4 Backporting this patch to 4.6.2 means that I now have a compiler that produces correct code just from appending "eb" to the CPU in the target triplet and configuring GCC with the correct --with-arch= flag.
Ignore the comment about GCC 4.7.3, which doesn't even exist. Looks like the fix is only in trunk so far.
Fixed for 4.8.