Compiler Memory Alignment Issue

Johannes Stezenbach js@sig21.net
Fri Feb 3 20:41:00 GMT 2012


On Fri, Feb 03, 2012 at 03:23:33PM +0100, Yann E. MORIN wrote:
> On Friday 03 February 2012 15:13:59 Johannes Stezenbach wrote:
> > 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
> 
> Indeed, but with the same .config (ie the same compiler settings), and the
> same code, I get a correct result, where Richard does not.

Richard has real hardware (ARMv5, Technologics TS-7350 ARM920T).
Since unaligned writes are undefined in ARMv5 qemu-arm is free
to do whatever it wants -- if you don't know what the hw
would do you can't emulate it 100%, I think.


Johannes

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



More information about the crossgcc mailing list