This is the mail archive of the gcc-help@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]
Other format: [Raw text]

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


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


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