/src/elfutils/backends/aarch64_regs.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Register names and numbers for AArch64 DWARF. |
2 | | Copyright (C) 2013, 2014 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 <stdio.h> |
34 | | #include <string.h> |
35 | | #include <dwarf.h> |
36 | | #include <stdarg.h> |
37 | | |
38 | | #define BACKEND aarch64_ |
39 | | #include "libebl_CPU.h" |
40 | | |
41 | | __attribute__ ((format (printf, 7, 8))) |
42 | | static ssize_t |
43 | | do_regtype (const char *setname, int type, |
44 | | const char **setnamep, int *typep, |
45 | | char *name, size_t namelen, const char *fmt, ...) |
46 | 0 | { |
47 | 0 | *setnamep = setname; |
48 | 0 | *typep = type; |
49 | |
|
50 | 0 | va_list ap; |
51 | 0 | va_start (ap, fmt); |
52 | 0 | int s = vsnprintf (name, namelen, fmt, ap); |
53 | 0 | va_end(ap); |
54 | |
|
55 | 0 | if (s < 0 || (unsigned) s >= namelen) |
56 | 0 | return -1; |
57 | 0 | return s + 1; |
58 | 0 | } |
59 | | |
60 | | ssize_t |
61 | | aarch64_register_info (Ebl *ebl __attribute__ ((unused)), |
62 | | int regno, char *name, size_t namelen, |
63 | | const char **prefix, const char **setnamep, |
64 | | int *bits, int *typep) |
65 | 0 | { |
66 | 0 | if (name == NULL) |
67 | 0 | return 128; |
68 | | |
69 | | |
70 | 0 | *prefix = ""; |
71 | 0 | *bits = 64; |
72 | |
|
73 | 0 | #define regtype(setname, type, ...) \ |
74 | 0 | do_regtype(setname, type, setnamep, typep, name, namelen, __VA_ARGS__) |
75 | |
|
76 | 0 | switch (regno) |
77 | 0 | { |
78 | 0 | case 0 ... 30: |
79 | 0 | return regtype ("integer", DW_ATE_signed, "x%d", regno); |
80 | | |
81 | 0 | case 31: |
82 | 0 | return regtype ("integer", DW_ATE_address, "sp"); |
83 | | |
84 | 0 | case 32: |
85 | 0 | return 0; |
86 | | |
87 | 0 | case 33: |
88 | 0 | return regtype ("integer", DW_ATE_address, "elr"); |
89 | | |
90 | 0 | case 34: |
91 | 0 | return regtype ("integer", DW_ATE_unsigned, "ra_sign_state"); |
92 | | |
93 | 0 | case 35 ... 63: |
94 | 0 | return 0; |
95 | | |
96 | 0 | case 64 ... 95: |
97 | | /* FP/SIMD register file supports a variety of data types--it |
98 | | can be thought of as a register holding a single integer or |
99 | | floating-point value, or a vector of 8-, 16-, 32- or 64-bit |
100 | | integers. 128-bit quad-word is the only singular value that |
101 | | covers the whole register, so mark the register thus. */ |
102 | 0 | *bits = 128; |
103 | 0 | return regtype ("FP/SIMD", DW_ATE_unsigned, "v%d", regno - 64); |
104 | | |
105 | 0 | case 96 ... 127: |
106 | 0 | return 0; |
107 | | |
108 | 0 | default: |
109 | 0 | return -1; |
110 | 0 | } |
111 | 0 | } |