Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
arch_x86_64.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 The University of Utah
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #include "config.h"
20 #include "string.h"
21 #include "common.h"
22 #include "arch.h"
23 #include "arch_x86_64.h"
24 
25 static char *x86_64_reg_names[ARCH_X86_64_REG_COUNT] = {
26  "rax","rdx","rcx","rbx","rsi","rdi","rbp","rsp",
27  "r8","r9","r10","r11","r12","r13","r14","r15",
28  "rip",
29  "xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7",
30  "xmm8","xmm9","xmm10","xmm11","xmm12","xmm13","xmm14","xmm15",
31  "st0","st1","st2","st3","st4","st5","st6","st7",
32  "mm0","mm1","mm2","mm3","mm4","mm5","mm6","mm7",
33  "rflags","es","cs","ss","ds","fs","gs",
34  NULL,NULL,
35  "fs_base","gs_base","gs_base_kernel","gs_base_user",
36  "tr","ldt","mxcsr","x87cw","x87sw","gdt",
37  NULL,NULL,
38  "cr0","cr1","cr2","cr3","cr4",NULL,NULL,NULL,"cr8",
39  NULL,
40  "dr0","dr1","dr2","dr3",NULL,NULL,"dr6","dr7",
41  "efer",
42 };
43 
44 static REG x86_64_common_to_arch[COMMON_REG_COUNT] = {
50 };
51 
52 static uint8_t x86_64_reg_sizes[ARCH_X86_64_REG_COUNT] = {
53  8,8,8,8,8,8,8,8,
54  8,8,8,8,8,8,8,8,
55  8,
56  64,64,64,64,64,64,64,64,
57  64,64,64,64,64,64,64,64,
58  10,10,10,10,10,10,10,10,
59  16,16,16,16,16,16,16,16,
60  8,8,8,8,8,8,8,
61  0,0,
62  8,8,8,8,
63  8,8,8,8,8,8,
64  0,0,
65  8,8,8,8,8,0,0,0,8,
66  0,
67  8,8,8,8,0,0,8,8,
68  8,
69 };
70 
71 static int x86_64_so_d0[] = { -1, };
72 static int x86_64_so_d1[] = {
82 };
83 static int x86_64_so_d2[] = {
87 };
88 static uint8_t x86_64_bpi[] = { 0xcc, };
89 static uint8_t x86_64_ri[] = { 0xc3, };
90 static uint8_t x86_64_fri[] = { 0xc9,0xc3, };
91 
92 struct arch arch_x86_64 = {
93  .type = ARCH_X86_64,
94 
95  .endian = ENDIAN_LITTLE,
96  .wordsize = 8,
97  .ptrsize = 8,
98 
99  .regcount = ARCH_X86_64_REG_COUNT,
100 
101  .reg_sizes = x86_64_reg_sizes,
102  .common_to_arch = x86_64_common_to_arch,
103  .reg_names = x86_64_reg_names,
104 
105  .snprintf_ordering = { x86_64_so_d0,x86_64_so_d1,x86_64_so_d2, }, //x86_64_snprintf_ordering,
106  .max_snprintf_ordering = 2,
107 
108  .breakpoint_instrs = x86_64_bpi,
109  .breakpoint_instrs_len = 1,
110  .breakpoint_instr_count = 1,
111 
112  .ret_instrs = x86_64_ri,
113  .ret_instrs_len = 1,
114  .ret_instr_count = 1,
115 
116  /* LEAVE, RET */
117  .full_ret_instrs = x86_64_fri,
118  .full_ret_instrs_len = 2,
119  .full_ret_instr_count = 2,
120 };
arch_type_t type
Definition: arch.h:117
#define REG_X86_64_DS
Definition: arch_x86_64.h:105
#define REG_X86_64_RSP
Definition: arch_x86_64.h:43
#define REG_X86_64_RDI
Definition: arch_x86_64.h:41
#define REG_X86_64_RIP
Definition: arch_x86_64.h:54
#define REG_X86_64_SS
Definition: arch_x86_64.h:104
#define REG_X86_64_R9
Definition: arch_x86_64.h:45
Definition: arch.h:74
#define REG_X86_64_RAX
Definition: arch_x86_64.h:36
#define REG_X86_64_DR3
Definition: arch_x86_64.h:149
#define REG_X86_64_RDX
Definition: arch_x86_64.h:37
#define REG_X86_64_R8
Definition: arch_x86_64.h:44
#define REG_X86_64_GS
Definition: arch_x86_64.h:107
#define REG_X86_64_R12
Definition: arch_x86_64.h:48
#define REG_X86_64_CR2
Definition: arch_x86_64.h:138
#define REG_X86_64_DR7
Definition: arch_x86_64.h:152
#define REG_X86_64_R13
Definition: arch_x86_64.h:49
#define REG_X86_64_R15
Definition: arch_x86_64.h:51
#define REG_X86_64_DR2
Definition: arch_x86_64.h:148
#define REG_X86_64_DR6
Definition: arch_x86_64.h:151
#define REG_X86_64_DR0
Definition: arch_x86_64.h:146
#define REG_X86_64_CR1
Definition: arch_x86_64.h:137
#define REG_X86_64_CS
Definition: arch_x86_64.h:103
#define REG_X86_64_MSR_EFER
Definition: arch_x86_64.h:154
#define REG_X86_64_RCX
Definition: arch_x86_64.h:38
#define REG_X86_64_R14
Definition: arch_x86_64.h:50
#define REG_X86_64_ES
Definition: arch_x86_64.h:102
#define REG_X86_64_RFLAGS
Definition: arch_x86_64.h:101
#define ARCH_X86_64_REG_COUNT
Definition: arch_x86_64.h:33
#define REG_X86_64_RBX
Definition: arch_x86_64.h:39
struct arch arch_x86_64
Definition: arch_x86_64.c:92
int8_t REG
Definition: common.h:93
#define REG_X86_64_RSI
Definition: arch_x86_64.h:40
#define COMMON_REG_COUNT
Definition: arch.h:80
#define REG_X86_64_R11
Definition: arch_x86_64.h:47
#define REG_X86_64_GS_BASE
Definition: arch_x86_64.h:110
#define REG_X86_64_DR1
Definition: arch_x86_64.h:147
Definition: arch.h:116
#define REG_X86_64_R10
Definition: arch_x86_64.h:46
#define REG_X86_64_CR0
Definition: arch_x86_64.h:136
#define REG_X86_64_CR3
Definition: arch_x86_64.h:139
#define REG_X86_64_RBP
Definition: arch_x86_64.h:42
Definition: arch.h:78
#define REG_X86_64_GS_BASE_USER
Definition: arch_x86_64.h:116
#define REG_X86_64_FS_BASE
Definition: arch_x86_64.h:109
Definition: arch.h:75
Definition: arch.h:76
#define REG_X86_64_FS
Definition: arch_x86_64.h:106
#define REG_X86_64_GS_BASE_KERNEL
Definition: arch_x86_64.h:115