xref: /linux/arch/x86/um/user-offsets.c (revision 6a34dfa15d6edf7e78b8118d862d2db0889cf669)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <stdio.h>
3 #include <stddef.h>
4 #include <signal.h>
5 #include <poll.h>
6 #include <sys/mman.h>
7 #include <sys/user.h>
8 #define __FRAME_OFFSETS
9 #include <linux/ptrace.h>
10 #include <asm/types.h>
11 #include <linux/kbuild.h>
12 
13 #define DEFINE_LONGS(sym, val)	\
14 	COMMENT(#val " / sizeof(unsigned long)");	\
15 	DEFINE(sym, val / sizeof(unsigned long))
16 
17 /* workaround for a warning with -Wmissing-prototypes */
18 void foo(void);
19 
20 void foo(void)
21 {
22 #ifdef __i386__
23 	DEFINE(HOST_IP, EIP);
24 	DEFINE(HOST_SP, UESP);
25 	DEFINE(HOST_EFLAGS, EFL);
26 	DEFINE(HOST_AX, EAX);
27 	DEFINE(HOST_BX, EBX);
28 	DEFINE(HOST_CX, ECX);
29 	DEFINE(HOST_DX, EDX);
30 	DEFINE(HOST_SI, ESI);
31 	DEFINE(HOST_DI, EDI);
32 	DEFINE(HOST_BP, EBP);
33 	DEFINE(HOST_CS, CS);
34 	DEFINE(HOST_SS, SS);
35 	DEFINE(HOST_DS, DS);
36 	DEFINE(HOST_FS, FS);
37 	DEFINE(HOST_ES, ES);
38 	DEFINE(HOST_GS, GS);
39 	DEFINE(HOST_ORIG_AX, ORIG_EAX);
40 #else
41 	DEFINE_LONGS(HOST_BX, RBX);
42 	DEFINE_LONGS(HOST_CX, RCX);
43 	DEFINE_LONGS(HOST_DI, RDI);
44 	DEFINE_LONGS(HOST_SI, RSI);
45 	DEFINE_LONGS(HOST_DX, RDX);
46 	DEFINE_LONGS(HOST_BP, RBP);
47 	DEFINE_LONGS(HOST_AX, RAX);
48 	DEFINE_LONGS(HOST_R8, R8);
49 	DEFINE_LONGS(HOST_R9, R9);
50 	DEFINE_LONGS(HOST_R10, R10);
51 	DEFINE_LONGS(HOST_R11, R11);
52 	DEFINE_LONGS(HOST_R12, R12);
53 	DEFINE_LONGS(HOST_R13, R13);
54 	DEFINE_LONGS(HOST_R14, R14);
55 	DEFINE_LONGS(HOST_R15, R15);
56 	DEFINE_LONGS(HOST_ORIG_AX, ORIG_RAX);
57 	DEFINE_LONGS(HOST_CS, CS);
58 	DEFINE_LONGS(HOST_SS, SS);
59 	DEFINE_LONGS(HOST_EFLAGS, EFLAGS);
60 #if 0
61 	DEFINE_LONGS(HOST_FS, FS);
62 	DEFINE_LONGS(HOST_GS, GS);
63 	DEFINE_LONGS(HOST_DS, DS);
64 	DEFINE_LONGS(HOST_ES, ES);
65 #endif
66 
67 	DEFINE_LONGS(HOST_IP, RIP);
68 	DEFINE_LONGS(HOST_SP, RSP);
69 #endif
70 
71 	DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
72 	DEFINE(UM_POLLIN, POLLIN);
73 	DEFINE(UM_POLLPRI, POLLPRI);
74 	DEFINE(UM_POLLOUT, POLLOUT);
75 
76 	DEFINE(UM_PROT_READ, PROT_READ);
77 	DEFINE(UM_PROT_WRITE, PROT_WRITE);
78 	DEFINE(UM_PROT_EXEC, PROT_EXEC);
79 }
80