This is the mail archive of the
mailing list for the GCC project.
inline asm clobber bug with -fpic
- To: egcs-bugs at cygnus dot com
- Subject: inline asm clobber bug with -fpic
- From: Sylvain Pion <Sylvain dot Pion at sophia dot inria dot fr>
- Date: Mon, 24 Aug 1998 23:55:56 +0200
- Cc: Sylvain Pion <Sylvain dot Pion at sophia dot inria dot fr>
First, I'm not sure if it's a bug of me or egcs, because it shows up with
gcc-184.108.40.206 too, and I'm only a beginner with asm(). Here is with
I want to detect the MMX functionality, so I have the following code:
static inline void detect_mmx(void)
unsigned int cpuid, dummy;
asm const (
// "pushl %%ebx\n\t"
// "popl %%ebx"
: "=a" (dummy), "=d" (cpuid)
: "0" (1)
: "bx", "cx"
mmx_unit_present = ((cpuid & 0x800000) != 0); // segfault here.
This code produces a segfault a few instructions later, because it tries to
use the contents of %ebx, which has been set to 0 by CPUID.
As far as I understand, since "bx" is in the clobber list, gcc should take
care of this. It seems it's not the case when I compile with "-O2 -fpic".
Removing "-fpic", it works.
To make it work, I need to save %ebx on the stack, with the push/pop.
Please CC me, I'm not subscribed.