public inbox for crossgcc@sourceware.org
 help / color / mirror / Atom feed
From: Johannes Stezenbach <js@sig21.net>
To: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: crossgcc@sourceware.org, Bob Dunlop <bob.dunlop@xyzzy.org.uk>,
	Richard Koch <n1gp@hotmail.com>,
	Martin Guy <martinwguy@gmail.com>
Subject: Re: Compiler Memory Alignment Issue
Date: Fri, 03 Feb 2012 14:14:00 -0000	[thread overview]
Message-ID: <20120203141359.GA13360@sig21.net> (raw)
In-Reply-To: <201202031421.23553.yann.morin.1998@free.fr>

Hi Yann,

On Fri, Feb 03, 2012 at 02:21:23PM +0100, Yann E. MORIN wrote:
> On Friday 03 February 2012 11:16:27 Bob Dunlop wrote:
> > On Thu, Feb 02 at 01:15, Richard Koch wrote:
> > > I'm seeing an alignment issue when I'm incrementing a pointer.
> 
> I Just tried your .config and your sample C code, and it seems to work here
> (with the buffer overflow fixed):

As Martin Guy pointed out the issue may be caused
by wrong alignment.  In fact the behaviour of the code
is undefined according to C99 if buffer is not suitably aligned:
https://www.securecoding.cert.org/confluence/display/seccode/EXP36-C.+Do+not+convert+pointers+into+more+strictly+aligned+pointer+types

I'd suggest to add a printf for the buffer address.

For ARM, unaligned access is supported for ARMv6+, in ARMv5
unaligned write is UNPREDICTABLE (unaligned read is
defined as rotated read from aligned address).
Not sure what's the default CPU for qemu-arm but
Richard has ARMv5.  I know Linux on ARM926EJ-S can
fix it up in sw like Martin described, but I'm not
sure every ARMv5 CPU supports alignment trap.


Johannes

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

  reply	other threads:[~2012-02-03 14:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-02 18:15 Richard Koch
2012-02-02 23:09 ` Martin Guy
2012-02-02 23:26 ` Rod Nussbaumer
2012-02-03  9:52 ` Martin Guy
2012-02-03 10:16 ` Bob Dunlop
2012-02-03 13:21   ` Yann E. MORIN
2012-02-03 14:14     ` Johannes Stezenbach [this message]
2012-02-03 14:23       ` Yann E. MORIN
2012-02-03 20:41         ` Johannes Stezenbach
2012-02-03 15:13       ` Richard Koch

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=20120203141359.GA13360@sig21.net \
    --to=js@sig21.net \
    --cc=bob.dunlop@xyzzy.org.uk \
    --cc=crossgcc@sourceware.org \
    --cc=martinwguy@gmail.com \
    --cc=n1gp@hotmail.com \
    --cc=yann.morin.1998@free.fr \
    /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).