1 /* AArch64 specific core note handling.
2 Copyright (C) 2013 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/>. */
39 #define BACKEND aarch64_
40 #include "libebl_CPU.h"
42 #define ULONG uint64_t
44 #define UID_T uint32_t
45 #define GID_T uint32_t
50 #define TYPE_ULONG ELF_T_XWORD
51 #define TYPE_PID_T ELF_T_SWORD
52 #define TYPE_UID_T ELF_T_WORD
53 #define TYPE_GID_T ELF_T_WORD
55 #define PRSTATUS_REGS_SIZE (34 * 8)
57 static const Ebl_Register_Location prstatus_regs[] =
59 { .offset = 0, .regno = 0, .count = 32, .bits = 64 }, /* x0..x30, sp */
62 #define PRSTATUS_REGSET_ITEMS \
64 .name = "pc", .type = ELF_T_XWORD, .format = 'x', \
65 .offset = (offsetof (struct EBLHOOK(prstatus), pr_reg) \
66 + PRSTATUS_REGS_SIZE - 16), \
67 .group = "register", \
71 .name = "pstate", .type = ELF_T_XWORD, .format = 'x', \
72 .offset = (offsetof (struct EBLHOOK(prstatus), pr_reg) \
73 + PRSTATUS_REGS_SIZE - 8), \
77 static const Ebl_Register_Location aarch64_fpregset_regs[] =
79 { .offset = 0, .regno = 64, .count = 32, .bits = 128 }, /* v0..v31 */
82 static const Ebl_Core_Item aarch64_fpregset_items[] =
85 .name = "fpsr", .type = ELF_T_WORD, .format = 'x',
86 .offset = 512, .group = "register"
89 .name = "fpcr", .type = ELF_T_WORD, .format = 'x',
90 .offset = 516, .group = "register"
94 static const Ebl_Core_Item aarch64_tls_items[] =
97 .name = "tls", .type = ELF_T_XWORD, .format = 'x',
98 .offset = 0, .group = "register"
102 #define AARCH64_HWBP_REG(KIND, N) \
104 .name = "DBG" KIND "VR" #N "_EL1", .type = ELF_T_XWORD, .format = 'x', \
105 .offset = 8 + N * 16, .group = "register" \
108 .name = "DBG" KIND "CR" #N "_EL1", .type = ELF_T_WORD, .format = 'x', \
109 .offset = 16 + N * 16, .group = "register" \
112 #define AARCH64_BP_WP_GROUP(KIND, NAME) \
113 static const Ebl_Core_Item NAME[] = \
116 .name = "dbg_info", .type = ELF_T_WORD, .format = 'x', \
117 .offset = 0, .group = "control" \
119 /* N.B.: 4 bytes of padding here. */ \
121 AARCH64_HWBP_REG(KIND, 0), \
122 AARCH64_HWBP_REG(KIND, 1), \
123 AARCH64_HWBP_REG(KIND, 2), \
124 AARCH64_HWBP_REG(KIND, 3), \
125 AARCH64_HWBP_REG(KIND, 4), \
126 AARCH64_HWBP_REG(KIND, 5), \
127 AARCH64_HWBP_REG(KIND, 6), \
128 AARCH64_HWBP_REG(KIND, 7), \
129 AARCH64_HWBP_REG(KIND, 8), \
130 AARCH64_HWBP_REG(KIND, 9), \
131 AARCH64_HWBP_REG(KIND, 10), \
132 AARCH64_HWBP_REG(KIND, 11), \
133 AARCH64_HWBP_REG(KIND, 12), \
134 AARCH64_HWBP_REG(KIND, 13), \
135 AARCH64_HWBP_REG(KIND, 14), \
136 AARCH64_HWBP_REG(KIND, 15), \
138 /* The DBGBVR+DBGBCR pair only takes 12 bytes. There are 4 bytes \
139 of padding at the end of each pair. The item formatter in \
140 readelf can skip those, but the missing 4 bytes at the end of \
141 the whole block cause it to assume the whole item bunch \
142 repeats, so it loops around to read more. Insert an explicit \
143 (but invisible) padding word. */ \
145 .name = "", .type = ELF_T_WORD, .format = 'h', \
146 .offset = 260, .group = "register" \
150 AARCH64_BP_WP_GROUP ("B", aarch64_hw_bp_items);
151 AARCH64_BP_WP_GROUP ("W", aarch64_hw_wp_items);
153 #undef AARCH64_BP_WP_GROUP
154 #undef AARCH64_HWBP_REG
156 #define EXTRA_NOTES \
157 EXTRA_REGSET_ITEMS (NT_FPREGSET, 528, \
158 aarch64_fpregset_regs, aarch64_fpregset_items) \
159 EXTRA_ITEMS (NT_ARM_TLS, 8, aarch64_tls_items) \
160 EXTRA_ITEMS (NT_ARM_HW_BREAK, 264, aarch64_hw_bp_items) \
161 EXTRA_ITEMS (NT_ARM_HW_WATCH, 264, aarch64_hw_wp_items)
163 #include "linux-core-note.c"