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


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


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