/src/elfutils/backends/i386_regs.c
Line | Count | Source |
1 | | /* Register names and numbers for i386 DWARF. |
2 | | Copyright (C) 2005, 2006, 2007 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 <string.h> |
34 | | #include <dwarf.h> |
35 | | |
36 | | #define BACKEND i386_ |
37 | | #include "libebl_CPU.h" |
38 | | |
39 | | ssize_t |
40 | | i386_register_info (Ebl *ebl __attribute__ ((unused)), |
41 | | int regno, char *name, size_t namelen, |
42 | | const char **prefix, const char **setname, |
43 | | int *bits, int *type) |
44 | 0 | { |
45 | 0 | if (name == NULL) |
46 | 0 | return 46; |
47 | | |
48 | 0 | if (regno < 0 || regno > 45 || namelen < 6) |
49 | 0 | return -1; |
50 | | |
51 | 0 | *prefix = "%"; |
52 | 0 | *bits = 32; |
53 | 0 | *type = DW_ATE_unsigned; |
54 | 0 | if (regno < 11) |
55 | 0 | { |
56 | 0 | *setname = "integer"; |
57 | 0 | if (regno < 9) |
58 | 0 | *type = DW_ATE_signed; |
59 | 0 | } |
60 | 0 | else if (regno < 19) |
61 | 0 | { |
62 | 0 | *setname = "x87"; |
63 | 0 | *type = DW_ATE_float; |
64 | 0 | *bits = 80; |
65 | 0 | } |
66 | 0 | else if (regno < 29) |
67 | 0 | { |
68 | 0 | *setname = "SSE"; |
69 | 0 | *bits = 128; |
70 | 0 | } |
71 | 0 | else if (regno < 37) |
72 | 0 | { |
73 | 0 | *setname = "MMX"; |
74 | 0 | *bits = 64; |
75 | 0 | } |
76 | 0 | else if (regno < 40) |
77 | 0 | *setname = "FPU-control"; |
78 | 0 | else |
79 | 0 | { |
80 | 0 | *setname = "segment"; |
81 | 0 | *bits = 16; |
82 | 0 | } |
83 | |
|
84 | 0 | switch (regno) |
85 | 0 | { |
86 | 0 | static const char baseregs[][2] = |
87 | 0 | { |
88 | 0 | {'a', 'x'}, |
89 | 0 | {'c', 'x'}, |
90 | 0 | {'d', 'x'}, |
91 | 0 | {'b', 'x'}, |
92 | 0 | {'s', 'p'}, |
93 | 0 | {'b', 'p'}, |
94 | 0 | {'s', 'i'}, |
95 | 0 | {'d', 'i'}, |
96 | 0 | {'i', 'p'}, |
97 | 0 | }; |
98 | | |
99 | 0 | case 4: |
100 | 0 | case 5: |
101 | 0 | case 8: |
102 | 0 | *type = DW_ATE_address; |
103 | 0 | FALLTHROUGH; |
104 | 0 | case 0 ... 3: |
105 | 0 | case 6 ... 7: |
106 | 0 | name[0] = 'e'; |
107 | 0 | name[1] = baseregs[regno][0]; |
108 | 0 | name[2] = baseregs[regno][1]; |
109 | 0 | namelen = 3; |
110 | 0 | break; |
111 | | |
112 | 0 | case 9: |
113 | 0 | return stpcpy (name, "eflags") + 1 - name; |
114 | 0 | case 10: |
115 | 0 | return stpcpy (name, "trapno") + 1 - name; |
116 | | |
117 | 0 | case 11 ... 18: |
118 | 0 | name[0] = 's'; |
119 | 0 | name[1] = 't'; |
120 | 0 | name[2] = regno - 11 + '0'; |
121 | 0 | namelen = 3; |
122 | 0 | break; |
123 | | |
124 | 0 | case 21 ... 28: |
125 | 0 | name[0] = 'x'; |
126 | 0 | name[1] = 'm'; |
127 | 0 | name[2] = 'm'; |
128 | 0 | name[3] = regno - 21 + '0'; |
129 | 0 | namelen = 4; |
130 | 0 | break; |
131 | | |
132 | 0 | case 29 ... 36: |
133 | 0 | name[0] = 'm'; |
134 | 0 | name[1] = 'm'; |
135 | 0 | name[2] = regno - 29 + '0'; |
136 | 0 | namelen = 3; |
137 | 0 | break; |
138 | | |
139 | 0 | case 37: |
140 | 0 | *bits = 16; |
141 | 0 | return stpcpy (name, "fctrl") + 1 - name; |
142 | 0 | case 38: |
143 | 0 | *bits = 16; |
144 | 0 | return stpcpy (name, "fstat") + 1 - name; |
145 | 0 | case 39: |
146 | 0 | return stpcpy (name, "mxcsr") + 1 - name; |
147 | | |
148 | 0 | case 40 ... 45: |
149 | 0 | name[0] = "ecsdfg"[regno - 40]; |
150 | 0 | name[1] = 's'; |
151 | 0 | namelen = 2; |
152 | 0 | break; |
153 | | |
154 | 0 | default: |
155 | 0 | *setname = NULL; |
156 | 0 | return 0; |
157 | 0 | } |
158 | | |
159 | 0 | name[namelen++] = '\0'; |
160 | 0 | return namelen; |
161 | 0 | } |