Imported Upstream version 0.153
[platform/upstream/elfutils.git] / backends / arm_attrs.c
1 /* Object attribute tags for ARM.
2    Copyright (C) 2009 Red Hat, Inc.
3    This file is part of Red Hat elfutils.
4
5    Red Hat elfutils is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by the
7    Free Software Foundation; version 2 of the License.
8
9    Red Hat elfutils is distributed in the hope that it will be useful, but
10    WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    General Public License for more details.
13
14    You should have received a copy of the GNU General Public License along
15    with Red Hat elfutils; if not, write to the Free Software Foundation,
16    Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
17
18    Red Hat elfutils is an included package of the Open Invention Network.
19    An included package of the Open Invention Network is a package for which
20    Open Invention Network licensees cross-license their patents.  No patent
21    license is granted, either expressly or impliedly, by designation as an
22    included package.  Should you wish to participate in the Open Invention
23    Network licensing program, please visit www.openinventionnetwork.com
24    <http://www.openinventionnetwork.com>.  */
25
26 #ifdef HAVE_CONFIG_H
27 # include <config.h>
28 #endif
29
30 #include <string.h>
31 #include <dwarf.h>
32
33 #define BACKEND arm_
34 #include "libebl_CPU.h"
35
36 #define KNOWN_VALUES(...) do                            \
37   {                                                     \
38     static const char *table[] = { __VA_ARGS__ };       \
39     if (value < sizeof table / sizeof table[0])         \
40       *value_name = table[value];                       \
41   } while (0)
42
43 bool
44 arm_check_object_attribute (ebl, vendor, tag, value, tag_name, value_name)
45      Ebl *ebl __attribute__ ((unused));
46      const char *vendor;
47      int tag;
48      uint64_t value __attribute__ ((unused));
49      const char **tag_name;
50      const char **value_name;
51 {
52   if (!strcmp (vendor, "aeabi"))
53     switch (tag)
54       {
55       case 4:
56         *tag_name = "CPU_raw_name";
57         return true;
58       case 5:
59         *tag_name = "CPU_name";
60         return true;
61       case 6:
62         *tag_name = "CPU_arch";
63         KNOWN_VALUES ("Pre-v4",
64                       "v4",
65                       "v4T",
66                       "v5T",
67                       "v5TE",
68                       "v5TEJ",
69                       "v6",
70                       "v6KZ",
71                       "v6T2",
72                       "v6K",
73                       "v7",
74                       "v6-M",
75                       "v6S-M");
76         return true;
77       case 7:
78         *tag_name = "CPU_arch_profile";
79         switch (value)
80           {
81           case 'A':
82             *value_name = "Application";
83             break;
84           case 'R':
85             *value_name = "Realtime";
86             break;
87           case 'M':
88             *value_name = "Microcontroller";
89             break;
90           }
91         return true;
92       case 8:
93         *tag_name = "ARM_ISA_use";
94         KNOWN_VALUES ("No", "Yes");
95         return true;
96       case 9:
97         *tag_name = "THUMB_ISA_use";
98         KNOWN_VALUES ("No", "Thumb-1", "Thumb-2");
99         return true;
100       case 10:
101         *tag_name = "VFP_arch";
102         KNOWN_VALUES ("No", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16");
103         return true;
104       case 11:
105         *tag_name = "WMMX_arch";
106         KNOWN_VALUES ("No", "WMMXv1", "WMMXv2");
107         return true;
108       case 12:
109         *tag_name = "Advanced_SIMD_arch";
110         KNOWN_VALUES ("No", "NEONv1");
111         return true;
112       case 13:
113         *tag_name = "PCS_config";
114         KNOWN_VALUES ("None",
115                       "Bare platform",
116                       "Linux application",
117                       "Linux DSO",
118                       "PalmOS 2004",
119                       "PalmOS (reserved)",
120                       "SymbianOS 2004",
121                       "SymbianOS (reserved)");
122         return true;
123       case 14:
124         *tag_name = "ABI_PCS_R9_use";
125         KNOWN_VALUES ("V6", "SB", "TLS", "Unused");
126         return true;
127       case 15:
128         *tag_name = "ABI_PCS_RW_data";
129         KNOWN_VALUES ("Absolute", "PC-relative", "SB-relative", "None");
130         return true;
131       case 16:
132         *tag_name = "ABI_PCS_RO_data";
133         KNOWN_VALUES ("Absolute", "PC-relative", "None");
134         return true;
135       case 17:
136         *tag_name = "ABI_PCS_GOT_use";
137         KNOWN_VALUES ("None", "direct", "GOT-indirect");
138         return true;
139       case 18:
140         *tag_name = "ABI_PCS_wchar_t";
141         return true;
142       case 19:
143         *tag_name = "ABI_FP_rounding";
144         KNOWN_VALUES ("Unused", "Needed");
145         return true;
146       case 20:
147         *tag_name = "ABI_FP_denormal";
148         KNOWN_VALUES ("Unused", "Needed", "Sign only");
149         return true;
150       case 21:
151         *tag_name = "ABI_FP_exceptions";
152         KNOWN_VALUES ("Unused", "Needed");
153         return true;
154       case 22:
155         *tag_name = "ABI_FP_user_exceptions";
156         KNOWN_VALUES ("Unused", "Needed");
157         return true;
158       case 23:
159         *tag_name = "ABI_FP_number_model";
160         KNOWN_VALUES ("Unused", "Finite", "RTABI", "IEEE 754");
161         return true;
162       case 24:
163         *tag_name = "ABI_align8_needed";
164         KNOWN_VALUES ("No", "Yes", "4-byte");
165         return true;
166       case 25:
167         *tag_name = "ABI_align8_preserved";
168         KNOWN_VALUES ("No", "Yes, except leaf SP", "Yes");
169         return true;
170       case 26:
171         *tag_name = "ABI_enum_size";
172         KNOWN_VALUES ("Unused", "small", "int", "forced to int");
173         return true;
174       case 27:
175         *tag_name = "ABI_HardFP_use";
176         KNOWN_VALUES ("as VFP_arch", "SP only", "DP only", "SP and DP");
177         return true;
178       case 28:
179         *tag_name = "ABI_VFP_args";
180         KNOWN_VALUES ("AAPCS", "VFP registers", "custom");
181         return true;
182       case 29:
183         *tag_name = "ABI_WMMX_args";
184         KNOWN_VALUES ("AAPCS", "WMMX registers", "custom");
185         return true;
186       case 30:
187         *tag_name = "ABI_optimization_goals";
188         KNOWN_VALUES ("None",
189                       "Prefer Speed",
190                       "Aggressive Speed",
191                       "Prefer Size",
192                       "Aggressive Size",
193                       "Prefer Debug",
194                       "Aggressive Debug");
195         return true;
196       case 31:
197         *tag_name = "ABI_FP_optimization_goals";
198         KNOWN_VALUES ("None",
199                       "Prefer Speed",
200                       "Aggressive Speed",
201                       "Prefer Size",
202                       "Aggressive Size",
203                       "Prefer Accuracy",
204                       "Aggressive Accuracy");
205         return true;
206       case 34:
207         *tag_name = "CPU_unaligned_access";
208         KNOWN_VALUES ("None", "v6");
209         return true;
210       case 36:
211         *tag_name = "VFP_HP_extension";
212         KNOWN_VALUES ("Not Allowed", "Allowed");
213         return true;
214       case 38:
215         *tag_name = "ABI_FP_16bit_format";
216         KNOWN_VALUES ("None", "IEEE 754", "Alternative Format");
217         return true;
218       case 64:
219         *tag_name = "nodefaults";
220         return true;
221       case 65:
222         *tag_name = "also_compatible_with";
223         return true;
224       case 66:
225         *tag_name = "T2EE_use";
226         KNOWN_VALUES ("Not Allowed", "Allowed");
227         return true;
228       case 67:
229         *tag_name = "conformance";
230         return true;
231       case 68:
232         *tag_name = "Virtualization_use";
233         KNOWN_VALUES ("Not Allowed", "Allowed");
234         return true;
235       case 70:
236         *tag_name = "MPextension_use";
237         KNOWN_VALUES ("Not Allowed", "Allowed");
238         return true;
239       }
240
241   return false;
242 }