2005-05-06 03:15:23 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <signal.h>
|
2006-03-27 13:14:30 +04:00
|
|
|
#include <sys/poll.h>
|
2007-05-07 01:51:48 +04:00
|
|
|
#include <sys/mman.h>
|
2007-10-16 12:27:14 +04:00
|
|
|
#include <sys/user.h>
|
2005-05-06 03:15:23 +04:00
|
|
|
#define __FRAME_OFFSETS
|
2017-07-06 10:35:27 +03:00
|
|
|
#include <linux/ptrace.h>
|
2005-05-21 00:59:07 +04:00
|
|
|
#include <asm/types.h>
|
2005-05-06 03:15:23 +04:00
|
|
|
|
2011-12-06 04:08:49 +04:00
|
|
|
#ifdef __i386__
|
2016-01-29 02:11:24 +03:00
|
|
|
#define __SYSCALL_I386(nr, sym, qual) [nr] = 1,
|
2011-12-06 04:08:49 +04:00
|
|
|
static char syscalls[] = {
|
|
|
|
#include <asm/syscalls_32.h>
|
|
|
|
};
|
|
|
|
#else
|
2016-01-29 02:11:24 +03:00
|
|
|
#define __SYSCALL_64(nr, sym, qual) [nr] = 1,
|
2011-12-06 04:08:49 +04:00
|
|
|
static char syscalls[] = {
|
|
|
|
#include <asm/syscalls_64.h>
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2005-05-06 03:15:23 +04:00
|
|
|
#define DEFINE(sym, val) \
|
2011-08-18 23:03:19 +04:00
|
|
|
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
|
2005-05-06 03:15:23 +04:00
|
|
|
|
2005-09-29 01:27:23 +04:00
|
|
|
#define DEFINE_LONGS(sym, val) \
|
2011-08-18 23:03:19 +04:00
|
|
|
asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
|
2005-09-29 01:27:23 +04:00
|
|
|
|
2005-05-06 03:15:23 +04:00
|
|
|
void foo(void)
|
|
|
|
{
|
2011-08-18 23:03:19 +04:00
|
|
|
#ifdef __i386__
|
|
|
|
DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct));
|
|
|
|
DEFINE_LONGS(HOST_FPX_SIZE, sizeof(struct user_fpxregs_struct));
|
|
|
|
|
|
|
|
DEFINE(HOST_IP, EIP);
|
|
|
|
DEFINE(HOST_SP, UESP);
|
|
|
|
DEFINE(HOST_EFLAGS, EFL);
|
2011-08-18 23:10:09 +04:00
|
|
|
DEFINE(HOST_AX, EAX);
|
|
|
|
DEFINE(HOST_BX, EBX);
|
|
|
|
DEFINE(HOST_CX, ECX);
|
|
|
|
DEFINE(HOST_DX, EDX);
|
|
|
|
DEFINE(HOST_SI, ESI);
|
|
|
|
DEFINE(HOST_DI, EDI);
|
|
|
|
DEFINE(HOST_BP, EBP);
|
2011-08-18 23:03:19 +04:00
|
|
|
DEFINE(HOST_CS, CS);
|
|
|
|
DEFINE(HOST_SS, SS);
|
|
|
|
DEFINE(HOST_DS, DS);
|
|
|
|
DEFINE(HOST_FS, FS);
|
|
|
|
DEFINE(HOST_ES, ES);
|
|
|
|
DEFINE(HOST_GS, GS);
|
2011-08-18 23:12:19 +04:00
|
|
|
DEFINE(HOST_ORIG_AX, ORIG_EAX);
|
2011-08-18 23:03:19 +04:00
|
|
|
#else
|
2017-07-19 02:43:47 +03:00
|
|
|
#ifdef FP_XSTATE_MAGIC1
|
2016-03-19 19:58:40 +03:00
|
|
|
DEFINE(HOST_FP_SIZE, sizeof(struct _xstate) / sizeof(unsigned long));
|
2017-05-25 21:36:26 +03:00
|
|
|
#else
|
|
|
|
DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
|
|
|
|
#endif
|
2011-08-18 23:10:09 +04:00
|
|
|
DEFINE_LONGS(HOST_BX, RBX);
|
|
|
|
DEFINE_LONGS(HOST_CX, RCX);
|
|
|
|
DEFINE_LONGS(HOST_DI, RDI);
|
|
|
|
DEFINE_LONGS(HOST_SI, RSI);
|
|
|
|
DEFINE_LONGS(HOST_DX, RDX);
|
|
|
|
DEFINE_LONGS(HOST_BP, RBP);
|
|
|
|
DEFINE_LONGS(HOST_AX, RAX);
|
2005-09-29 01:27:23 +04:00
|
|
|
DEFINE_LONGS(HOST_R8, R8);
|
|
|
|
DEFINE_LONGS(HOST_R9, R9);
|
|
|
|
DEFINE_LONGS(HOST_R10, R10);
|
|
|
|
DEFINE_LONGS(HOST_R11, R11);
|
|
|
|
DEFINE_LONGS(HOST_R12, R12);
|
|
|
|
DEFINE_LONGS(HOST_R13, R13);
|
|
|
|
DEFINE_LONGS(HOST_R14, R14);
|
|
|
|
DEFINE_LONGS(HOST_R15, R15);
|
2011-08-18 23:12:19 +04:00
|
|
|
DEFINE_LONGS(HOST_ORIG_AX, ORIG_RAX);
|
2005-09-29 01:27:23 +04:00
|
|
|
DEFINE_LONGS(HOST_CS, CS);
|
|
|
|
DEFINE_LONGS(HOST_SS, SS);
|
|
|
|
DEFINE_LONGS(HOST_EFLAGS, EFLAGS);
|
2005-05-06 03:15:23 +04:00
|
|
|
#if 0
|
2005-09-29 01:27:23 +04:00
|
|
|
DEFINE_LONGS(HOST_FS, FS);
|
|
|
|
DEFINE_LONGS(HOST_GS, GS);
|
|
|
|
DEFINE_LONGS(HOST_DS, DS);
|
|
|
|
DEFINE_LONGS(HOST_ES, ES);
|
2005-05-06 03:15:23 +04:00
|
|
|
#endif
|
|
|
|
|
2005-09-29 01:27:23 +04:00
|
|
|
DEFINE_LONGS(HOST_IP, RIP);
|
|
|
|
DEFINE_LONGS(HOST_SP, RSP);
|
2011-08-18 23:03:19 +04:00
|
|
|
#endif
|
2006-03-27 13:14:30 +04:00
|
|
|
|
2011-08-18 23:03:19 +04:00
|
|
|
DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
|
2006-03-27 13:14:30 +04:00
|
|
|
DEFINE(UM_POLLIN, POLLIN);
|
|
|
|
DEFINE(UM_POLLPRI, POLLPRI);
|
|
|
|
DEFINE(UM_POLLOUT, POLLOUT);
|
2007-05-07 01:51:48 +04:00
|
|
|
|
|
|
|
DEFINE(UM_PROT_READ, PROT_READ);
|
|
|
|
DEFINE(UM_PROT_WRITE, PROT_WRITE);
|
|
|
|
DEFINE(UM_PROT_EXEC, PROT_EXEC);
|
2011-12-06 04:08:49 +04:00
|
|
|
|
|
|
|
DEFINE(__NR_syscall_max, sizeof(syscalls) - 1);
|
|
|
|
DEFINE(NR_syscalls, sizeof(syscalls));
|
2005-05-06 03:15:23 +04:00
|
|
|
}
|