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
#include <machine/asm.h>
#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)