From: Aggelos Economopoulos Date: Tue, 1 Dec 2009 12:46:09 +0000 (+0200) Subject: Unbreak ptrace on x86_64 X-Git-Tag: v2.7.1~371^2 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/95a5b34936ae88313dea47593a1e7033561ca997 Unbreak ptrace on x86_64 The asm code was calling __tls_get_addr in order to set errno to 0 before the system call and that was trashing registers holding the syscall arguments. Don't bother setting errno to 0 anymore (the in-tree users are careful to set that themselves when appropriate). While here, declare it properly as a weak symbol. At this point we could just drop the hand-written assembly. Proxies-to-x86_64-dfly: Antonio Huete Jimenez, Jan Lentfer Dragonfly-bug: http://bugs.dragonflybsd.org/issue1571 --- diff --git a/lib/libc/x86_64/sys/ptrace.S b/lib/libc/x86_64/sys/ptrace.S index 5246112594..4c92b35eb9 100644 --- a/lib/libc/x86_64/sys/ptrace.S +++ b/lib/libc/x86_64/sys/ptrace.S @@ -40,34 +40,20 @@ #include #include "SYS.h" -ENTRY(ptrace) -#ifdef PIC -# ifdef __thread - movq PIC_GOT(CNAME(errno)),%rax -# else - pushq %rdi - leaq errno@TLSGD(%rip),%rdi - call __tls_get_addr@PLT - popq %rdi -# endif -#else -# ifdef __thread - leaq CNAME(errno)(%rip),%rax -# else - movq errno@GOTTPOFF(%rip),%rax - addq %fs:0,%rax -# endif -#endif - movl $0,(%rax) - mov $SYS_ptrace,%eax + .weak _ptrace + .set _ptrace,__sys_ptrace + .weak ptrace + .set ptrace,__sys_ptrace +ENTRY(__sys_ptrace) + mov $SYS_ptrace,%rax KERNCALL - jb err - ret -err: + jb 1f + retq +1: #ifdef PIC movq PIC_GOT(HIDENAME(cerror)),%rdx jmp *%rdx #else jmp HIDENAME(cerror) #endif -END(ptrace) +END(__sys_ptrace)