This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/34725] [4.3 regression] gcc 4.3-rev 131213 miscompiles libgcrypt 1.4.0 at -O2 -mtune=i686 -fomit-frame-pointer



------- Comment #4 from jakub at gcc dot gnu dot org  2008-01-20 19:26 -------
It fails even with gcc 4.1.2 and the same CFLAGS, and the problem is just buggy
inline assembly.
Following patch cures this for me:
--- hwfeatures.c.xx     2007-12-05 12:03:33.000000000 +0100
+++ hwfeatures.c        2008-01-20 19:54:54.000000000 +0100
@@ -79,13 +79,12 @@ detect_ia32_gnuc (void)
     ("pushl %%ebx\n\t"           /* Save GOT register.  */
      "xorl  %%eax, %%eax\n\t"    /* 0 -> EAX.  */
      "cpuid\n\t"                 /* Get vendor ID.  */
-     "leal  %0, %%eax\n\t"       /* EBX,EDX,ECX -> VENDOR_ID.  */
-     "movl  %%ebx, (%%eax)\n\t"
-     "movl  %%edx, 4(%%eax)\n\t"
-     "movl  %%ecx, 8(%%eax)\n\t"
+     "movl  %%ebx, (%1)\n\t"    /* EBX,EDX,ECX -> VENDOR_ID.  */
+     "movl  %%edx, 4(%1)\n\t"
+     "movl  %%ecx, 8(%1)\n\t"
      "popl  %%ebx\n"
      : "=m" (vendor_id)
-     :
+     : "S" (&vendor_id[0])
      : "%eax", "%ecx", "%edx", "cc"
      );
   vendor_id[12] = 0;

The problem is that %0 corresponding to "=m" is expanded when %esp is different
from what it has been originally on inline asm entry (and exit).  Without
-fomit-frame-pointer GCC will usually use (%ebp+N) for %0, but with
-fomit-frame-pointer it uses (%esp+M), but as there is pushl %ebx before this,
it means the inline asm stores to a different location than expected.


-- 

jakub at gcc dot gnu dot org changed:

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


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


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