This is with GCC trunk r126556 (2007-07-11).

Note that the instruction at 0x08048388 means that the offset from
%esp to the CFA is not a constant, but the .debug_frame information
for 0x0804838e and beyond claims the CFA is a constant distance from
either %esp or %ebp.

The proper behavior would be for the CFI to place the CFA relative to
%ecx from 0x08048388 to the end of the function.

$ cat align.c
int main(int argc, char **argv)
{
  sleep (1);
  return argc;
}
$ ~/gcc/pub/bin/gcc -g align.c -o align
$ readelf -wfF align
The section .eh_frame contains:

00000000 ZERO terminator


The section .debug_frame contains:

00000000 00000010 ffffffff CIE "" cf=1 df=-4 ra=8
   LOC   CFA      ra   
00000000 r4+4     c-4  

00000014 00000024 00000000 FDE cie=00000000 pc=08048384..080483b0
   LOC   CFA      r3   r4   r5   ra   
08048384 r4+4     u    u    u    c-4  
08048388 r1+0     u    r1   u    c-4  
0804838e r4+4     u    r1   u    c-4  
0804838f r4+8     u    r1   c-8  c-4  
08048391 r5+8     u    r1   c-8  c-4  
08048393 r5+8     c-12 c-16 c-8  c-4  

$ gdb align
GNU gdb Red Hat Linux (6.5-15.fc6rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db
library "/lib/libthread_db.so.1".

(gdb) disass main
Dump of assembler code for function main:
0x08048384 <main+0>:    lea    0x4(%esp),%ecx
0x08048388 <main+4>:    and    $0xfffffff0,%esp
0x0804838b <main+7>:    pushl  0xfffffffc(%ecx)
0x0804838e <main+10>:   push   %ebp
0x0804838f <main+11>:   mov    %esp,%ebp
0x08048391 <main+13>:   push   %ebx
0x08048392 <main+14>:   push   %ecx
0x08048393 <main+15>:   sub    $0x10,%esp
0x08048396 <main+18>:   mov    %ecx,%ebx
0x08048398 <main+20>:   movl   $0x1,(%esp)
0x0804839f <main+27>:   call   0x80482a0 <[EMAIL PROTECTED]>
0x080483a4 <main+32>:   mov    (%ebx),%eax
0x080483a6 <main+34>:   add    $0x10,%esp
0x080483a9 <main+37>:   pop    %ecx
0x080483aa <main+38>:   pop    %ebx
0x080483ab <main+39>:   pop    %ebp
0x080483ac <main+40>:   lea    0xfffffffc(%ecx),%esp
0x080483af <main+43>:   ret    
End of assembler dump.
(gdb)


-- 
           Summary: GCC generates incorrect DWARF CFI for SSE stack
                    alignment
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jimb at codesourcery dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to