This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Compiler Memory Alignment Issue



Yann, Johannes, Bob, Martin, All,

Thank you for all your information. I have updated to
C-compiler 4.4.4 and am no longer seeing the alignment
issue.

I have also tried the suggestion to update /proc/cpu/alignment
and that works as well with the older compiler.

I will point out to the developers in my group to try to use
"compliant" coding methods when casting between types.

Thanks again.

-Rick Koch

----------------------------------------
> Date: Fri, 3 Feb 2012 15:13:59 +0100

> From: js@sig21.net

> To: yann.morin.1998@free.fr

> CC: crossgcc@sourceware.org; bob.dunlop@xyzzy.org.uk; n1gp@hotmail.com; martinwguy@gmail.com

> Subject: Re: Compiler Memory Alignment Issue

>

> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]