ptrace.S revision 1.6
11.6Schristos/* $NetBSD: ptrace.S,v 1.6 2014/11/24 15:33:18 christos Exp $ */ 21.1Sfvdl 31.1Sfvdl/*- 41.1Sfvdl * Copyright (c) 1990 The Regents of the University of California. 51.1Sfvdl * All rights reserved. 61.1Sfvdl * 71.1Sfvdl * This code is derived from software contributed to Berkeley by 81.1Sfvdl * William Jolitz. 91.1Sfvdl * 101.1Sfvdl * Redistribution and use in source and binary forms, with or without 111.1Sfvdl * modification, are permitted provided that the following conditions 121.1Sfvdl * are met: 131.1Sfvdl * 1. Redistributions of source code must retain the above copyright 141.1Sfvdl * notice, this list of conditions and the following disclaimer. 151.1Sfvdl * 2. Redistributions in binary form must reproduce the above copyright 161.1Sfvdl * notice, this list of conditions and the following disclaimer in the 171.1Sfvdl * documentation and/or other materials provided with the distribution. 181.2Sagc * 3. Neither the name of the University nor the names of its contributors 191.1Sfvdl * may be used to endorse or promote products derived from this software 201.1Sfvdl * without specific prior written permission. 211.1Sfvdl * 221.1Sfvdl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 231.1Sfvdl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 241.1Sfvdl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 251.1Sfvdl * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 261.1Sfvdl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271.1Sfvdl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281.1Sfvdl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291.1Sfvdl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301.1Sfvdl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311.1Sfvdl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321.1Sfvdl * SUCH DAMAGE. 331.1Sfvdl * 341.1Sfvdl * from: @(#)ptrace.s 5.1 (Berkeley) 4/23/90 351.1Sfvdl */ 361.1Sfvdl 371.1Sfvdl#include <machine/asm.h> 381.1Sfvdl#if defined(SYSLIBC_SCCS) && !defined(lint) 391.6Schristos RCSID("$NetBSD: ptrace.S,v 1.6 2014/11/24 15:33:18 christos Exp $") 401.1Sfvdl#endif /* SYSLIBC_SCCS and not lint */ 411.1Sfvdl 421.1Sfvdl#include "SYS.h" 431.1Sfvdl 441.1Sfvdl .globl _C_LABEL(__errno) 451.1Sfvdl 461.1SfvdlENTRY(ptrace) 471.6Schristos /* 481.6Schristos * The following code calls __errno() to set it to 0 before 491.6Schristos * calling ptrace(2). The libc version of __errno() does not use 501.6Schristos * any registers, but the libpthread version clobbers %rcx 511.6Schristos * before we get a chance to store it in %r10. So we save it 521.6Schristos * in %r10 and restore it. 531.6Schristos */ 541.6Schristos movq %rcx, %r10 551.4Sjoerg#ifdef __PIC__ 561.1Sfvdl call PIC_PLT(_C_LABEL(__errno)) 571.1Sfvdl#else 581.1Sfvdl call _C_LABEL(__errno) 591.4Sjoerg#endif /* __PIC__ */ 601.1Sfvdl movl $0,(%rax) 611.6Schristos movq %r10, %rcx 621.1Sfvdl SYSTRAP(ptrace) 631.1Sfvdl jc err 641.1Sfvdl ret 651.1Sfvdlerr: 661.1Sfvdl jmp CERROR 671.5SuebayasiEND(ptrace) 68