In functions utilising varargs gcc generates the below prologue, which
unfortunately results in movaps operating on a non 16byte aligned memory
address. In this particular case we should either be ensuring alignment on the
stack variable, or using movups. I have reason to believe, from discussion on
#gcc that this bug may be present in mainline.

Thanks, Zwane


/usr/bin/gcc -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/3.4.2/include/
-Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common
-march=nocona -mno-red-zone -mcmodel=kernel -pipe -fno-reorder-blocks
-Wno-sign-compare -fno-asynchronous-unwind-tables -funit-at-a-time -DMODULE -O2
-c -o test.o test.c

int z_printf(int fd, const char * fmt, ...)
{
        __asm__ __volatile__("nop");
        return 0;
}

0000000000000000 <z_printf>:
   0:   48 81 ec b8 00 00 00    sub    $0xb8,%rsp
   7:   48 89 54 24 10          mov    %rdx,0x10(%rsp)
   c:   0f b6 d0                movzbl %al,%edx
   f:   48 89 4c 24 18          mov    %rcx,0x18(%rsp)
  14:   48 8d 04 95 00 00 00    lea    0x0(,%rdx,4),%rax
  1b:   00
  1c:   48 c7 c2 00 00 00 00    mov    $0x0,%rdx
  23:   4c 89 44 24 20          mov    %r8,0x20(%rsp)
  28:   48 29 c2                sub    %rax,%rdx
  2b:   48 8d 84 24 af 00 00    lea    0xaf(%rsp),%rax
  32:   00
  33:   4c 89 4c 24 28          mov    %r9,0x28(%rsp)
  38:   ff e2                   jmpq   *%edx
  3a:   0f 29 78 f1             movaps %xmm7,0xfffffffffffffff1(%rax)
  3e:   0f 29 70 e1             movaps %xmm6,0xffffffffffffffe1(%rax)
  42:   0f 29 68 d1             movaps %xmm5,0xffffffffffffffd1(%rax)
  46:   0f 29 60 c1             movaps %xmm4,0xffffffffffffffc1(%rax)
  4a:   0f 29 58 b1             movaps %xmm3,0xffffffffffffffb1(%rax)
  4e:   0f 29 50 a1             movaps %xmm2,0xffffffffffffffa1(%rax)
  52:   0f 29 48 91             movaps %xmm1,0xffffffffffffff91(%rax)
  56:   0f 29 40 81             movaps %xmm0,0xffffffffffffff81(%rax)
  5a:   90                      nop
  5b:   31 c0                   xor    %eax,%eax
  5d:   48 81 c4 b8 00 00 00    add    $0xb8,%rsp
  64:   c3                      retq

Giving us;
> -0xb8 + 0xa5 + -15
        -34     [0xffffffde]

-- 
           Summary: gcc generated movaps instruction used on unaligned stack
                    variable
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zwane at arm dot linux dot org dot uk
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-redhat-linux
  GCC host triplet: x86_64-redhat-linux
GCC target triplet: x86_64-redhat-linux


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

Reply via email to