[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#368039: linux-kernel-headers: can't use _syscallx (x>=2) with -fPIC on x86



Package: linux-kernel-headers
Version: 2.6.13+0rc3-2.1
Severity: normal

Hi,

When using _syscallx (with x>=2) in an x86 shared library, gcc complains
that it can't find a BREG register, for instance:

#include <sys/types.h>
#include <linux/unistd.h>

_syscall2(int, tkill, pid_t, tid, int, sig)

int main(void) { tkill(0,0); }

gcc -c test.c -o test.o -fPIC

test.c: In function 'tkill':
test.c:4: error: can't find a register in class 'BREG' while reloading 'asm'

This is because with -fPIC, gcc keeps the GOT address in %ebx, and
refuses it be clobbered. In latest kernel sources (2.6.17-rc1 for
instance), the problem got fixed by saving %ebx in the assembly string:

#define _syscall2(type,name,type1,arg1,type2,arg2) \
type name(type1 arg1,type2 arg2) \
{ \
long __res; \
__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
	: "=a" (__res) \
	: "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)) \
	: "memory"); \
__syscall_return(type,__res); \
}

Please either upgrade to more recent kernel headers, or at least
backport these #defines.

Thanks,
Samuel

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (900, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-rc1
Locale: LANG=fr_FR@euro, LC_CTYPE=fr_FR@euro (charmap=ISO-8859-15)

-- no debconf information

-- 
Samuel Thibault <samuel.thibault@ens-lyon.org>
<D> m'enfin, le 5 juillet, le mec vient visiter le labo...
* D a marque d'une croix rouge le 5 juillet sur son agenda
<y> niarc niarc niarc
<D> cet homme va souffrir
<B> c'est donc le 5 juillet qu'il meurt d'un accident de la route écrasé par un truck muni d'un pare buffle
 -+- #ens-mim - repaire de terroristes -+-



Reply to: