From: Tom Hughes Date: Wed, 27 Apr 2005 08:58:53 +0000 (+0000) Subject: Rework the inline assembly implementations of write and getpid for x86 to X-Git-Tag: svn/VALGRIND_3_0_0~744 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd35e4a4cb7a3290e032af410ba2f94bb36661e8;p=thirdparty%2Fvalgrind.git Rework the inline assembly implementations of write and getpid for x86 to work in PIE builds. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3574 --- diff --git a/coregrind/m_debuglog.c b/coregrind/m_debuglog.c index 9a81c56f67..9b79f3768e 100644 --- a/coregrind/m_debuglog.c +++ b/coregrind/m_debuglog.c @@ -62,12 +62,15 @@ static UInt local_sys_write_stderr ( HChar* buf, Int n ) { UInt __res; - __asm__ volatile ("int $0x80" - : "=a" (__res) - : "0" (4), /* __NR_write */ - "b" (2), /* stderr */ - "c" (buf), - "d" (n) ); + __asm__ volatile ( + "movl $4, %%eax\n" /* set %eax = __NR_write */ + "movl $2, %%ebx\n" /* set %ebx = stderr */ + "movl %1, %%ecx\n" /* set %ecx = buf */ + "movl %2, %%edx\n" /* set %ecx = n */ + "int $0x80\n" /* write(stderr, buf, n) */ + "movl %%eax, %0\n" /* set __res = eax */ + : "=mr" (__res) + : "g" (buf), "g" (n) ); if (__res < 0) __res = -1; return __res; @@ -76,9 +79,11 @@ static UInt local_sys_write_stderr ( HChar* buf, Int n ) static UInt local_sys_getpid ( void ) { UInt __res; - __asm__ volatile ("int $0x80" - : "=a" (__res) - : "0" (20) /* __NR_getpid */); + __asm__ volatile ( + "movl $20, %%eax\n" /* set %eax = __NR_getpid */ + "int $0x80\n" /* getpid() */ + "movl %%eax, %0\n" /* set __res = eax */ + : "=mr" (__res) ); return __res; }