diff options
Diffstat (limited to 'arch/x86/um/user-offsets.c')
-rw-r--r-- | arch/x86/um/user-offsets.c | 79 |
1 files changed, 79 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..3c19c48a1d48 --- /dev/null +++ b/arch/x86/um/user-offsets.c | |||
@@ -0,0 +1,79 @@ | |||
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 | |||
17 | void 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_EAX, EAX); | ||
27 | DEFINE(HOST_EBX, EBX); | ||
28 | DEFINE(HOST_ECX, ECX); | ||
29 | DEFINE(HOST_EDX, EDX); | ||
30 | DEFINE(HOST_ESI, ESI); | ||
31 | DEFINE(HOST_EDI, EDI); | ||
32 | DEFINE(HOST_EBP, 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 | #else | ||
40 | DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long)); | ||
41 | DEFINE_LONGS(HOST_RBX, RBX); | ||
42 | DEFINE_LONGS(HOST_RCX, RCX); | ||
43 | DEFINE_LONGS(HOST_RDI, RDI); | ||
44 | DEFINE_LONGS(HOST_RSI, RSI); | ||
45 | DEFINE_LONGS(HOST_RDX, RDX); | ||
46 | DEFINE_LONGS(HOST_RBP, RBP); | ||
47 | DEFINE_LONGS(HOST_RAX, 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_RAX, 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 | } | ||