From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30807 invoked by alias); 3 Feb 2012 20:41:33 -0000 Received: (qmail 30798 invoked by uid 22791); 3 Feb 2012 20:41:32 -0000 X-SWARE-Spam-Status: No, hits=-1.5 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 20:41:16 +0000 Received: from p54bdb567.dip.t-dialin.net ([84.189.181.103] helo=abc.local) by bar.sig21.net with esmtpsa (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.69) (envelope-from ) id 1RtPwP-0005t7-VH; Fri, 03 Feb 2012 21:41:12 +0100 Received: from js by abc.local with local (Exim 4.77) (envelope-from ) id 1RtPwP-0002La-6v; Fri, 03 Feb 2012 21:41:05 +0100 Date: Fri, 03 Feb 2012 20:41: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: <20120203204105.GB2670@sig21.net> References: <201202031421.23553.yann.morin.1998@free.fr> <20120203141359.GA13360@sig21.net> <201202031523.33507.yann.morin.1998@free.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201202031523.33507.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/msg00041.txt.bz2 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