From: Julian Seward Date: Fri, 28 Apr 2006 21:01:33 +0000 (+0000) Subject: Fix completely bogus asm, which didn't work when compiled with gcc-4.1.0 X-Git-Tag: svn/VALGRIND_3_2_0~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed4db0bbc5e6379f6f2913bf364568f0bb00f63f;p=thirdparty%2Fvalgrind.git Fix completely bogus asm, which didn't work when compiled with gcc-4.1.0 since it trashed the regs that gcc assigned for %0 and %1 before reading them. local_sys_write_stderr() for the 3 other targets suffer from the same problem. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5865 --- diff --git a/coregrind/m_debuglog.c b/coregrind/m_debuglog.c index 39473c8c6e..36c26ba6cf 100644 --- a/coregrind/m_debuglog.c +++ b/coregrind/m_debuglog.c @@ -60,23 +60,28 @@ static UInt local_sys_write_stderr ( HChar* buf, Int n ) { - UInt __res; + Int block[2]; + block[0] = (Int)buf; + block[1] = n; __asm__ volatile ( - "pushl %%ebx\n" // ebx is callee-save - "movl $4, %%eax\n" /* %eax = __NR_write */ - "movl $1, %%ebx\n" /* %ebx = stderr */ - "movl %1, %%ecx\n" /* %ecx = buf */ - "movl %2, %%edx\n" /* %edx = n */ - "int $0x80\n" /* write(stderr, buf, n) */ - "movl %%eax, %0\n" /* __res = eax */ - "popl %%ebx\n" // restore ebx - : "=mr" (__res) - : "g" (buf), "g" (n) - : "eax", "edi", "ecx", "edx" + "pushl %%ebx\n" /* ebx is callee-save */ + "movl %0, %%ebx\n" /* ebx = &block */ + "pushl %%ebx\n" /* save &block */ + "movl 0(%%ebx), %%ecx\n" /* %ecx = buf */ + "movl 4(%%ebx), %%edx\n" /* %edx = n */ + "movl $4, %%eax\n" /* %eax = __NR_write */ + "movl $1, %%ebx\n" /* %ebx = stderr */ + "int $0x80\n" /* write(stderr, buf, n) */ + "popl %%ebx\n" /* reestablish &block */ + "movl %%eax, 0(%%ebx)\n" /* block[0] = result */ + "popl %%ebx\n" /* restore ebx */ + : /*wr*/ + : /*rd*/ "g" (block) + : /*trash*/ "eax", "edi", "ecx", "edx", "memory", "cc" ); - if (__res < 0) - __res = -1; - return __res; + if (block[0] < 0) + block[0] = -1; + return block[0]; } static UInt local_sys_getpid ( void )