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]

Re: -fPIC bug


> unless I'm on crack, this looks like a bug where
> the compiler allows a register to be clobbered without
> doing anything about it.
> 
> % cat foo.c
> int foo(){
>     asm("mov $0,%%ebx":::"%ebx");
>     return 0;
> }

You are using the constraint incorrectly; %ebx means something
different. One way to write what you want is

int foo(){
    int dummy;
    asm("mov $0,%%ebx":"=b"(dummy));
    return 0;
}

in which case you'll get

Invalid `asm' statement:
fixed or forbidden register 3 (bx) was spilled for class BREG.

IOW, with -fPIC, you must not use ebx (just in case you didn't know).

regards,
Martin


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