aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/um/user-offsets.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/um/user-offsets.c')
-rw-r--r--arch/x86/um/user-offsets.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/arch/x86/um/user-offsets.c b/arch/x86/um/user-offsets.c
new file mode 100644
index 000000000000..ca49be8ddd0c
--- /dev/null
+++ b/arch/x86/um/user-offsets.c
@@ -0,0 +1,80 @@
1#include <stdio.h>
2#include <stddef.h>
3#include <signal.h>
4#include <sys/poll.h>
5#include <sys/mman.h>
6#include <sys/user.h>
7#define __FRAME_OFFSETS
8#include <asm/ptrace.h>
9#include <asm/types.h>
10
11#define DEFINE(sym, val) \
12 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
13
14#define DEFINE_LONGS(sym, val) \
15 asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
16
17void foo(void)
18{
19#ifdef __i386__
20 DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct));
21 DEFINE_LONGS(HOST_FPX_SIZE, sizeof(struct user_fpxregs_struct));
22
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(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
42 DEFINE_LONGS(HOST_BX, RBX);
43 DEFINE_LONGS(HOST_CX, RCX);
44 DEFINE_LONGS(HOST_DI, RDI);
45 DEFINE_LONGS(HOST_SI, RSI);
46 DEFINE_LONGS(HOST_DX, RDX);
47 DEFINE_LONGS(HOST_BP, RBP);
48 DEFINE_LONGS(HOST_AX, RAX);
49 DEFINE_LONGS(HOST_R8, R8);
50 DEFINE_LONGS(HOST_R9, R9);
51 DEFINE_LONGS(HOST_R10, R10);
52 DEFINE_LONGS(HOST_R11, R11);
53 DEFINE_LONGS(HOST_R12, R12);
54 DEFINE_LONGS(HOST_R13, R13);
55 DEFINE_LONGS(HOST_R14, R14);
56 DEFINE_LONGS(HOST_R15, R15);
57 DEFINE_LONGS(HOST_ORIG_AX, ORIG_RAX);
58 DEFINE_LONGS(HOST_CS, CS);
59 DEFINE_LONGS(HOST_SS, SS);
60 DEFINE_LONGS(HOST_EFLAGS, EFLAGS);
61#if 0
62 DEFINE_LONGS(HOST_FS, FS);
63 DEFINE_LONGS(HOST_GS, GS);
64 DEFINE_LONGS(HOST_DS, DS);
65 DEFINE_LONGS(HOST_ES, ES);
66#endif
67
68 DEFINE_LONGS(HOST_IP, RIP);
69 DEFINE_LONGS(HOST_SP, RSP);
70#endif
71
72 DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
73 DEFINE(UM_POLLIN, POLLIN);
74 DEFINE(UM_POLLPRI, POLLPRI);
75 DEFINE(UM_POLLOUT, POLLOUT);
76
77 DEFINE(UM_PROT_READ, PROT_READ);
78 DEFINE(UM_PROT_WRITE, PROT_WRITE);
79 DEFINE(UM_PROT_EXEC, PROT_EXEC);
80}