xref: /openbsd/regress/sys/kern/noexec/testfly.S (revision a6fec130)
1/*	$OpenBSD: testfly.S,v 1.13 2024/03/26 19:12:34 miod Exp $	*/
2
3/*
4 * Copyright (c) 2002,2003 Michael Shalayeff
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 *    derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <machine/asm.h>
32
33#if !defined(_ASM_TYPE_FUNCTION)
34#define _ASM_TYPE_FUNCTION @function
35#endif
36
37	.space 16384
38
39#if defined(__aarch64__)
40	.section .rodata
41	.globl	testfly
42	.type	testfly,_ASM_TYPE_FUNCTION
43testfly:
44	bti c
45	ret
46END(testfly)
47#endif
48
49#if defined(__amd64__)
50	.section .rodata
51	.globl	testfly
52	.type	testfly,_ASM_TYPE_FUNCTION
53testfly:
54	endbr64
55	ret
56END(testfly)
57#endif
58
59#if defined(__i386__)
60ENTRY(testfly)
61	ret
62END(testfly)
63#endif
64
65#ifdef __alpha__
66LEAF(testfly, 0)
67	ret	zero,(ra),1
68	nop
69END(testfly)
70#endif
71
72#ifdef __hppa__
73LEAF_ENTRY(testfly)
74	bv	r0(rp)
75	nop
76EXIT(testfly)
77#endif
78
79#ifdef __arm__
80ENTRY(testfly)
81	mov	pc, lr
82END(testfly)
83#endif
84
85#ifdef __mips64__
86LEAF(testfly, 0)
87	jr	ra
88	nop
89END(testfly)
90#endif
91
92#ifdef __riscv
93ENTRY(testfly)
94	jr	ra
95END(testfly)
96#endif
97
98#ifdef __powerpc__
99ENTRY(testfly)
100	blr
101END(testfly)
102#endif
103
104#if defined(__sparc64__)
105ENTRY(testfly)
106	retl
107	nop
108END(testfly)
109#endif
110
111	.space 16384
112