From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9024 invoked by alias); 3 Feb 2012 14:14:24 -0000 Received: (qmail 9009 invoked by uid 22791); 3 Feb 2012 14:14:23 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,TW_QE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from bar.sig21.net (HELO bar.sig21.net) (80.81.252.164) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Feb 2012 14:14:08 +0000 Received: from p5099b351.dip0.t-ipconnect.de ([80.153.179.81] helo=zzz.local) by bar.sig21.net with esmtpsa (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.69) (envelope-from ) id 1RtJtp-0004LA-49; Fri, 03 Feb 2012 15:14:03 +0100 Received: from js by zzz.local with local (Exim 4.77) (envelope-from ) id 1RtJto-0003Xt-0H; Fri, 03 Feb 2012 15:14:00 +0100 Date: Fri, 03 Feb 2012 14:14:00 -0000 From: Johannes Stezenbach To: "Yann E. MORIN" Cc: crossgcc@sourceware.org, Bob Dunlop , Richard Koch , Martin Guy Subject: Re: Compiler Memory Alignment Issue Message-ID: <20120203141359.GA13360@sig21.net> References: <20120203101627.GA13646@xyzzy.org.uk> <201202031421.23553.yann.morin.1998@free.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201202031421.23553.yann.morin.1998@free.fr> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-21-Score: -2.9 (--) X-Spam-21-Report: No, score=-2.9 required=8.0 tests=ALL_TRUSTED=-1,BAYES_00=-1.9 autolearn=ham X-IsSubscribed: yes Mailing-List: contact crossgcc-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: crossgcc-owner@sourceware.org X-SW-Source: 2012-02/txt/msg00036.txt.bz2 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