can't find a register in class 'GENERAL_REGS' while reloading 'asm'

Ian Lance Taylor iant@google.com
Fri Apr 20 14:12:00 GMT 2007


Michael Haubenwallner <michael.haubenwallner@salomon.at> writes:

> in openssl-0.9.8e there is some inlined assembler code, which does not
> compile with -fpic (or -fPIC) and -O0 on x86-linux-gnu.

> openssl-error.c:28: error: can't find a register in class 'GENERAL_REGS' while reloading 'asm'

>        asm volatile (
>                "pushl	%%ebx\n"
>                "	leal	16(%0),%%edx\n"
>                "	leal	32(%0),%%ebx\n"
>                ".byte 0xf3,0x0f,0xa7,0xc8" "\n"
>                "	popl	%%ebx"
>                : "=a"(iv), "=c"(cnt), "=D"(out), "=S"(inp)
>                : "0"(cdata), "1"(cnt), "2"(out), "3"(inp), "m"(*cdata)
>                : "edx", "cc", "memory"
>        );

This puts iv in %eax, cnt in %ecx, out in %edi, inp in %esi, and it
lists *cdata as an explicit input.  You are using -fpic so %ebx is
used as a PIC register.  %ebp is the frame pointer.  %edx is in the
list of clobbered registers.  You are left with no registers to hold
*cdata.

I think I would write this more like
    xchg  %ebx, %2
    .byte 0xf3, 0x0f, 0xa7, 0xc8
    xchg %ebx, %2
: "+c" (cnt), "+d" (cdata->len), "+r" (cdata->addr), "+D" (out), "+S" (inp)
: "cc", "memory"

Ian



More information about the Gcc-help mailing list