public inbox for crossgcc@sourceware.org
 help / color / mirror / Atom feed
From: Will Newton <will.newton@gmail.com>
To: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: "crossgcc@sourceware.org" <crossgcc@sourceware.org>,
	"buildroot@uclibc.org" <buildroot@uclibc.org>,
		linaro-toolchain@lists.linaro.org
Subject: Re: [Buildroot] Bizarre behavior of armeb toolchain
Date: Thu, 20 Jun 2013 13:49:00 -0000	[thread overview]
Message-ID: <CAFbHwiT5p8-BGXuWnFRZ6R_nc+FTXdXpdrzy5+0tkmnvA8UcZQ@mail.gmail.com> (raw)
In-Reply-To: <20130620154130.1606594d@skate>

On Thu, Jun 20, 2013 at 2:41 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Hello,
>
> I'm facing a bizarre problem with an armeb toolchain built by
> Buildroot. I'm also posting this to the crossgcc@ list since there are
> some gcc/binutils experts out there.
>
> First, a little bit of background. ARM Big Endian comes into two
> variants:
>
>  * BE32, which was used up to ARMv5, where both the instructions and
>    the data are Big Endian.
>
>  * BE8, which is used since ARMv6, where the instructions remain
>    little-endian and only the data are big-endian.
>
> See
> http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0338g/ch06s05s01.html
> for some details about this.
>
> So, I've built an ARMv7 Cortex-A8 toolchain, with the armeb
> architecture selected. The CROSS-gcc -v shows that it was configured as
> follows:
>
>         --target=armeb-buildroot-linux-uclibcgnueabi
>         --with-abi=aapcs-linux
>         --with-arch=armv7-a
>         --with-tune=cortex-a8
>
> Then, I wrote a simple program that contains some data and
> instructions, built it under several conditions, and observed with
> hexdump whether the data and code was little-endian or big-endian.
>
> And the results are somewhat surprising: when I explicitly pass
> -mbig-endian, I get the proper behavior (BE8 code with code in little
> endian and data in big endian), but when I don't pass any flags to the
> compiler, I get an incorrect behavior: both the code and data are big
> endian, as if the BE8 wasn't used (and readelf confirms that it wasn't
> used). See below the detailed results.
>
> Note that the compiler is supposed to automatically use BE8 on
> ARMv6/ARMv7 and BE32 on ARMv5 and earlier cores.
>
> The data is DEADBEEF, and the instruction is E52DB004.
>
> Flags used                      Observed data   Observed code   Comment
> =======================         =============== =============== =========================================
>
> -mlittle-endian                 EFBEADDE        04B02DE5        Code and data in LE -> OK
> -mbig-endian                    DEADBEEF        04B02DE5        Code LE, data BE, binary marked BE8 -> OK
> no flags                        DEADBEEF        E52DB004        Data BE (ok!), code BE (*NOT* ok) -> NOK
> -march=armv5t -mbig-endian      DEADBEEF        E52DB004        Code and data in BE, on ARMv5 -> OK
> -march=armv5t                   DEADBEEF        E52DB004        Code and data in BE, on ARMv5 -> OK
>
> As can be seen in this table:
>
>  (*) On ARMv5, regardless of whether -mbig-endian is passed or not, the
>  code produced is correct (both code and data are big endian, which is
>  correct for ARMv5 where the big endian mode is BE32)
>
>  (*) On ARMv7 however, the code is different whether -mbig-endian is
>  passed or not, even though an "armeb-linux" compiler is supposed to
>  generate big endian code by default. When no flags is passed, both the
>  data *and* code are big-endian (so it's BE32 like on ARMv5), but
>  passing -mbig-endian makes the thing behave properly (code is
>  little-endian, data is big-endian).
>
> I'm using binutils 2.23.2 and gcc 4.7.3.
>
> Any ideas?

Hi Thomas,

I added linaro-toolchain to CC as there may be someone there who knows
the answer.

--
For unsubscribe information see http://sourceware.org/lists.html#faq

  reply	other threads:[~2013-06-20 13:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-20 13:41 Thomas Petazzoni
2013-06-20 13:49 ` Will Newton [this message]
2013-06-20 13:52 ` [Buildroot] " Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFbHwiT5p8-BGXuWnFRZ6R_nc+FTXdXpdrzy5+0tkmnvA8UcZQ@mail.gmail.com \
    --to=will.newton@gmail.com \
    --cc=buildroot@uclibc.org \
    --cc=crossgcc@sourceware.org \
    --cc=linaro-toolchain@lists.linaro.org \
    --cc=thomas.petazzoni@free-electrons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).