From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24227 invoked by alias); 3 Feb 2012 13:21:43 -0000 Received: (qmail 24111 invoked by uid 22791); 3 Feb 2012 13:21:41 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,TW_QE X-Spam-Check-By: sourceware.org Received: from p-mail2.rd.francetelecom.com (HELO p-mail2.rd.francetelecom.com) (195.101.245.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Feb 2012 13:21:26 +0000 Received: from p-mail2.rd.francetelecom.com (localhost.localdomain [127.0.0.1]) by localhost (Postfix) with SMTP id 390E4E30375; Fri, 3 Feb 2012 14:21:57 +0100 (CET) Received: from ftrdsmtp2.rd.francetelecom.fr (unknown [10.192.128.47]) by p-mail2.rd.francetelecom.com (Postfix) with ESMTP id 31ACAE30372; Fri, 3 Feb 2012 14:21:57 +0100 (CET) Received: from ftrdmel11.rd.francetelecom.fr ([10.192.128.45]) by ftrdsmtp2.rd.francetelecom.fr with Microsoft SMTPSVC(6.0.3790.4675); Fri, 3 Feb 2012 14:21:24 +0100 Received: from r-lnx-ilmarinen.localnet ([10.194.59.183]) by ftrdmel11.rd.francetelecom.fr with Microsoft SMTPSVC(6.0.3790.4675); Fri, 3 Feb 2012 14:21:24 +0100 From: "Yann E. MORIN" To: crossgcc@sourceware.org Subject: Re: Compiler Memory Alignment Issue Date: Fri, 03 Feb 2012 13:21:00 -0000 User-Agent: KMail/1.13.5 (Linux/3.2.2-ilmarinen-nv; KDE/4.4.5; x86_64; ; ) Cc: Bob Dunlop , Richard Koch References: <20120203101627.GA13646@xyzzy.org.uk> In-Reply-To: <20120203101627.GA13646@xyzzy.org.uk> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201202031421.23553.yann.morin.1998@free.fr> 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/msg00035.txt.bz2 Richard, Bob, All, 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): $ arm-none-linux-gnueabi-gcc -o ess ess.c $ qemu-arm -L ..../arm-none-linux-gnueabi/sysroot ./ess size of int is: 4 buffer[0]=ff buffer[1]=ff buffer[2]=ff buffer[3]=ff buffer[4]=34 buffer[5]=12 buffer[6]=0 buffer[7]=0 The assembly code corresponding to the assignment is (from gdb's disas /m): 14 *(ptr + 1) = 0x1234; 0x00008400 <+56>: ldr r3, [r11, #-16] 0x00008404 <+60>: add r2, r3, #4 0x00008408 <+64>: mov r3, #4608 ; 0x1200 0x0000840c <+68>: add r3, r3, #52 ; 0x34 0x00008410 <+72>: str r3, [r2] As you can see for @0x8404, an offset of #4 is added to the address of the array. Regards, Yann E. MORIN. -- .-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +0/33 662376056 | Software Designer | \ / CAMPAIGN | ^ | | --==< O_o >==-- '------------.-------: X AGAINST | /e\ There is no | | http://ymorin.is-a-geek.org/ | (*_*) | / \ HTML MAIL | """ conspiracy. | '------------------------------'-------'------------------'--------------------' -- For unsubscribe information see http://sourceware.org/lists.html#faq