From: Julian Seward Date: Fri, 26 May 2006 11:31:15 +0000 (+0000) Subject: Replace the obviously-bogus piece of inline asm with a probably X-Git-Tag: svn/VALGRIND_3_2_0~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=163ce737c9644914229a44e557f074a4d4ff1624;p=thirdparty%2Fvalgrind.git Replace the obviously-bogus piece of inline asm with a probably equally bogus new version. In fact if I actually understood the magical "earlyclobber" (&) asm constraint this would probably be unnecessary, but I don't. Ah well. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5935 --- diff --git a/coregrind/m_debuglog.c b/coregrind/m_debuglog.c index 735d0f3465..5838911f6b 100644 --- a/coregrind/m_debuglog.c +++ b/coregrind/m_debuglog.c @@ -98,23 +98,33 @@ static UInt local_sys_getpid ( void ) } #elif defined(VGP_amd64_linux) - +__attribute__((noinline)) static UInt local_sys_write_stderr ( HChar* buf, Int n ) { - UInt __res; + Long block[2]; + block[0] = (Long)buf; + block[1] = n; __asm__ volatile ( - "movq $1, %%rax\n" /* set %rax = __NR_write */ - "movq $2, %%rdi\n" /* set %rdi = stderr */ - "movq %1, %%rsi\n" /* set %rsi = buf */ - "movl %2, %%edx\n" /* set %edx = n */ - "syscall\n" /* write(stderr, buf, n) */ - "movl %%eax, %0\n" /* set __res = %eax */ - : "=mr" (__res) - : "g" (buf), "g" (n) - : "rax", "rdi", "rsi", "rdx" ); - if (__res < 0) - __res = -1; - return __res; + "subq $256, %%rsp\n" /* don't trash the stack redzone */ + "pushq %%r15\n" /* r15 is callee-save */ + "movq %0, %%r15\n" /* r15 = &block */ + "pushq %%r15\n" /* save &block */ + "movq $1, %%rax\n" /* rax = __NR_write */ + "movq $2, %%rdi\n" /* rdi = stderr */ + "movq 0(%%r15), %%rsi\n" /* rsi = buf */ + "movq 8(%%r15), %%rdx\n" /* rdx = n */ + "syscall\n" /* write(stderr, buf, n) */ + "popq %%r15\n" /* reestablish &block */ + "movq %%rax, 0(%%r15)\n" /* block[0] = result */ + "popq %%r15\n" /* restore r15 */ + "addq $256, %%rsp\n" /* restore stack ptr */ + : /*wr*/ + : /*rd*/ "g" (block) + : /*trash*/ "rax", "rdi", "rsi", "rdx", "memory", "cc" + ); + if (block[0] < 0) + block[0] = -1; + return (UInt)block[0]; } static UInt local_sys_getpid ( void )