From e9f2eb5241d731aa0d3a21daccf62508b09c32c3 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 24 Sep 2004 00:25:32 +0000 Subject: [PATCH] Support compiling with -fPIC for people who somehow think this is a good idea. --- loader/preloader.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/loader/preloader.c b/loader/preloader.c index f71fbe95d4b..91ed99f6431 100644 --- a/loader/preloader.c +++ b/loader/preloader.c @@ -173,28 +173,32 @@ __ASM_GLOBAL_FUNC(_start, 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_read( int fd, void *buffer, size_t len ) 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 @@ static void *wld_mmap( void *start, size_t len, int prot, int flags, int fd, off 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); }