From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] ARM: prevent misaligned array inits
Date: Tue, 02 Oct 2012 14:06:53 -0600 [thread overview]
Message-ID: <506B495D.2030306@wwwdotorg.org> (raw)
In-Reply-To: <1349203564-27150-1-git-send-email-albert.u.boot@aribaud.net>
On 10/02/2012 12:46 PM, Albert ARIBAUD wrote:
> Under option -munaligned-access, gcc can perform local char
> or 16-bit array initializations using misaligned native
> accesses which will throw a data abort exception. Fix files
> where these array initializations were unneeded, and for
> files known to contain such initializations, enforce gcc
> option -mno-unaligned-access.
> +++ b/doc/README.arm-unaligned-accesses
...
> +However this will only apply to the version of gcc which will have such
> +an option. For other versions, there are four workarounds:
> +
> +a) Enforce as a rule that array initializations as described above
> + are forbidden. This is generally not acceptable as they are valid,
> + and usual, C constructs. The only case where they could be rejected
> + is when they actually equate to a const char* declaration, i.e. the
> + array is initialized and never modified in the function's scope.
> +
> +b) Drop the requirement on unaligned accesses at least for ARMv7,
> + i.e. do not throw a data abort exception upon unaligned accesses.
> + But that will allow adding badly aligned code to U-Boot, only for
> + it to fail when re-used with another, more strict, target, possibly
> + once the bad code is already in mainline.
> +
> +c) Relax the -munified-access rule globally. This will prevent native
I assume that's meant to say -munaligned-access?
> + unaligned accesses of course, but that will also hide any bug caused
> + by a bad unaligned access, making it much harder to diagnose it. It
> + is actually what already happens when building ARM targets with a
> + pre-4.7 gcc, and it may actually already hide some bugs yet unseen
> + until the target gets compiled with m-unaligned-access.
s/m-/-m/
> +d) Relax the -munified-access rule only for for files susceptible to
I assume that's meant to say -munaligned-access?
> + the local initialized array issue. This minimizes the quantity of
> + code which can hide unwanted misaligned accesses.
> +
> +Considering the rarity of actual occurrences (as of this writing, 5
> +files out of 7840 in U-Boot, or .3%, contain an initialized local char
> +array which cannot actually be replaced with a const char*), detection
> +if the issue in patches should not be asked from contributors.
I assume therefore that option (d) was chosen. Perhaps state this
explicitly?
next prev parent reply other threads:[~2012-10-02 20:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-02 18:46 [U-Boot] [RFC] ARM: prevent misaligned array inits Albert ARIBAUD
2012-10-02 19:13 ` Joakim Tjernlund
2012-10-02 20:05 ` Albert ARIBAUD
2012-10-03 8:22 ` Joakim Tjernlund
2012-10-02 20:06 ` Stephen Warren [this message]
2012-10-02 21:20 ` Albert ARIBAUD
2012-10-02 21:42 ` Måns Rullgård
2012-10-03 7:29 ` Mark Marshall
2012-10-04 20:22 ` Albert ARIBAUD
2012-10-04 12:02 ` Thierry Reding
2012-10-04 19:10 ` Lucas Stach
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=506B495D.2030306@wwwdotorg.org \
--to=swarren@wwwdotorg.org \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.