public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/26800]  New: ARM: creates 'strd' instructions for unaligned addresses
@ 2006-03-22 11:59 enrico dot scholz at informatik dot tu-chemnitz dot de
  2006-03-22 12:15 ` [Bug c/26800] " rearnsha at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: enrico dot scholz at informatik dot tu-chemnitz dot de @ 2006-03-22 11:59 UTC (permalink / raw)
  To: gcc-bugs

gcc creates 'strd' instructions which are accessing non-double-word
aligned addresses. This is forbidden accordingly ARM Reference Manual
and causes an alignment exception:

| 10.6.14 STRD
| However, the address of the first of the two words is required to be
| doubleword-aligned (that is, the address must be divisible by 8).



Example:
------------
$ cat foo.c
struct A {
        unsigned int            a;
        unsigned long long      l;
};

int main()
{
        extern struct A volatile        *a;
        a->l = 0;
}

$ arm-xscale-linux-gnu-gcc -c -Os -mabi=aapcs -march=armv5te ./foo.c
$ objdump -d foo.o 

foo.o:     file format elf32-littlearm

Disassembly of section .text:

00000000 <main>:
   0:   e59f3010        ldr     r3, [pc, #16]   ; 18 <.text+0x18>
   4:   e3a00000        mov     r0, #0  ; 0x0
   8:   e5933000        ldr     r3, [r3]
   c:   e3a01000        mov     r1, #0  ; 0x0
  10:   e1c300f8        strd    r0, [r3, #8]
  14:   e12fff1e        bx      lr
  18:   00000000        andeq   r0, r0, r0

------------


AAPCS requires only a 4-Byte alignment for data pointers, so the
external 'a' might point to a non-8 divisible address. The resulting
address at 10: is non-8 divisible too and will cause an alignment
exception.

-------------

$ $C-gcc -v
Using built-in specs.
Target: arm-xscale-linux-gnu
Configured with: ../configure --prefix=/usr --build=i686-redhat-linux-gnu
--host=i686-redhat-linux-gnu --target=arm-xscale-linux-gnu
--with-sysroot=/usr/arm-xscale-linux-gnu/sys-root --disable-__cxa_atexit
--enable-target-optspace --with-gnu-ld --disable-nls --infodir=/usr/share/info
--mandir=/usr/share/man --enable-version-specific-runtime-libs
--enable-languages=c,c++,java,objc --enable-shared --enable-threads
--disable-multilib --with-cpu=xscale --enable-cxx-flags=-mcpu=xscale
-fomit-frame-pointer
Thread model: posix
gcc version 4.1.0


-- 
           Summary: ARM: creates 'strd' instructions for unaligned addresses
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: enrico dot scholz at informatik dot tu-chemnitz dot de
 GCC build triplet: i686-redhat-linux-gnu
  GCC host triplet: i686-redhat-linux-gnu
GCC target triplet: arm-xscale-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26800


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/26800] ARM: creates 'strd' instructions for unaligned addresses
  2006-03-22 11:59 [Bug c/26800] New: ARM: creates 'strd' instructions for unaligned addresses enrico dot scholz at informatik dot tu-chemnitz dot de
@ 2006-03-22 12:15 ` rearnsha at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2006-03-22 12:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rearnsha at gcc dot gnu dot org  2006-03-22 12:15 -------
Invalid.  The AAPCS requires 8-byte alignment of double-word objects (and,
recursively any object containing such an object).  Your struct contains a long
long, which is a double-word object.

See http://www.arm.com/products/DevTools/ABI.html for details.


-- 

rearnsha at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26800


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-22 12:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-22 11:59 [Bug c/26800] New: ARM: creates 'strd' instructions for unaligned addresses enrico dot scholz at informatik dot tu-chemnitz dot de
2006-03-22 12:15 ` [Bug c/26800] " rearnsha at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).