Imported Upstream version 0.155
[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 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 arm_
37 #include "libebl_CPU.h"
38
39 #define KNOWN_VALUES(...) do                            \
40   {                                                     \
41     static const char *table[] = { __VA_ARGS__ };       \
42     if (value < sizeof table / sizeof table[0])         \
43       *value_name = table[value];                       \
44   } while (0)
45
46 bool
47 arm_check_object_attribute (ebl, vendor, tag, value, tag_name, value_name)
48      Ebl *ebl __attribute__ ((unused));
49      const char *vendor;
50      int tag;
51      uint64_t value __attribute__ ((unused));
52      const char **tag_name;
53      const char **value_name;
54 {
55   if (!strcmp (vendor, "aeabi"))
56     switch (tag)
57       {
58       case 4:
59         *tag_name = "CPU_raw_name";
60         return true;
61       case 5:
62         *tag_name = "CPU_name";
63         return true;
64       case 6:
65         *tag_name = "CPU_arch";
66         KNOWN_VALUES ("Pre-v4",
67                       "v4",
68                       "v4T",
69                       "v5T",
70                       "v5TE",
71                       "v5TEJ",
72                       "v6",
73                       "v6KZ",
74                       "v6T2",
75                       "v6K",
76                       "v7",
77                       "v6-M",
78                       "v6S-M");
79         return true;
80       case 7:
81         *tag_name = "CPU_arch_profile";
82         switch (value)
83           {
84           case 'A':
85             *value_name = "Application";
86             break;
87           case 'R':
88             *value_name = "Realtime";
89             break;
90           case 'M':
91             *value_name = "Microcontroller";
92             break;
93           }
94         return true;
95       case 8:
96         *tag_name = "ARM_ISA_use";
97         KNOWN_VALUES ("No", "Yes");
98         return true;
99       case 9:
100         *tag_name = "THUMB_ISA_use";
101         KNOWN_VALUES ("No", "Thumb-1", "Thumb-2");
102         return true;
103       case 10:
104         *tag_name = "VFP_arch";
105         KNOWN_VALUES ("No", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16");
106         return true;
107       case 11:
108         *tag_name = "WMMX_arch";
109         KNOWN_VALUES ("No", "WMMXv1", "WMMXv2");
110         return true;
111       case 12:
112         *tag_name = "Advanced_SIMD_arch";
113         KNOWN_VALUES ("No", "NEONv1");
114         return true;
115       case 13:
116         *tag_name = "PCS_config";
117         KNOWN_VALUES ("None",
118                       "Bare platform",
119                       "Linux application",
120                       "Linux DSO",
121                       "PalmOS 2004",
122                       "PalmOS (reserved)",
123                       "SymbianOS 2004",
124                       "SymbianOS (reserved)");
125         return true;
126       case 14:
127         *tag_name = "ABI_PCS_R9_use";
128         KNOWN_VALUES ("V6", "SB", "TLS", "Unused");
129         return true;
130       case 15:
131         *tag_name = "ABI_PCS_RW_data";
132         KNOWN_VALUES ("Absolute", "PC-relative", "SB-relative", "None");
133         return true;
134       case 16:
135         *tag_name = "ABI_PCS_RO_data";
136         KNOWN_VALUES ("Absolute", "PC-relative", "None");
137         return true;
138       case 17:
139         *tag_name = "ABI_PCS_GOT_use";
140         KNOWN_VALUES ("None", "direct", "GOT-indirect");
141         return true;
142       case 18:
143         *tag_name = "ABI_PCS_wchar_t";
144         return true;
145       case 19:
146         *tag_name = "ABI_FP_rounding";
147         KNOWN_VALUES ("Unused", "Needed");
148         return true;
149       case 20:
150         *tag_name = "ABI_FP_denormal";
151         KNOWN_VALUES ("Unused", "Needed", "Sign only");
152         return true;
153       case 21:
154         *tag_name = "ABI_FP_exceptions";
155         KNOWN_VALUES ("Unused", "Needed");
156         return true;
157       case 22:
158         *tag_name = "ABI_FP_user_exceptions";
159         KNOWN_VALUES ("Unused", "Needed");
160         return true;
161       case 23:
162         *tag_name = "ABI_FP_number_model";
163         KNOWN_VALUES ("Unused", "Finite", "RTABI", "IEEE 754");
164         return true;
165       case 24:
166         *tag_name = "ABI_align8_needed";
167         KNOWN_VALUES ("No", "Yes", "4-byte");
168         return true;
169       case 25:
170         *tag_name = "ABI_align8_preserved";
171         KNOWN_VALUES ("No", "Yes, except leaf SP", "Yes");
172         return true;
173       case 26:
174         *tag_name = "ABI_enum_size";
175         KNOWN_VALUES ("Unused", "small", "int", "forced to int");
176         return true;
177       case 27:
178         *tag_name = "ABI_HardFP_use";
179         KNOWN_VALUES ("as VFP_arch", "SP only", "DP only", "SP and DP");
180         return true;
181       case 28:
182         *tag_name = "ABI_VFP_args";
183         KNOWN_VALUES ("AAPCS", "VFP registers", "custom");
184         return true;
185       case 29:
186         *tag_name = "ABI_WMMX_args";
187         KNOWN_VALUES ("AAPCS", "WMMX registers", "custom");
188         return true;
189       case 30:
190         *tag_name = "ABI_optimization_goals";
191         KNOWN_VALUES ("None",
192                       "Prefer Speed",
193                       "Aggressive Speed",
194                       "Prefer Size",
195                       "Aggressive Size",
196                       "Prefer Debug",
197                       "Aggressive Debug");
198         return true;
199       case 31:
200         *tag_name = "ABI_FP_optimization_goals";
201         KNOWN_VALUES ("None",
202                       "Prefer Speed",
203                       "Aggressive Speed",
204                       "Prefer Size",
205                       "Aggressive Size",
206                       "Prefer Accuracy",
207                       "Aggressive Accuracy");
208         return true;
209       case 34:
210         *tag_name = "CPU_unaligned_access";
211         KNOWN_VALUES ("None", "v6");
212         return true;
213       case 36:
214         *tag_name = "VFP_HP_extension";
215         KNOWN_VALUES ("Not Allowed", "Allowed");
216         return true;
217       case 38:
218         *tag_name = "ABI_FP_16bit_format";
219         KNOWN_VALUES ("None", "IEEE 754", "Alternative Format");
220         return true;
221       case 64:
222         *tag_name = "nodefaults";
223         return true;
224       case 65:
225         *tag_name = "also_compatible_with";
226         return true;
227       case 66:
228         *tag_name = "T2EE_use";
229         KNOWN_VALUES ("Not Allowed", "Allowed");
230         return true;
231       case 67:
232         *tag_name = "conformance";
233         return true;
234       case 68:
235         *tag_name = "Virtualization_use";
236         KNOWN_VALUES ("Not Allowed", "Allowed");
237         return true;
238       case 70:
239         *tag_name = "MPextension_use";
240         KNOWN_VALUES ("Not Allowed", "Allowed");
241         return true;
242       }
243
244   return false;
245 }