Support compiling with -fPIC for people who somehow think this is a
good idea.
diff --git a/loader/preloader.c b/loader/preloader.c
index f71fbe9..91ed99f 100644
--- a/loader/preloader.c
+++ b/loader/preloader.c
@@ -173,28 +173,32 @@
static inline __attribute__((noreturn)) void wld_exit( int code )
{
for (;;) /* avoid warning */
- __asm__ __volatile__( "int $0x80" : : "a" (SYS_exit), "b" (code) );
+ __asm__ __volatile__( "pushl %%ebx; movl %1,%%ebx; int $0x80; popl %%ebx"
+ : : "a" (SYS_exit), "g" (code) );
}
static inline int wld_open( const char *name, int flags )
{
int ret;
- __asm__ __volatile__( "int $0x80" : "=a" (ret) : "0" (SYS_open), "b" (name), "c" (flags) );
+ __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"
+ : "=a" (ret) : "0" (SYS_open), "g" (name), "c" (flags) );
return SYSCALL_RET(ret);
}
static inline int wld_close( int fd )
{
int ret;
- __asm__ __volatile__( "int $0x80" : "=a" (ret) : "0" (SYS_close), "b" (fd) );
+ __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"
+ : "=a" (ret) : "0" (SYS_close), "g" (fd) );
return SYSCALL_RET(ret);
}
static inline ssize_t wld_read( int fd, void *buffer, size_t len )
{
int ret;
- __asm__ __volatile__( "int $0x80" : "=a" (ret)
- : "0" (SYS_read), "b" (fd), "c" (buffer), "d" (len)
+ __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"
+ : "=a" (ret)
+ : "0" (SYS_read), "g" (fd), "c" (buffer), "d" (len)
: "memory" );
return SYSCALL_RET(ret);
}
@@ -202,15 +206,16 @@
static inline ssize_t wld_write( int fd, const void *buffer, size_t len )
{
int ret;
- __asm__ __volatile__( "int $0x80" : "=a" (ret)
- : "0" (SYS_write), "b" (fd), "c" (buffer), "d" (len) );
+ __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"
+ : "=a" (ret) : "0" (SYS_write), "g" (fd), "c" (buffer), "d" (len) );
return SYSCALL_RET(ret);
}
static inline int wld_mprotect( const void *addr, size_t len, int prot )
{
int ret;
- __asm__ __volatile__( "int $0x80" : "=a" (ret) : "0" (SYS_mprotect), "b" (addr), "c" (len), "d" (prot) );
+ __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"
+ : "=a" (ret) : "0" (SYS_mprotect), "g" (addr), "c" (len), "d" (prot) );
return SYSCALL_RET(ret);
}
@@ -234,7 +239,8 @@
args.flags = flags;
args.fd = fd;
args.offset = offset;
- __asm__ __volatile__( "int $0x80" : "=a" (ret) : "0" (SYS_mmap), "b" (&args) : "memory" );
+ __asm__ __volatile__( "pushl %%ebx; movl %2,%%ebx; int $0x80; popl %%ebx"
+ : "=a" (ret) : "0" (SYS_mmap), "g" (&args) : "memory" );
return (void *)SYSCALL_RET(ret);
}