PROBLEM: using _syscall4 to call sys_futex with -fPIC won't compile

From: Benjamin Collar
Date: Mon Jul 05 2004 - 05:41:58 EST


Greetings

[1.]
If I use _syscall4 in order to call sys_futex and compile with -fPIC, I
receive this compiler error:
"can't find a register in class `BREG' while reloading `asm'"

[2.]
I'm using futexes in a project and I have to build a shared library;
thus I need to use -fPIC when compiling. When doing so, I get the error
mentioned in [1.]. A colleague and I figured out that the problem lies
in the intermediate code generated:

int sys_futex(int *futex, int op, int val, struct timespec *rel) {
register long __res;
__asm__ volatile (
"int $0x80"
: "=a" (__res)
: "0" (240),
"b" ((long)(futex)),
"c" ((long)(op)),
"d" ((long)(val)),
"S" ((long)(rel)));

The "b" ((long)(futex)), causes the error.

[3.] syscall
[4.] Linux version 2.6.7 (gcc version 3.3.3 20040412 (Gentoo Linux
3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)) #2 SMP Thu Jun 17 10:38:06 CEST 2004
(I tested on a Debian based machine as well with the same result).
[5.] n/a
[6.] For example, see the futex-2.2.tar.bz2; change the Makefile to use
-fPIC
[7.]
[7.1]
Linux mhpajh5c 2.6.7 #2 SMP Thu Jun 17 10:38:06 CEST 2004 i686 Intel(R)
Pentium(R) 4 CPU 3.20GHz GenuineIntel GNU/Linux

Gnu C 3.3.3
Gnu make 3.80
binutils 2.14.90.0.8
util-linux 2.12
mount 2.12
module-init-tools 3.0
e2fsprogs 1.35
Linux C Library 2.3.3
Dynamic linker (ldd) 2.3.3
Procps 3.1.15
Net-tools 1.60
Kbd 1.12
Sh-utils 5.2.1
Modules Loaded i830 ohci_hcd 3c59x ata_piix libata uhci_hcd
intel_agp agpgart snd_pcm_oss snd_mixer_oss snd_intel8x0 snd_ac97_codec
snd_pcm snd_page_alloc gameport snd_mpu401_uart snd_rawmidi snd_seq_oss
snd_seq_midi_event snd_seq snd_timer snd_seq_device snd e1000 sbp2
ohci1394 ieee1394 usb_storage ehci_hcd usbcore
[7.2]
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Pentium(R) 4 CPU 3.20GHz
stepping : 9
cpu MHz : 3192.159
cache size : 512 KB
physical id : 0
siblings : 2
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid
bogomips : 6307.84
[7.3,4,5,6,7] n/a
[X.] This hand-written assembly works for the moment:
int sys_futex(int *futex, int op, int val, struct timespec *rel) {
register long __res;
__asm__ volatile (
"pushl %%ebx\n\
movl 8(%%ebp), %%ebx\n\
int $0x80\n\
popl %%ebx"
: "=a" (__res)
: "0" (240)/*,
"b" ((long)(futex))*/,
"c" ((long)(op)),
"d" ((long)(val)),
"S" ((long)(rel)));

do {
if ((unsigned long)(__res) >= (unsigned long)(-125)) {
(*__errno_location ()) = -(__res);
__res = -1;
}
return (int) (__res);
} while (0);
}

Thanks for any help in figuring out what's wrong.

Sincerely
Ben



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/