ptrace.S revision 1.5
11.5Sthorpej/*	$NetBSD: ptrace.S,v 1.5 2002/08/17 19:54:32 thorpej Exp $ */
21.1Sbjh21
31.1Sbjh21/*-
41.1Sbjh21 * Copyright (c) 1990 The Regents of the University of California.
51.1Sbjh21 * All rights reserved.
61.1Sbjh21 *
71.1Sbjh21 * Redistribution and use in source and binary forms, with or without
81.1Sbjh21 * modification, are permitted provided that the following conditions
91.1Sbjh21 * are met:
101.1Sbjh21 * 1. Redistributions of source code must retain the above copyright
111.1Sbjh21 *    notice, this list of conditions and the following disclaimer.
121.1Sbjh21 * 2. Redistributions in binary form must reproduce the above copyright
131.1Sbjh21 *    notice, this list of conditions and the following disclaimer in the
141.1Sbjh21 *    documentation and/or other materials provided with the distribution.
151.1Sbjh21 * 3. All advertising materials mentioning features or use of this software
161.1Sbjh21 *    must display the following acknowledgement:
171.1Sbjh21 *	This product includes software developed by the University of
181.1Sbjh21 *	California, Berkeley and its contributors.
191.1Sbjh21 * 4. Neither the name of the University nor the names of its contributors
201.1Sbjh21 *    may be used to endorse or promote products derived from this software
211.1Sbjh21 *    without specific prior written permission.
221.1Sbjh21 *
231.1Sbjh21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241.1Sbjh21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251.1Sbjh21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261.1Sbjh21 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
271.1Sbjh21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281.1Sbjh21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291.1Sbjh21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301.1Sbjh21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311.1Sbjh21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321.1Sbjh21 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331.1Sbjh21 * SUCH DAMAGE.
341.1Sbjh21 *
351.1Sbjh21 *	from: @(#)ptrace.s	5.1 (Berkeley) 4/23/90
361.1Sbjh21 */
371.1Sbjh21
381.1Sbjh21#include "SYS.h"
391.1Sbjh21
401.1Sbjh21ENTRY(ptrace)
411.1Sbjh21#ifdef _REENTRANT
421.1Sbjh21	stmfd	sp!, {r0-r3, lr}
431.4Schris	sub	sp, sp, #4	/* align stack */
441.3Smatt	bl	PIC_SYM(_C_LABEL(__errno), PLT)
451.4Schris	add	sp, sp, #4	/* unalign stack */
461.1Sbjh21	mov	r1, #0x00000000
471.1Sbjh21	str	r1, [r0]
481.1Sbjh21	ldmfd	sp!, {r0-r3, lr}
491.1Sbjh21#else
501.1Sbjh21	stmfd	sp!, {r0, r1}
511.1Sbjh21#ifdef PIC
521.1Sbjh21	/* Setup the GOT */
531.5Sthorpej	ldr	r0, .Lgot
541.1Sbjh21	add	r0, pc, r0
551.3Smatt.L1:
561.5Sthorpej	ldr	r1, .Lerrno
571.1Sbjh21	ldr	r1, [r0, r1]
581.1Sbjh21#else
591.5Sthorpej	ldr	r1, .Lerrno
601.1Sbjh21#endif /* PIC */
611.1Sbjh21	mov	r0, #0x00000000
621.1Sbjh21	str	r0, [r1]
631.1Sbjh21	ldmfd	sp!, {r0, r1}
641.1Sbjh21#endif /* _REENTRANT */
651.1Sbjh21
661.2Sbjh21	SYSTRAP(ptrace)
671.3Smatt	bcs	PIC_SYM(CERROR, PLT)
681.1Sbjh21#ifdef __APCS_26__
691.1Sbjh21	movs	pc, lr
701.1Sbjh21#else
711.1Sbjh21	mov	pc, lr
721.1Sbjh21#endif
731.1Sbjh21
741.1Sbjh21#ifndef _REENTRANT
751.1Sbjh21#ifdef PIC
761.1Sbjh21	.align	0
771.5Sthorpej.Lgot:
781.3Smatt	.word	_C_LABEL(_GLOBAL_OFFSET_TABLE_) + (. - (.L1+4))
791.1Sbjh21#endif /* PIC */
801.1Sbjh21
811.5Sthorpej.Lerrno:
821.3Smatt	.word	PIC_SYM(_C_LABEL(errno), GOT)
831.1Sbjh21#endif /* !_REENTRANT */
84