This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: can't find a register in class 'GENERAL_REGS' while reloading 'asm'
- From: Ian Lance Taylor <iant at google dot com>
- To: Michael Haubenwallner <michael dot haubenwallner at salomon dot at>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 19 Apr 2007 22:43:23 -0700
- Subject: Re: can't find a register in class 'GENERAL_REGS' while reloading 'asm'
- References: <1176997751.7328.88.camel@localhost>
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