1 /* i386 specific core note handling.
2 Copyright (C) 2007-2010 Red Hat, Inc.
3 This file is part of elfutils.
5 This file is free software; you can redistribute it and/or modify
6 it under the terms of either
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
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
18 or both in parallel, as here.
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.
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/>. */
40 #include "libebl_CPU.h"
43 static const Ebl_Register_Location prstatus_regs[] =
45 #define GR(at, n, dwreg) \
46 { .offset = at * 4, .regno = dwreg, .count = n, .bits = 32 }
47 #define SR(at, n, dwreg) \
48 { .offset = at * 4, .regno = dwreg, .count = n, .bits = 16, .pad = 2 }
50 GR (0, 1, 3), /* %ebx */
51 GR (1, 2, 1), /* %ecx-%edx */
52 GR (3, 2, 6), /* %esi-%edi */
53 GR (5, 1, 5), /* %ebp */
54 GR (6, 1, 0), /* %eax */
55 SR (7, 1, 43), /* %ds */
56 SR (8, 1, 40), /* %es */
57 SR (9, 1, 44), /* %fs */
58 SR (10, 1, 45), /* %gs */
60 GR (12, 1, 8), /* %eip */
61 SR (13, 1, 41), /* %cs */
62 GR (14, 1, 9), /* eflags */
63 GR (15, 1, 4), /* %esp */
64 SR (16, 1, 42), /* %ss */
69 #define PRSTATUS_REGS_SIZE (17 * 4)
71 #define ULONG uint32_t
73 #define UID_T uint16_t
74 #define GID_T uint16_t
79 #define TYPE_ULONG ELF_T_WORD
80 #define TYPE_PID_T ELF_T_SWORD
81 #define TYPE_UID_T ELF_T_HALF
82 #define TYPE_GID_T ELF_T_HALF
84 #define PRSTATUS_REGSET_ITEMS \
86 .name = "orig_eax", .type = ELF_T_SWORD, .format = 'd', \
87 .offset = offsetof (struct EBLHOOK(prstatus), pr_reg) + (4 * 11), \
91 static const Ebl_Register_Location fpregset_regs[] =
93 { .offset = 0, .regno = 37, .count = 2, .bits = 32 }, /* fctrl-fstat */
94 { .offset = 7 * 4, .regno = 11, .count = 8, .bits = 80 }, /* stN */
96 #define FPREGSET_SIZE 108
98 static const Ebl_Register_Location prxfpreg_regs[] =
100 { .offset = 0, .regno = 37, .count = 2, .bits = 16 }, /* fctrl-fstat */
101 { .offset = 24, .regno = 39, .count = 1, .bits = 32 }, /* mxcsr */
102 { .offset = 32, .regno = 11, .count = 8, .bits = 80, .pad = 6 }, /* stN */
103 { .offset = 32 + 128, .regno = 21, .count = 8, .bits = 128 }, /* xmm */
106 #define EXTRA_NOTES \
107 EXTRA_REGSET (NT_PRXFPREG, 512, prxfpreg_regs) \
109 return tls_info (nhdr->n_descsz, regs_offset, nregloc, reglocs, \
113 static const Ebl_Core_Item tls_items[] =
115 { .type = ELF_T_WORD, .offset = 0x0, .format = 'd', .name = "index" },
116 { .type = ELF_T_WORD, .offset = 0x4, .format = 'x', .name = "base" },
117 { .type = ELF_T_WORD, .offset = 0x8, .format = 'x', .name = "limit" },
118 { .type = ELF_T_WORD, .offset = 0xc, .format = 'x', .name = "flags" },
122 tls_info (GElf_Word descsz, GElf_Word *regs_offset,
123 size_t *nregloc, const Ebl_Register_Location **reglocs,
124 size_t *nitems, const Ebl_Core_Item **items)
126 if (descsz % 16 != 0)
132 *nitems = sizeof tls_items / sizeof tls_items[0];
137 #include "x86_corenote.c"
138 #include "linux-core-note.c"