This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: inline asm clobber bug with -fpic
- To: egcs-bugs at cygnus dot com
- Subject: Re: inline asm clobber bug with -fpic
- From: Ulrich Drepper <drepper at cygnus dot com>
- Date: 27 Aug 1998 16:44:44 -0700
- Newsgroups: cygnus.egcs.bugs
- Organization: Cygnus Solutions
- References: <19980824235556.A25152.cygnus.egcs.bugs@rigel.inria.fr>
- Reply-To: drepper at cygnus dot com (Ulrich Drepper)
Sylvain.Pion@sophia.inria.fr (Sylvain Pion) writes:
> asm const (
> // "pushl %%ebx\n\t"
> "cpuid\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.
No. If the %ebx register is used in PIC you cannot rely on gcc doing
anything to restore the value. Gcc has not enough knowledge about the
special value in %ebx. This will hopefully change some day but
currently it is not and you indeed have to save and restore %ebx.
--
---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com `------------------------