1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/* $OpenBSD: DEFS.h,v 1.2 2023/12/10 16:45:50 deraadt Exp $ */
/*
* Copyright (c) 2015,2018,2021 Philip Guenther <guenther@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <machine/asm.h>
/* ARM just had to be different... */
#ifndef __arm__
# define _FUNC_TYPE @function
#else
# define _FUNC_TYPE #function
#endif
/*
* We define a hidden alias with the prefix "_libc_" for each global symbol
* that may be used internally. By referencing _libc_x instead of x, other
* parts of libc prevent overriding by the application and avoid unnecessary
* relocations.
*/
#define _HIDDEN(x) _libc_##x
#define _HIDDEN_ALIAS(x,y) \
STRONG_ALIAS(_HIDDEN(x),y); \
.hidden _HIDDEN(x)
#define _HIDDEN_FALIAS(x,y) \
_HIDDEN_ALIAS(x,y); \
.type _HIDDEN(x),_FUNC_TYPE
/*
* For functions implemented in ASM that aren't syscalls.
* END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names
* END_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names
* END_BUILTIN(x) If compiling with clang, then just END() and
* mark it .protected, else be like END_STRONG();
* for clang builtins like memcpy
*
* If a 'BUILTIN' function needs be referenced by other ASM code, then use
* _BUILTIN(x) If compiled with clang, then just x, otherwise
* _HIDDEN(x)
*
* _END(x) Set a size on a symbol, like END(), but even for
* symbols with no matching ENTRY(). (On alpha and
* mips64, END() generates .end which requires a
* matching .ent from ENTRY())
*/
#define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); _END(_HIDDEN(x))
#define END_WEAK(x) END_STRONG(x); .weak x
#ifdef __clang__
#define END_BUILTIN(x) END(x); .protected x
#define _BUILTIN(x) x
#else
#define END_BUILTIN(x) END_STRONG(x)
#define _BUILTIN(x) _HIDDEN(x)
#endif
#define _END(x) .size x, . - x
#define PINSYSCALL(sysno, label) \
.pushsection .openbsd.syscalls,"",@progbits; \
.long label; \
.long sysno; \
.popsection;
|