llvm.org GIT mirror llvm / 459c949
tools: add support for decoding ARM attributes Enhance the ARM specific parsing support in llvm-readobj to support attributes. This allows for simpler tests to validate encoding of the build attributes as specified in the ARM ELF specification. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200450 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 6 years ago
9 changed file(s) with 1121 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 @ RUN: llvm-mc -triple armv7-eabi -filetype obj -o - %s \
1 @ RUN: | llvm-readobj -arm-attributes - | FileCheck %s
2
3 .syntax unified
4
5 .cpu cortex-a8
6 .fpu neon
7
8 .eabi_attribute Tag_CPU_raw_name, "Cortex-A9"
9 .eabi_attribute Tag_CPU_name, "cortex-a9"
10 .eabi_attribute Tag_CPU_arch, 10
11 .eabi_attribute Tag_CPU_arch_profile, 'A'
12 .eabi_attribute Tag_ARM_ISA_use, 0
13 .eabi_attribute Tag_THUMB_ISA_use, 2
14 .eabi_attribute Tag_FP_arch, 3
15 .eabi_attribute Tag_WMMX_arch, 0
16 .eabi_attribute Tag_Advanced_SIMD_arch, 1
17 .eabi_attribute Tag_PCS_config, 2
18 .eabi_attribute Tag_ABI_PCS_R9_use, 0
19 .eabi_attribute Tag_ABI_PCS_RW_data, 0
20 .eabi_attribute Tag_ABI_PCS_RO_data, 0
21 .eabi_attribute Tag_ABI_PCS_GOT_use, 0
22 .eabi_attribute Tag_ABI_PCS_wchar_t, 4
23 .eabi_attribute Tag_ABI_FP_rounding, 1
24 .eabi_attribute Tag_ABI_FP_denormal, 2
25 .eabi_attribute Tag_ABI_FP_exceptions, 1
26 .eabi_attribute Tag_ABI_FP_user_exceptions, 1
27 .eabi_attribute Tag_ABI_FP_number_model, 3
28 .eabi_attribute Tag_ABI_align_needed, 1
29 .eabi_attribute Tag_ABI_align_preserved, 2
30 .eabi_attribute Tag_ABI_enum_size, 3
31 .eabi_attribute Tag_ABI_HardFP_use, 0
32 .eabi_attribute Tag_ABI_VFP_args, 1
33 .eabi_attribute Tag_ABI_WMMX_args, 0
34 .eabi_attribute Tag_ABI_optimization_goals, 2
35 .eabi_attribute Tag_ABI_FP_optimization_goals, 2
36 .eabi_attribute Tag_compatibility, 1
37 .eabi_attribute Tag_compatibility, 1, "aeabi"
38 .eabi_attribute Tag_CPU_unaligned_access, 0
39 .eabi_attribute Tag_FP_HP_extension, 0
40 .eabi_attribute Tag_ABI_FP_16bit_format, 0
41 .eabi_attribute Tag_MPextension_use, 0
42 .eabi_attribute Tag_DIV_use, 0
43 .eabi_attribute Tag_nodefaults, 0
44 .eabi_attribute Tag_also_compatible_with, "gnu"
45 .eabi_attribute Tag_T2EE_use, 0
46 .eabi_attribute Tag_conformance, "2.09"
47 .eabi_attribute Tag_Virtualization_use, 0
48
49 @ CHECK: BuildAttributes {
50 @ CHECK: Section 1 {
51 @ CHECK: Tag: Tag_File (0x1)
52 @ CHECK: FileAttributes {
53 @ CHECK: Attribute {
54 @ CHECK: Tag: 4
55 @ CHECK: TagName: CPU_raw_name
56 @ CHECK: Value: CORTEX-A9
57 @ CHECK: }
58 @ CHECK: Attribute {
59 @ CHECK: Tag: 5
60 @ CHECK: TagName: CPU_name
61 @ CHECK: Value: CORTEX-A9
62 @ CHECK: }
63 @ CHECK: Attribute {
64 @ CHECK: Tag: 6
65 @ CHECK: Value: 10
66 @ CHECK: TagName: CPU_arch
67 @ CHECK: Description: ARM v7
68 @ CHECK: }
69 @ CHECK: Attribute {
70 @ CHECK: Tag: 7
71 @ CHECK: Value: 65
72 @ CHECK: TagName: CPU_arch_profile
73 @ CHECK: Description: Application
74 @ CHECK: }
75 @ CHECK: Attribute {
76 @ CHECK: Tag: 8
77 @ CHECK: Value: 0
78 @ CHECK: TagName: ARM_ISA_use
79 @ CHECK: Description: Not Permitted
80 @ CHECK: }
81 @ CHECK: Attribute {
82 @ CHECK: Tag: 9
83 @ CHECK: Value: 2
84 @ CHECK: TagName: THUMB_ISA_use
85 @ CHECK: Description: Thumb-2
86 @ CHECK: }
87 @ CHECK: Attribute {
88 @ CHECK: Tag: 10
89 @ CHECK: Value: 3
90 @ CHECK: TagName: FP_arch
91 @ CHECK: Description: VFPv3
92 @ CHECK: }
93 @ CHECK: Attribute {
94 @ CHECK: Tag: 11
95 @ CHECK: Value: 0
96 @ CHECK: TagName: WMMX_arch
97 @ CHECK: Description: Not Permitted
98 @ CHECK: }
99 @ CHECK: Attribute {
100 @ CHECK: Tag: 12
101 @ CHECK: Value: 1
102 @ CHECK: TagName: Advanced_SIMD_arch
103 @ CHECK: Description: NEONv1
104 @ CHECK: }
105 @ CHECK: Attribute {
106 @ CHECK: Tag: 13
107 @ CHECK: Value: 2
108 @ CHECK: TagName: PCS_config
109 @ CHECK: Description: Linux Application
110 @ CHECK: }
111 @ CHECK: Attribute {
112 @ CHECK: Tag: 14
113 @ CHECK: Value: 0
114 @ CHECK: TagName: ABI_PCS_R9_use
115 @ CHECK: Description: v6
116 @ CHECK: }
117 @ CHECK: Attribute {
118 @ CHECK: Tag: 15
119 @ CHECK: Value: 0
120 @ CHECK: TagName: ABI_PCS_RW_data
121 @ CHECK: Description: Absolute
122 @ CHECK: }
123 @ CHECK: Attribute {
124 @ CHECK: Tag: 16
125 @ CHECK: Value: 0
126 @ CHECK: TagName: ABI_PCS_RO_data
127 @ CHECK: Description: Absolute
128 @ CHECK: }
129 @ CHECK: Attribute {
130 @ CHECK: Tag: 17
131 @ CHECK: Value: 0
132 @ CHECK: TagName: ABI_PCS_GOT_use
133 @ CHECK: Description: Not Permitted
134 @ CHECK: }
135 @ CHECK: Attribute {
136 @ CHECK: Tag: 18
137 @ CHECK: Value: 4
138 @ CHECK: TagName: ABI_PCS_wchar_t
139 @ CHECK: Description: 4-byte
140 @ CHECK: }
141 @ CHECK: Attribute {
142 @ CHECK: Tag: 19
143 @ CHECK: Value: 1
144 @ CHECK: TagName: ABI_FP_rounding
145 @ CHECK: Description: Runtime
146 @ CHECK: }
147 @ CHECK: Attribute {
148 @ CHECK: Tag: 20
149 @ CHECK: Value: 2
150 @ CHECK: TagName: ABI_FP_denormal
151 @ CHECK: Description: Sign Only
152 @ CHECK: }
153 @ CHECK: Attribute {
154 @ CHECK: Tag: 21
155 @ CHECK: Value: 1
156 @ CHECK: TagName: ABI_FP_exceptions
157 @ CHECK: Description: IEEE-754
158 @ CHECK: }
159 @ CHECK: Attribute {
160 @ CHECK: Tag: 22
161 @ CHECK: Value: 1
162 @ CHECK: TagName: ABI_FP_user_exceptions
163 @ CHECK: Description: IEEE-754
164 @ CHECK: }
165 @ CHECK: Attribute {
166 @ CHECK: Tag: 23
167 @ CHECK: Value: 3
168 @ CHECK: TagName: ABI_FP_number_model
169 @ CHECK: Description: IEEE-754
170 @ CHECK: }
171 @ CHECK: Attribute {
172 @ CHECK: Tag: 24
173 @ CHECK: Value: 1
174 @ CHECK: TagName: ABI_align_needed
175 @ CHECK: Description: 8-byte alignment
176 @ CHECK: }
177 @ CHECK: Attribute {
178 @ CHECK: Tag: 25
179 @ CHECK: Value: 2
180 @ CHECK: TagName: ABI_align_preserved
181 @ CHECK: Description: 8-byte data and code alignment
182 @ CHECK: }
183 @ CHECK: Attribute {
184 @ CHECK: Tag: 26
185 @ CHECK: Value: 3
186 @ CHECK: TagName: ABI_enum_size
187 @ CHECK: Description: External Int32
188 @ CHECK: }
189 @ CHECK: Attribute {
190 @ CHECK: Tag: 27
191 @ CHECK: Value: 0
192 @ CHECK: TagName: ABI_HardFP_use
193 @ CHECK: Description: Tag_FP_arch
194 @ CHECK: }
195 @ CHECK: Attribute {
196 @ CHECK: Tag: 28
197 @ CHECK: Value: 1
198 @ CHECK: TagName: ABI_VFP_args
199 @ CHECK: Description: AAPCS VFP
200 @ CHECK: }
201 @ CHECK: Attribute {
202 @ CHECK: Tag: 29
203 @ CHECK: Value: 0
204 @ CHECK: TagName: ABI_WMMX_args
205 @ CHECK: Description: AAPCS
206 @ CHECK: }
207 @ CHECK: Attribute {
208 @ CHECK: Tag: 30
209 @ CHECK: Value: 2
210 @ CHECK: TagName: ABI_optimization_goals
211 @ CHECK: Description: Aggressive Speed
212 @ CHECK: }
213 @ CHECK: Attribute {
214 @ CHECK: Tag: 31
215 @ CHECK: Value: 2
216 @ CHECK: TagName: ABI_FP_optimization_goals
217 @ CHECK: Description: Aggressive Speed
218 @ CHECK: }
219 @ CHECK: Attribute {
220 @ CHECK: Tag: 32
221 @ CHECK: Value: 1, AEABI
222 @ CHECK: TagName: compatibility
223 @ CHECK: Description: AEABI Conformant
224 @ CHECK: }
225 @ CHECK: Attribute {
226 @ CHECK: Tag: 34
227 @ CHECK: Value: 0
228 @ CHECK: TagName: CPU_unaligned_access
229 @ CHECK: Description: Not Permitted
230 @ CHECK: }
231 @ CHECK: Attribute {
232 @ CHECK: Tag: 36
233 @ CHECK: Value: 0
234 @ CHECK: TagName: FP_HP_extension
235 @ CHECK: Description: If Available
236 @ CHECK: }
237 @ CHECK: Attribute {
238 @ CHECK: Tag: 38
239 @ CHECK: Value: 0
240 @ CHECK: TagName: ABI_FP_16bit_format
241 @ CHECK: Description: Not Permitted
242 @ CHECK: }
243 @ CHECK: Attribute {
244 @ CHECK: Tag: 42
245 @ CHECK: Value: 0
246 @ CHECK: TagName: MPextension_use
247 @ CHECK: Description: Not Permitted
248 @ CHECK: }
249 @ CHECK: Attribute {
250 @ CHECK: Tag: 44
251 @ CHECK: Value: 0
252 @ CHECK: TagName: DIV_use
253 @ CHECK: Description: If Available
254 @ CHECK: }
255 @ CHECK: Attribute {
256 @ CHECK: Tag: 64
257 @ CHECK: Value: 0
258 @ CHECK: TagName: nodefaults
259 @ CHECK: Description: Unspecified Tags UNDEFINED
260 @ CHECK: }
261 @ CHECK: Attribute {
262 @ CHECK: Tag: 65
263 @ CHECK: TagName: also_compatible_with
264 @ CHECK: Value: GNU
265 @ CHECK: }
266 @ CHECK: Attribute {
267 @ CHECK: Tag: 66
268 @ CHECK: Value: 0
269 @ CHECK: TagName: T2EE_use
270 @ CHECK: Description: Not Permitted
271 @ CHECK: }
272 @ CHECK: Attribute {
273 @ CHECK: Tag: 67
274 @ CHECK: TagName: conformance
275 @ CHECK: Value: 2.09
276 @ CHECK: }
277 @ CHECK: Attribute {
278 @ CHECK: Tag: 68
279 @ CHECK: Value: 0
280 @ CHECK: TagName: Virtualization_use
281 @ CHECK: Description: Not Permitted
282 @ CHECK: }
283 @ CHECK: }
284 @ CHECK: }
285 @ CHECK: }
286
0 //===--- ARMAttributeParser.cpp - ARM Attribute Information Printer -------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "ARMAttributeParser.h"
10 #include "StreamWriter.h"
11 #include "llvm/ADT/StringExtras.h"
12 #include "llvm/Support/LEB128.h"
13
14 using namespace llvm;
15 using namespace llvm::ARMBuildAttrs;
16
17
18 static const EnumEntry TagNames[] = {
19 { "Tag_File", ARMBuildAttrs::File },
20 { "Tag_Section", ARMBuildAttrs::Section },
21 { "Tag_Symbol", ARMBuildAttrs::Symbol },
22 };
23
24 template
25 size_t countof(const type_ (&)[size_]) {
26 return size_;
27 }
28
29 namespace llvm {
30 #define ATTRIBUTE_HANDLER(Attr_) \
31 { ARMBuildAttrs::Attr_, &ARMAttributeParser::Attr_ }
32
33 const ARMAttributeParser::DisplayHandler
34 ARMAttributeParser::DisplayRoutines[] = {
35 { ARMBuildAttrs::CPU_raw_name, &ARMAttributeParser::StringAttribute, },
36 { ARMBuildAttrs::CPU_name, &ARMAttributeParser::StringAttribute },
37 ATTRIBUTE_HANDLER(CPU_arch),
38 ATTRIBUTE_HANDLER(CPU_arch_profile),
39 ATTRIBUTE_HANDLER(ARM_ISA_use),
40 ATTRIBUTE_HANDLER(THUMB_ISA_use),
41 ATTRIBUTE_HANDLER(FP_arch),
42 ATTRIBUTE_HANDLER(WMMX_arch),
43 ATTRIBUTE_HANDLER(Advanced_SIMD_arch),
44 ATTRIBUTE_HANDLER(PCS_config),
45 ATTRIBUTE_HANDLER(ABI_PCS_R9_use),
46 ATTRIBUTE_HANDLER(ABI_PCS_RW_data),
47 ATTRIBUTE_HANDLER(ABI_PCS_RO_data),
48 ATTRIBUTE_HANDLER(ABI_PCS_GOT_use),
49 ATTRIBUTE_HANDLER(ABI_PCS_wchar_t),
50 ATTRIBUTE_HANDLER(ABI_FP_rounding),
51 ATTRIBUTE_HANDLER(ABI_FP_denormal),
52 ATTRIBUTE_HANDLER(ABI_FP_exceptions),
53 ATTRIBUTE_HANDLER(ABI_FP_user_exceptions),
54 ATTRIBUTE_HANDLER(ABI_FP_number_model),
55 ATTRIBUTE_HANDLER(ABI_align_needed),
56 ATTRIBUTE_HANDLER(ABI_align_preserved),
57 ATTRIBUTE_HANDLER(ABI_enum_size),
58 ATTRIBUTE_HANDLER(ABI_HardFP_use),
59 ATTRIBUTE_HANDLER(ABI_VFP_args),
60 ATTRIBUTE_HANDLER(ABI_WMMX_args),
61 ATTRIBUTE_HANDLER(ABI_optimization_goals),
62 ATTRIBUTE_HANDLER(ABI_FP_optimization_goals),
63 ATTRIBUTE_HANDLER(compatibility),
64 ATTRIBUTE_HANDLER(CPU_unaligned_access),
65 ATTRIBUTE_HANDLER(FP_HP_extension),
66 ATTRIBUTE_HANDLER(ABI_FP_16bit_format),
67 ATTRIBUTE_HANDLER(MPextension_use),
68 ATTRIBUTE_HANDLER(DIV_use),
69 ATTRIBUTE_HANDLER(T2EE_use),
70 ATTRIBUTE_HANDLER(Virtualization_use),
71 ATTRIBUTE_HANDLER(nodefaults)
72 };
73
74 #undef ATTRIBUTE_HANDLER
75
76 uint64_t ARMAttributeParser::ParseInteger(const uint8_t *Data,
77 uint32_t &Offset) {
78 unsigned Length;
79 uint64_t Value = decodeULEB128(Data + Offset, &Length);
80 Offset = Offset + Length;
81 return Value;
82 }
83
84 StringRef ARMAttributeParser::ParseString(const uint8_t *Data,
85 uint32_t &Offset) {
86 const char *String = reinterpret_cast(Data + Offset);
87 size_t Length = std::strlen(String);
88 Offset = Offset + Length + 1;
89 return StringRef(String, Length);
90 }
91
92 void ARMAttributeParser::IntegerAttribute(AttrType Tag, const uint8_t *Data,
93 uint32_t &Offset) {
94 SW.printNumber(ARMBuildAttrs::AttrTypeAsString(Tag),
95 ParseInteger(Data, Offset));
96 }
97
98 void ARMAttributeParser::StringAttribute(AttrType Tag, const uint8_t *Data,
99 uint32_t &Offset) {
100 StringRef TagName = ARMBuildAttrs::AttrTypeAsString(Tag, /*TagPrefix*/false);
101
102 DictScope AS(SW, "Attribute");
103 SW.printNumber("Tag", Tag);
104 if (!TagName.empty())
105 SW.printString("TagName", TagName);
106 SW.printString("Value", ParseString(Data, Offset));
107 }
108
109 void ARMAttributeParser::PrintAttribute(unsigned Tag, unsigned Value,
110 StringRef ValueDesc) {
111 StringRef TagName = ARMBuildAttrs::AttrTypeAsString(Tag, /*TagPrefix*/false);
112
113 DictScope AS(SW, "Attribute");
114 SW.printNumber("Tag", Tag);
115 SW.printNumber("Value", Value);
116 if (!TagName.empty())
117 SW.printString("TagName", TagName);
118 if (!ValueDesc.empty())
119 SW.printString("Description", ValueDesc);
120 }
121
122 void ARMAttributeParser::CPU_arch(AttrType Tag, const uint8_t *Data,
123 uint32_t &Offset) {
124 static const char *Strings[] = {
125 "Pre-v4", "ARM v4", "ARM v4T", "ARM v5T", "ARM v5TE", "ARM v5TEJ", "ARM v6",
126 "ARM v6KZ", "ARM v6T2", "ARM v6K", "ARM v7", "ARM v6-M", "ARM v6S-M",
127 "ARM v7E-M", "ARM v8"
128 };
129
130 uint64_t Value = ParseInteger(Data, Offset);
131 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
132 PrintAttribute(Tag, Value, ValueDesc);
133 }
134
135 void ARMAttributeParser::CPU_arch_profile(AttrType Tag, const uint8_t *Data,
136 uint32_t &Offset) {
137 uint64_t Encoded = ParseInteger(Data, Offset);
138
139 StringRef Profile;
140 switch (Encoded) {
141 default: Profile = "Unknown"; break;
142 case 'A': Profile = "Application"; break;
143 case 'R': Profile = "Real-time"; break;
144 case 'M': Profile = "Microcontroller"; break;
145 case 'S': Profile = "Classic"; break;
146 case '0': Profile = "None"; break;
147 }
148
149 PrintAttribute(Tag, Encoded, Profile);
150 }
151
152 void ARMAttributeParser::ARM_ISA_use(AttrType Tag, const uint8_t *Data,
153 uint32_t &Offset) {
154 static const char *Strings[] = { "Not Permitted", "Permitted" };
155
156 uint64_t Value = ParseInteger(Data, Offset);
157 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
158 PrintAttribute(Tag, Value, ValueDesc);
159 }
160
161 void ARMAttributeParser::THUMB_ISA_use(AttrType Tag, const uint8_t *Data,
162 uint32_t &Offset) {
163 static const char *Strings[] = { "Not Permitted", "Thumb-1", "Thumb-2" };
164
165 uint64_t Value = ParseInteger(Data, Offset);
166 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
167 PrintAttribute(Tag, Value, ValueDesc);
168 }
169
170 void ARMAttributeParser::FP_arch(AttrType Tag, const uint8_t *Data,
171 uint32_t &Offset) {
172 static const char *Strings[] = {
173 "Not Permitted", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16", "VFPv4",
174 "VFPv4-D16", "ARMv8-a FP", "ARMv8-a FP-D16"
175 };
176
177 uint64_t Value = ParseInteger(Data, Offset);
178 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
179 PrintAttribute(Tag, Value, ValueDesc);
180 }
181
182 void ARMAttributeParser::WMMX_arch(AttrType Tag, const uint8_t *Data,
183 uint32_t &Offset) {
184 static const char *Strings[] = { "Not Permitted", "WMMXv1", "WMMXv2" };
185
186 uint64_t Value = ParseInteger(Data, Offset);
187 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
188 PrintAttribute(Tag, Value, ValueDesc);
189 }
190
191 void ARMAttributeParser::Advanced_SIMD_arch(AttrType Tag, const uint8_t *Data,
192 uint32_t &Offset) {
193 static const char *Strings[] = {
194 "Not Permitted", "NEONv1", "NEONv2+FMA", "ARMv8-a NEON"
195 };
196
197 uint64_t Value = ParseInteger(Data, Offset);
198 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
199 PrintAttribute(Tag, Value, ValueDesc);
200 }
201
202 void ARMAttributeParser::PCS_config(AttrType Tag, const uint8_t *Data,
203 uint32_t &Offset) {
204 static const char *Strings[] = {
205 "None", "Bare Platform", "Linux Application", "Linux DSO", "Palm OS 2004",
206 "Reserved (Palm OS)", "Symbian OS 2004", "Reserved (Symbian OS)"
207 };
208
209 uint64_t Value = ParseInteger(Data, Offset);
210 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
211 PrintAttribute(Tag, Value, ValueDesc);
212 }
213
214 void ARMAttributeParser::ABI_PCS_R9_use(AttrType Tag, const uint8_t *Data,
215 uint32_t &Offset) {
216 static const char *Strings[] = { "v6", "Static Base", "TLS", "Unused" };
217
218 uint64_t Value = ParseInteger(Data, Offset);
219 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
220 PrintAttribute(Tag, Value, ValueDesc);
221 }
222
223 void ARMAttributeParser::ABI_PCS_RW_data(AttrType Tag, const uint8_t *Data,
224 uint32_t &Offset) {
225 static const char *Strings[] = {
226 "Absolute", "PC-relative", "SB-relative", "Not Permitted"
227 };
228
229 uint64_t Value = ParseInteger(Data, Offset);
230 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
231 PrintAttribute(Tag, Value, ValueDesc);
232 }
233
234 void ARMAttributeParser::ABI_PCS_RO_data(AttrType Tag, const uint8_t *Data,
235 uint32_t &Offset) {
236 static const char *Strings[] = { "Absolute", "PC-relative", "Not Permitted" };
237
238 uint64_t Value = ParseInteger(Data, Offset);
239 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
240 PrintAttribute(Tag, Value, ValueDesc);
241 }
242
243 void ARMAttributeParser::ABI_PCS_GOT_use(AttrType Tag, const uint8_t *Data,
244 uint32_t &Offset) {
245 static const char *Strings[] = { "Not Permitted", "Direct", "GOT-Indirect" };
246
247 uint64_t Value = ParseInteger(Data, Offset);
248 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
249 PrintAttribute(Tag, Value, ValueDesc);
250 }
251
252 void ARMAttributeParser::ABI_PCS_wchar_t(AttrType Tag, const uint8_t *Data,
253 uint32_t &Offset) {
254 static const char *Strings[] = {
255 "Not Permitted", "Unknown", "2-byte", "Unknown", "4-byte"
256 };
257
258 uint64_t Value = ParseInteger(Data, Offset);
259 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
260 PrintAttribute(Tag, Value, ValueDesc);
261 }
262
263 void ARMAttributeParser::ABI_FP_rounding(AttrType Tag, const uint8_t *Data,
264 uint32_t &Offset) {
265 static const char *Strings[] = { "IEEE-754", "Runtime" };
266
267 uint64_t Value = ParseInteger(Data, Offset);
268 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
269 PrintAttribute(Tag, Value, ValueDesc);
270 }
271
272 void ARMAttributeParser::ABI_FP_denormal(AttrType Tag, const uint8_t *Data,
273 uint32_t &Offset) {
274 static const char *Strings[] = { "Unsupported", "IEEE-754", "Sign Only" };
275
276 uint64_t Value = ParseInteger(Data, Offset);
277 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
278 PrintAttribute(Tag, Value, ValueDesc);
279 }
280
281 void ARMAttributeParser::ABI_FP_exceptions(AttrType Tag, const uint8_t *Data,
282 uint32_t &Offset) {
283 static const char *Strings[] = { "Not Permitted", "IEEE-754" };
284
285 uint64_t Value = ParseInteger(Data, Offset);
286 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
287 PrintAttribute(Tag, Value, ValueDesc);
288 }
289
290 void ARMAttributeParser::ABI_FP_user_exceptions(AttrType Tag,
291 const uint8_t *Data,
292 uint32_t &Offset) {
293 static const char *Strings[] = { "Not Permitted", "IEEE-754" };
294
295 uint64_t Value = ParseInteger(Data, Offset);
296 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
297 PrintAttribute(Tag, Value, ValueDesc);
298 }
299
300 void ARMAttributeParser::ABI_FP_number_model(AttrType Tag, const uint8_t *Data,
301 uint32_t &Offset) {
302 static const char *Strings[] = {
303 "Not Permitted", "Finite Only", "RTABI", "IEEE-754"
304 };
305
306 uint64_t Value = ParseInteger(Data, Offset);
307 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
308 PrintAttribute(Tag, Value, ValueDesc);
309 }
310
311 void ARMAttributeParser::ABI_align_needed(AttrType Tag, const uint8_t *Data,
312 uint32_t &Offset) {
313 static const char *Strings[] = {
314 "Not Permitted", "8-byte alignment", "4-byte alignment", "Reserved"
315 };
316
317 uint64_t Value = ParseInteger(Data, Offset);
318
319 Twine Description;
320 if (Value < countof(Strings))
321 Description = StringRef(Strings[Value]);
322 else if (Value <= 12)
323 Description = Twine("8-byte alignment, ") + utostr(exp2(Value))
324 + Twine("-byte extended alignment");
325 else
326 Description = "Invalid";
327
328 PrintAttribute(Tag, Value, Description.str());
329 }
330
331 void ARMAttributeParser::ABI_align_preserved(AttrType Tag, const uint8_t *Data,
332 uint32_t &Offset) {
333 static const char *Strings[] = {
334 "Not Required", "8-byte data alignment", "8-byte data and code alignment",
335 "Reserved"
336 };
337
338 uint64_t Value = ParseInteger(Data, Offset);
339
340 Twine Description;
341 if (Value < countof(Strings))
342 Description = StringRef(Strings[Value]);
343 else if (Value <= 12)
344 Description = Twine("8-byte stack alignment, ") + utostr(exp2(Value))
345 + Twine("-byte data alignment");
346 else
347 Description = "Invalid";
348
349 PrintAttribute(Tag, Value, Description.str());
350 }
351
352 void ARMAttributeParser::ABI_enum_size(AttrType Tag, const uint8_t *Data,
353 uint32_t &Offset) {
354 static const char *Strings[] = {
355 "Not Permitted", "Packed", "Int32", "External Int32"
356 };
357
358 uint64_t Value = ParseInteger(Data, Offset);
359 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
360 PrintAttribute(Tag, Value, ValueDesc);
361 }
362
363 void ARMAttributeParser::ABI_HardFP_use(AttrType Tag, const uint8_t *Data,
364 uint32_t &Offset) {
365 static const char *Strings[] = {
366 "Tag_FP_arch", "Single-Precision", "Reserved", "Tag_FP_arch (deprecated)"
367 };
368
369 uint64_t Value = ParseInteger(Data, Offset);
370 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
371 PrintAttribute(Tag, Value, ValueDesc);
372 }
373
374 void ARMAttributeParser::ABI_VFP_args(AttrType Tag, const uint8_t *Data,
375 uint32_t &Offset) {
376 static const char *Strings[] = {
377 "AAPCS", "AAPCS VFP", "Custom", "Not Permitted"
378 };
379
380 uint64_t Value = ParseInteger(Data, Offset);
381 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
382 PrintAttribute(Tag, Value, ValueDesc);
383 }
384
385 void ARMAttributeParser::ABI_WMMX_args(AttrType Tag, const uint8_t *Data,
386 uint32_t &Offset) {
387 static const char *Strings[] = { "AAPCS", "iWMMX", "Custom" };
388
389 uint64_t Value = ParseInteger(Data, Offset);
390 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
391 PrintAttribute(Tag, Value, ValueDesc);
392 }
393
394 void ARMAttributeParser::ABI_optimization_goals(AttrType Tag,
395 const uint8_t *Data,
396 uint32_t &Offset) {
397 static const char *Strings[] = {
398 "None", "Speed", "Aggressive Speed", "Size", "Aggressive Size", "Debugging",
399 "Best Debugging"
400 };
401
402 uint64_t Value = ParseInteger(Data, Offset);
403 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
404 PrintAttribute(Tag, Value, ValueDesc);
405 }
406
407 void ARMAttributeParser::ABI_FP_optimization_goals(AttrType Tag,
408 const uint8_t *Data,
409 uint32_t &Offset) {
410 static const char *Strings[] = {
411 "None", "Speed", "Aggressive Speed", "Size", "Aggressive Size", "Accuracy",
412 "Best Accuracy"
413 };
414
415 uint64_t Value = ParseInteger(Data, Offset);
416 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
417 PrintAttribute(Tag, Value, ValueDesc);
418 }
419
420 void ARMAttributeParser::compatibility(AttrType Tag, const uint8_t *Data,
421 uint32_t &Offset) {
422 uint64_t Integer = ParseInteger(Data, Offset);
423 StringRef String = ParseString(Data, Offset);
424
425 DictScope AS(SW, "Attribute");
426 SW.printNumber("Tag", Tag);
427 SW.startLine() << "Value: " << Integer << ", " << String << '\n';
428 SW.printString("TagName", AttrTypeAsString(Tag, /*TagPrefix*/false));
429 switch (Integer) {
430 case 0:
431 SW.printString("Description", StringRef("No Specific Requirements"));
432 break;
433 case 1:
434 SW.printString("Description", StringRef("AEABI Conformant"));
435 break;
436 default:
437 SW.printString("Description", StringRef("AEABI Non-Conformant"));
438 break;
439 }
440 }
441
442 void ARMAttributeParser::CPU_unaligned_access(AttrType Tag, const uint8_t *Data,
443 uint32_t &Offset) {
444 static const char *Strings[] = { "Not Permitted", "v6-style" };
445
446 uint64_t Value = ParseInteger(Data, Offset);
447 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
448 PrintAttribute(Tag, Value, ValueDesc);
449 }
450
451 void ARMAttributeParser::FP_HP_extension(AttrType Tag, const uint8_t *Data,
452 uint32_t &Offset) {
453 static const char *Strings[] = { "If Available", "Permitted" };
454
455 uint64_t Value = ParseInteger(Data, Offset);
456 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
457 PrintAttribute(Tag, Value, ValueDesc);
458 }
459
460 void ARMAttributeParser::ABI_FP_16bit_format(AttrType Tag, const uint8_t *Data,
461 uint32_t &Offset) {
462 static const char *Strings[] = { "Not Permitted", "IEEE-754", "VFPv3" };
463
464 uint64_t Value = ParseInteger(Data, Offset);
465 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
466 PrintAttribute(Tag, Value, ValueDesc);
467 }
468
469 void ARMAttributeParser::MPextension_use(AttrType Tag, const uint8_t *Data,
470 uint32_t &Offset) {
471 static const char *Strings[] = { "Not Permitted", "Permitted" };
472
473 uint64_t Value = ParseInteger(Data, Offset);
474 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
475 PrintAttribute(Tag, Value, ValueDesc);
476 }
477
478 void ARMAttributeParser::DIV_use(AttrType Tag, const uint8_t *Data,
479 uint32_t &Offset) {
480 static const char *Strings[] = {
481 "If Available", "Not Permitted", "Permitted"
482 };
483
484 uint64_t Value = ParseInteger(Data, Offset);
485 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
486 PrintAttribute(Tag, Value, ValueDesc);
487 }
488
489 void ARMAttributeParser::T2EE_use(AttrType Tag, const uint8_t *Data,
490 uint32_t &Offset) {
491 static const char *Strings[] = { "Not Permitted", "Permitted" };
492
493 uint64_t Value = ParseInteger(Data, Offset);
494 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
495 PrintAttribute(Tag, Value, ValueDesc);
496 }
497
498 void ARMAttributeParser::Virtualization_use(AttrType Tag, const uint8_t *Data,
499 uint32_t &Offset) {
500 static const char *Strings[] = {
501 "Not Permitted", "TrustZone", "Virtualization Extensions",
502 "TrustZone + Virtualization Extensions"
503 };
504
505 uint64_t Value = ParseInteger(Data, Offset);
506 StringRef ValueDesc = (Value < countof(Strings)) ? Strings[Value] : NULL;
507 PrintAttribute(Tag, Value, ValueDesc);
508 }
509
510 void ARMAttributeParser::nodefaults(AttrType Tag, const uint8_t *Data,
511 uint32_t &Offset) {
512 uint64_t Value = ParseInteger(Data, Offset);
513 PrintAttribute(Tag, Value, "Unspecified Tags UNDEFINED");
514 }
515
516 void ARMAttributeParser::ParseIndexList(const uint8_t *Data, uint32_t &Offset,
517 SmallVectorImpl &IndexList) {
518 for (;;) {
519 unsigned Length;
520 uint64_t Value = decodeULEB128(Data + Offset, &Length);
521 Offset = Offset + Length;
522 if (Value == 0)
523 break;
524 IndexList.push_back(Value);
525 }
526 }
527
528 void ARMAttributeParser::ParseAttributeList(const uint8_t *Data,
529 uint32_t &Offset, uint32_t Length) {
530 while (Offset < Length) {
531 unsigned Length;
532 uint64_t Tag = decodeULEB128(Data + Offset, &Length);
533 Offset += Length;
534
535 bool Handled = false;
536 for (unsigned AHI = 0, AHE = countof(DisplayRoutines);
537 AHI != AHE && !Handled; ++AHI) {
538 if (DisplayRoutines[AHI].Attribute == Tag) {
539 (this->*DisplayRoutines[AHI].Routine)(ARMBuildAttrs::AttrType(Tag),
540 Data, Offset);
541 Handled = true;
542 break;
543 }
544 }
545 if (!Handled) {
546 if (Tag < 32) {
547 errs() << "unhandled AEABI Tag " << Tag
548 << " (" << ARMBuildAttrs::AttrTypeAsString(Tag) << ")\n";
549 continue;
550 }
551
552 if (Tag % 2 == 0)
553 IntegerAttribute(ARMBuildAttrs::AttrType(Tag), Data, Offset);
554 else
555 StringAttribute(ARMBuildAttrs::AttrType(Tag), Data, Offset);
556 }
557 }
558 }
559
560 void ARMAttributeParser::ParseSubsection(const uint8_t *Data, uint32_t Length) {
561 uint32_t Offset = sizeof(uint32_t); /* SectionLength */
562
563 SW.printNumber("SectionLength", Length);
564
565 const char *VendorName = reinterpret_cast(Data + Offset);
566 size_t VendorNameLength = std::strlen(VendorName);
567 SW.printString("Vendor", StringRef(VendorName, VendorNameLength));
568 Offset = Offset + VendorNameLength + 1;
569
570 if (StringRef(VendorName, VendorNameLength).lower() != "aeabi")
571 return;
572
573 while (Offset < Length) {
574 /// Tag_File | Tag_Section | Tag_Symbol uleb128:byte-size
575 uint8_t Tag = Data[Offset];
576 SW.printEnum("Tag", Tag, makeArrayRef(TagNames));
577 Offset = Offset + sizeof(Tag);
578
579 uint32_t Size =
580 *reinterpret_cast(Data + Offset);
581 SW.printNumber("Size", Size);
582 Offset = Offset + sizeof(Size);
583
584 if (Size > Length) {
585 errs() << "subsection length greater than section length\n";
586 return;
587 }
588
589 StringRef ScopeName, IndexName;
590 SmallVector Indicies;
591 switch (Tag) {
592 case ARMBuildAttrs::File:
593 ScopeName = "FileAttributes";
594 break;
595 case ARMBuildAttrs::Section:
596 ScopeName = "SectionAttributes";
597 IndexName = "Sections";
598 ParseIndexList(Data, Offset, Indicies);
599 break;
600 case ARMBuildAttrs::Symbol:
601 ScopeName = "SymbolAttributes";
602 IndexName = "Symbols";
603 ParseIndexList(Data, Offset, Indicies);
604 break;
605 default:
606 errs() << "unrecognised tag: 0x" << utohexstr(Tag) << '\n';
607 return;
608 }
609
610 DictScope ASS(SW, ScopeName);
611
612 if (!Indicies.empty())
613 SW.printList(IndexName, Indicies);
614
615 ParseAttributeList(Data, Offset, Length);
616 }
617 }
618
619 void ARMAttributeParser::Parse(ArrayRef Section) {
620 size_t Offset = 1;
621 unsigned SectionNumber = 0;
622
623 while (Offset < Section.size()) {
624 uint32_t SectionLength =
625 *reinterpret_cast(Section.data() + Offset);
626
627 SW.startLine() << "Section " << ++SectionNumber << " {\n";
628 SW.indent();
629
630 ParseSubsection(Section.data() + Offset, SectionLength);
631 Offset = Offset + SectionLength;
632
633 SW.unindent();
634 SW.startLine() << "}\n";
635 }
636 }
637 }
638
0 //===--- ARMAttributeParser.h - ARM Attribute Information Printer ---------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_READOBJ_ARMATTRIBUTE_PARSER_H
10 #define LLVM_READOBJ_ARMATTRIBUTE_PARSER_H
11
12 #include "StreamWriter.h"
13 #include "llvm/Support/ARMBuildAttributes.h"
14
15 namespace llvm {
16 class StringRef;
17
18 class ARMAttributeParser {
19 StreamWriter &SW;
20
21 struct DisplayHandler {
22 ARMBuildAttrs::AttrType Attribute;
23 void (ARMAttributeParser::*Routine)(ARMBuildAttrs::AttrType,
24 const uint8_t *, uint32_t &);
25 };
26 static const DisplayHandler DisplayRoutines[];
27
28 uint64_t ParseInteger(const uint8_t *Data, uint32_t &Offset);
29 StringRef ParseString(const uint8_t *Data, uint32_t &Offset);
30
31 void IntegerAttribute(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
32 uint32_t &Offset);
33 void StringAttribute(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
34 uint32_t &Offset);
35
36 void PrintAttribute(unsigned Tag, unsigned Value, StringRef ValueDesc);
37
38 void CPU_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
39 uint32_t &Offset);
40 void CPU_arch_profile(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
41 uint32_t &Offset);
42 void ARM_ISA_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
43 uint32_t &Offset);
44 void THUMB_ISA_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
45 uint32_t &Offset);
46 void FP_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
47 uint32_t &Offset);
48 void WMMX_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
49 uint32_t &Offset);
50 void Advanced_SIMD_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
51 uint32_t &Offset);
52 void PCS_config(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
53 uint32_t &Offset);
54 void ABI_PCS_R9_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
55 uint32_t &Offset);
56 void ABI_PCS_RW_data(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
57 uint32_t &Offset);
58 void ABI_PCS_RO_data(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
59 uint32_t &Offset);
60 void ABI_PCS_GOT_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
61 uint32_t &Offset);
62 void ABI_PCS_wchar_t(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
63 uint32_t &Offset);
64 void ABI_FP_rounding(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
65 uint32_t &Offset);
66 void ABI_FP_denormal(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
67 uint32_t &Offset);
68 void ABI_FP_exceptions(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
69 uint32_t &Offset);
70 void ABI_FP_user_exceptions(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
71 uint32_t &Offset);
72 void ABI_FP_number_model(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
73 uint32_t &Offset);
74 void ABI_align_needed(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
75 uint32_t &Offset);
76 void ABI_align_preserved(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
77 uint32_t &Offset);
78 void ABI_enum_size(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
79 uint32_t &Offset);
80 void ABI_HardFP_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
81 uint32_t &Offset);
82 void ABI_VFP_args(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
83 uint32_t &Offset);
84 void ABI_WMMX_args(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
85 uint32_t &Offset);
86 void ABI_optimization_goals(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
87 uint32_t &Offset);
88 void ABI_FP_optimization_goals(ARMBuildAttrs::AttrType Tag,
89 const uint8_t *Data, uint32_t &Offset);
90 void compatibility(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
91 uint32_t &Offset);
92 void CPU_unaligned_access(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
93 uint32_t &Offset);
94 void FP_HP_extension(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
95 uint32_t &Offset);
96 void ABI_FP_16bit_format(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
97 uint32_t &Offset);
98 void MPextension_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
99 uint32_t &Offset);
100 void DIV_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
101 uint32_t &Offset);
102 void T2EE_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
103 uint32_t &Offset);
104 void Virtualization_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
105 uint32_t &Offset);
106 void nodefaults(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
107 uint32_t &Offset);
108
109 void ParseAttributeList(const uint8_t *Data, uint32_t &Offset,
110 uint32_t Length);
111 void ParseIndexList(const uint8_t *Data, uint32_t &Offset,
112 SmallVectorImpl &IndexList);
113 void ParseSubsection(const uint8_t *Data, uint32_t Length);
114 public:
115 ARMAttributeParser(StreamWriter &SW) : SW(SW) {}
116
117 void Parse(ArrayRef Section);
118 };
119
120 }
121
122 #endif
123
1111 MachODumper.cpp
1212 Error.cpp
1313 StreamWriter.cpp
14 ARMAttributeParser.cpp
1415 )
1212 //===----------------------------------------------------------------------===//
1313
1414 #include "llvm-readobj.h"
15 #include "ARMAttributeParser.h"
1516 #include "ARMEHABIPrinter.h"
1617 #include "Error.h"
1718 #include "ObjDumper.h"
1819 #include "StreamWriter.h"
1920 #include "llvm/ADT/SmallString.h"
21 #include "llvm/ADT/StringExtras.h"
2022 #include "llvm/Object/ELFObjectFile.h"
23 #include "llvm/Support/ARMBuildAttributes.h"
2124 #include "llvm/Support/Compiler.h"
2225 #include "llvm/Support/Format.h"
2326 #include "llvm/Support/MathExtras.h"
4851 virtual void printDynamicTable() LLVM_OVERRIDE;
4952 virtual void printNeededLibraries() LLVM_OVERRIDE;
5053 virtual void printProgramHeaders() LLVM_OVERRIDE;
54
55 virtual void printAttributes() LLVM_OVERRIDE;
5156
5257 private:
5358 typedef ELFFile ELFO;
854859 W.printNumber("Alignment", PI->p_align);
855860 }
856861 }
862
863 template
864 void ELFDumper::printAttributes() {
865 W.startLine() << "Attributes not implemented.\n";
866 }
867
868 namespace {
869 template <>
870 void ELFDumper >::printAttributes() {
871 if (Obj->getHeader()->e_machine != EM_ARM) {
872 W.startLine() << "Attributes not implemented.\n";
873 return;
874 }
875
876 DictScope BA(W, "BuildAttributes");
877 for (typename ELFO::Elf_Shdr_Iter SI = Obj->begin_sections(),
878 SE = Obj->end_sections(); SI != SE; ++SI) {
879 if (SI->sh_type != ELF::SHT_ARM_ATTRIBUTES)
880 continue;
881
882 ErrorOr > Contents = Obj->getSectionContents(&(*SI));
883 if (!Contents)
884 continue;
885
886 if ((*Contents)[0] != ARMBuildAttrs::Format_Version) {
887 errs() << "unrecognised FormatVersion: 0x" << utohexstr((*Contents)[0])
888 << '\n';
889 continue;
890 }
891
892 W.printHex("FormatVersion", (*Contents)[0]);
893 if (Contents->size() == 1)
894 continue;
895
896 ARMAttributeParser(W).Parse(*Contents);
897 }
898 }
899 }
900
3939 virtual void printNeededLibraries() { }
4040 virtual void printProgramHeaders() { }
4141
42 // Only implemented for ARM ELF at this time.
43 virtual void printAttributes() { }
44
4245 protected:
4346 StreamWriter& W;
4447 };
171171 startLine() << Label << ": " << int(Value) << "\n";
172172 }
173173
174 template
175 void printList(StringRef Label, const SmallVectorImpl &List) {
176 startLine() << Label << ": [";
177 bool Comma = false;
178 for (unsigned LI = 0, LE = List.size(); LI != LE; ++LI) {
179 if (Comma)
180 OS << ", ";
181 OS << List[LI];
182 Comma = true;
183 }
184 OS << "]\n";
185 }
186
174187 template
175188 void printHex(StringRef Label, T Value) {
176189 startLine() << Label << ": " << hex(Value) << "\n";
128128 // -codeview-linetables
129129 cl::opt CodeViewLineTables("codeview-linetables",
130130 cl::desc("Display CodeView line table information"));
131
132 // -arm-attributes, -a
133 cl::opt ARMAttributes("arm-attributes",
134 cl::desc("Display the ARM attributes section"));
135 cl::alias ARMAttributesShort("-a", cl::desc("Alias for --arm-attributes"),
136 cl::aliasopt(ARMAttributes));
131137 } // namespace opts
132138
133139 static int ReturnValue = EXIT_SUCCESS;
226232 Dumper->printNeededLibraries();
227233 if (opts::ProgramHeaders)
228234 Dumper->printProgramHeaders();
235 if (Obj->getArch() == llvm::Triple::arm && Obj->isELF())
236 if (opts::ARMAttributes)
237 Dumper->printAttributes();
229238 }
230239
231240
3838 extern llvm::cl::opt UnwindInfo;
3939 extern llvm::cl::opt ExpandRelocs;
4040 extern llvm::cl::opt CodeViewLineTables;
41 extern llvm::cl::opt ARMAttributes;
4142 } // namespace opts
4243
4344 #define LLVM_READOBJ_ENUM_ENT(ns, enum) \