Re: syscall defines deficiency or gcc bug?

From: Brian Gerst (
Date: Wed Aug 02 2000 - 17:12:51 EST

Linda Walsh wrote:
> I have some code that includes asm-i386/unistd.h and has defines for
> the functions I want to call (audit related)
> Thing is, that I want to also be able to call those functions in
> a shared library compiled with -fpic (or -fPIC). When I use the
> fpic option to gcc, I get:
> asm-audit.h: In function `aud_setluid':
> asm-audit.h:17: Invalid `asm' statement:
> asm-audit.h:17: fixed or forbidden register 3 (bx) was spilled for class BREG.
> That line contains:
> _syscall1(int, aud_setluid, uid_t, luid)
> Basically and syscall definition I use that has input arguments gets
> the above error message. Functions with no arguments generate no
> error.
> The problem appears to lie in gcc's global register allocator. 'greg'.
> So what I'm wondering is "does this point to a bug in gcc"? or is there
> some different way the syscalls could be defined to make them portable
> between both cases?

PIC code on the x86 reserves the %ebx register for an offset pointer,
but the syscall interface defines %ebx as the first argument of a
syscall. Glibc works around this by pushing and popping %ebx around the
syscall. You would need something like this:

#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{ \
long __res; \
__asm__ volatile ("pushl %%ebx; movl %2, %%ebx; int $0x80; popl %%ebx" \
        : "=a" (__res) \
        : "0" (__NR_##name),"g" ((long)(arg1))); \
__syscall_return(type,__res); \


Brian Gerst

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Aug 07 2000 - 21:00:09 EST