Imported Upstream version 0.155
[platform/upstream/elfutils.git] / backends / x86_64_corenote.c
1 /* x86-64 specific core note handling.
2    Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
3    This file is part of elfutils.
4
5    This file is free software; you can redistribute it and/or modify
6    it under the terms of either
7
8      * the GNU Lesser General Public License as published by the Free
9        Software Foundation; either version 3 of the License, or (at
10        your option) any later version
11
12    or
13
14      * the GNU General Public License as published by the Free
15        Software Foundation; either version 2 of the License, or (at
16        your option) any later version
17
18    or both in parallel, as here.
19
20    elfutils is distributed in the hope that it will be useful, but
21    WITHOUT ANY WARRANTY; without even the implied warranty of
22    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23    General Public License for more details.
24
25    You should have received copies of the GNU General Public License and
26    the GNU Lesser General Public License along with this program.  If
27    not, see <http://www.gnu.org/licenses/>.  */
28
29 #ifdef HAVE_CONFIG_H
30 # include <config.h>
31 #endif
32
33 #include <elf.h>
34 #include <inttypes.h>
35 #include <stddef.h>
36 #include <stdio.h>
37 #include <sys/time.h>
38
39 #define BACKEND         x86_64_
40 #include "libebl_CPU.h"
41
42
43 static const Ebl_Register_Location prstatus_regs[] =
44   {
45 #define GR(at, n, dwreg)                                                \
46     { .offset = at * 8, .regno = dwreg, .count = n, .bits = 64 }
47 #define SR(at, n, dwreg)                                                \
48     { .offset = at * 8, .regno = dwreg, .count = n, .bits = 16, .pad = 6 }
49
50     GR (0, 1, 15),              /* %r15 */
51     GR (1, 1, 14),              /* %r14 */
52     GR (2, 1, 13),              /* %r13 */
53     GR (3, 1, 12),              /* %r12 */
54     GR (4, 1, 6),               /* %rbp */
55     GR (5, 1, 3),               /* %rbx */
56     GR (6, 1, 11),              /* %r11 */
57     GR (7, 1, 10),              /* %r10 */
58     GR (8, 1, 9),               /* %r9 */
59     GR (9, 1, 8),               /* %r8 */
60     GR (10,1, 0),               /* %rax */
61     GR (11,1, 2),               /* %rcx */
62     GR (12,1, 1),               /* %rdx */
63     GR (13,2, 4),               /* %rsi-%rdi */
64     /*  15,1,                       orig_rax */
65     GR (16,1, 16),              /* %rip */
66     SR (17,1, 51),              /* %cs */
67     GR (18,1, 49),              /* %rFLAGS */
68     GR (19,1, 7),               /* %rsp */
69     SR (20,1, 52),              /* %ss */
70     GR (21,2, 58),              /* %fs.base-%gs.base */
71     SR (23,1, 53),              /* %ds */
72     SR (24,1, 50),              /* %es */
73     SR (25,2, 54),              /* %fs-%gs */
74
75 #undef  GR
76 #undef  SR
77   };
78 #define PRSTATUS_REGS_SIZE      (27 * 8)
79
80 #define ULONG                   uint64_t
81 #define PID_T                   int32_t
82 #define UID_T                   uint32_t
83 #define GID_T                   uint32_t
84 #define ALIGN_ULONG             8
85 #define ALIGN_PID_T             4
86 #define ALIGN_UID_T             4
87 #define ALIGN_GID_T             4
88 #define TYPE_ULONG              ELF_T_XWORD
89 #define TYPE_PID_T              ELF_T_SWORD
90 #define TYPE_UID_T              ELF_T_SWORD
91 #define TYPE_GID_T              ELF_T_SWORD
92
93 #define PRSTATUS_REGSET_ITEMS                                                 \
94   {                                                                           \
95     .name = "orig_rax", .type = ELF_T_SXWORD, .format = 'd',                  \
96     .offset = offsetof (struct EBLHOOK(prstatus), pr_reg) + (8 * 15),         \
97     .group = "register"                                                       \
98   }
99
100 static const Ebl_Register_Location fpregset_regs[] =
101   {
102     { .offset = 0, .regno = 65, .count = 2, .bits = 16 }, /* fcw-fsw */
103     { .offset = 24, .regno = 64, .count = 1, .bits = 32 }, /* mxcsr */
104     { .offset = 32, .regno = 33, .count = 8, .bits = 80, .pad = 6 }, /* stN */
105     { .offset = 32 + 128, .regno = 17, .count = 16, .bits = 128 }, /* xmm */
106   };
107 #define FPREGSET_SIZE   512
108
109 #define EXTRA_NOTES     EXTRA_NOTES_IOPERM
110
111 #include "x86_corenote.c"
112 #include "linux-core-note.c"