Re: _syscall2 in PIC code on ix86

From: Alan Modra (alan@SPRI.Levels.UniSA.Edu.Au)
Date: Sat Jan 15 2000 - 22:47:58 EST


On Sat, 15 Jan 2000, Chris Noe wrote:

> On 14 Jan 2000, H. Peter Anvin wrote:
>
> > We probably should add a set of macros that include PIC support
> > (_syscallX_pic)... it seems to me the obvious way to deal with this
> > seems to push/pop %ebx around the syscall.
> >
> > -hpa
>
> That sounded easy enough to accomplish that I went ahead and did it;
> however, even after digging through the inline-asm info pages and such I
> still can't discover what the "last step" to fix it is. I still get
> compiler errors using the syscallX_pic versions.
>[snip]
>
> btw, does it matter that I've split the "pushl %ebx / int 0x80" over two
> separate asm lines? I wouldn't think so because of the volatile, but I'm
>[snip]

Yes it does matter. The whole point is that you can't use a "b"
constraint and try to make the compiler put anything into ebx.

Something like the following (untested!) is required

#define _syscall1_pic(type,name,type1,arg1) \
type name(type1 arg1) \
{ \
long __res; \
__asm__ volatile ("push %%ebx\n\t" \
        "mov %%eax,%%ebx\n\t" \
        "mov %1,%%eax"\n\t \
        "int $0x80\n\t" \
        "pop %%ebx" \
        : "=a" (__res) \
        : "i" (__NR_##name),"a" ((long)(arg1))); \
__syscall_return(type,__res); \
}

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



This archive was generated by hypermail 2b29 : Sun Jan 23 2000 - 21:00:13 EST