1 //===--- ARMAttributeParser.cpp - ARM Attribute Information Printer -------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Support/ARMAttributeParser.h"
11 #include "llvm/ADT/STLExtras.h"
12 #include "llvm/ADT/StringExtras.h"
13 #include "llvm/Support/LEB128.h"
14 #include "llvm/Support/ScopedPrinter.h"
17 using namespace llvm::ARMBuildAttrs
;
20 static const EnumEntry
<unsigned> TagNames
[] = {
21 { "Tag_File", ARMBuildAttrs::File
},
22 { "Tag_Section", ARMBuildAttrs::Section
},
23 { "Tag_Symbol", ARMBuildAttrs::Symbol
},
27 #define ATTRIBUTE_HANDLER(Attr_) \
28 { ARMBuildAttrs::Attr_, &ARMAttributeParser::Attr_ }
30 const ARMAttributeParser::DisplayHandler
31 ARMAttributeParser::DisplayRoutines
[] = {
32 { ARMBuildAttrs::CPU_raw_name
, &ARMAttributeParser::StringAttribute
, },
33 { ARMBuildAttrs::CPU_name
, &ARMAttributeParser::StringAttribute
},
34 ATTRIBUTE_HANDLER(CPU_arch
),
35 ATTRIBUTE_HANDLER(CPU_arch_profile
),
36 ATTRIBUTE_HANDLER(ARM_ISA_use
),
37 ATTRIBUTE_HANDLER(THUMB_ISA_use
),
38 ATTRIBUTE_HANDLER(FP_arch
),
39 ATTRIBUTE_HANDLER(WMMX_arch
),
40 ATTRIBUTE_HANDLER(Advanced_SIMD_arch
),
41 ATTRIBUTE_HANDLER(PCS_config
),
42 ATTRIBUTE_HANDLER(ABI_PCS_R9_use
),
43 ATTRIBUTE_HANDLER(ABI_PCS_RW_data
),
44 ATTRIBUTE_HANDLER(ABI_PCS_RO_data
),
45 ATTRIBUTE_HANDLER(ABI_PCS_GOT_use
),
46 ATTRIBUTE_HANDLER(ABI_PCS_wchar_t
),
47 ATTRIBUTE_HANDLER(ABI_FP_rounding
),
48 ATTRIBUTE_HANDLER(ABI_FP_denormal
),
49 ATTRIBUTE_HANDLER(ABI_FP_exceptions
),
50 ATTRIBUTE_HANDLER(ABI_FP_user_exceptions
),
51 ATTRIBUTE_HANDLER(ABI_FP_number_model
),
52 ATTRIBUTE_HANDLER(ABI_align_needed
),
53 ATTRIBUTE_HANDLER(ABI_align_preserved
),
54 ATTRIBUTE_HANDLER(ABI_enum_size
),
55 ATTRIBUTE_HANDLER(ABI_HardFP_use
),
56 ATTRIBUTE_HANDLER(ABI_VFP_args
),
57 ATTRIBUTE_HANDLER(ABI_WMMX_args
),
58 ATTRIBUTE_HANDLER(ABI_optimization_goals
),
59 ATTRIBUTE_HANDLER(ABI_FP_optimization_goals
),
60 ATTRIBUTE_HANDLER(compatibility
),
61 ATTRIBUTE_HANDLER(CPU_unaligned_access
),
62 ATTRIBUTE_HANDLER(FP_HP_extension
),
63 ATTRIBUTE_HANDLER(ABI_FP_16bit_format
),
64 ATTRIBUTE_HANDLER(MPextension_use
),
65 ATTRIBUTE_HANDLER(DIV_use
),
66 ATTRIBUTE_HANDLER(DSP_extension
),
67 ATTRIBUTE_HANDLER(T2EE_use
),
68 ATTRIBUTE_HANDLER(Virtualization_use
),
69 ATTRIBUTE_HANDLER(nodefaults
)
72 #undef ATTRIBUTE_HANDLER
74 uint64_t ARMAttributeParser::ParseInteger(const uint8_t *Data
,
77 uint64_t Value
= decodeULEB128(Data
+ Offset
, &Length
);
78 Offset
= Offset
+ Length
;
82 StringRef
ARMAttributeParser::ParseString(const uint8_t *Data
,
84 const char *String
= reinterpret_cast<const char*>(Data
+ Offset
);
85 size_t Length
= std::strlen(String
);
86 Offset
= Offset
+ Length
+ 1;
87 return StringRef(String
, Length
);
90 void ARMAttributeParser::IntegerAttribute(AttrType Tag
, const uint8_t *Data
,
93 uint64_t Value
= ParseInteger(Data
, Offset
);
94 Attributes
.insert(std::make_pair(Tag
, Value
));
97 SW
->printNumber(ARMBuildAttrs::AttrTypeAsString(Tag
), Value
);
100 void ARMAttributeParser::StringAttribute(AttrType Tag
, const uint8_t *Data
,
102 StringRef TagName
= ARMBuildAttrs::AttrTypeAsString(Tag
, /*TagPrefix*/false);
103 StringRef ValueDesc
= ParseString(Data
, Offset
);
106 DictScope
AS(*SW
, "Attribute");
107 SW
->printNumber("Tag", Tag
);
108 if (!TagName
.empty())
109 SW
->printString("TagName", TagName
);
110 SW
->printString("Value", ValueDesc
);
114 void ARMAttributeParser::PrintAttribute(unsigned Tag
, unsigned Value
,
115 StringRef ValueDesc
) {
116 Attributes
.insert(std::make_pair(Tag
, Value
));
119 StringRef TagName
= ARMBuildAttrs::AttrTypeAsString(Tag
,
121 DictScope
AS(*SW
, "Attribute");
122 SW
->printNumber("Tag", Tag
);
123 SW
->printNumber("Value", Value
);
124 if (!TagName
.empty())
125 SW
->printString("TagName", TagName
);
126 if (!ValueDesc
.empty())
127 SW
->printString("Description", ValueDesc
);
131 void ARMAttributeParser::CPU_arch(AttrType Tag
, const uint8_t *Data
,
133 static const char *const Strings
[] = {
134 "Pre-v4", "ARM v4", "ARM v4T", "ARM v5T", "ARM v5TE", "ARM v5TEJ", "ARM v6",
135 "ARM v6KZ", "ARM v6T2", "ARM v6K", "ARM v7", "ARM v6-M", "ARM v6S-M",
136 "ARM v7E-M", "ARM v8"
139 uint64_t Value
= ParseInteger(Data
, Offset
);
140 StringRef ValueDesc
=
141 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
142 PrintAttribute(Tag
, Value
, ValueDesc
);
145 void ARMAttributeParser::CPU_arch_profile(AttrType Tag
, const uint8_t *Data
,
147 uint64_t Encoded
= ParseInteger(Data
, Offset
);
151 default: Profile
= "Unknown"; break;
152 case 'A': Profile
= "Application"; break;
153 case 'R': Profile
= "Real-time"; break;
154 case 'M': Profile
= "Microcontroller"; break;
155 case 'S': Profile
= "Classic"; break;
156 case 0: Profile
= "None"; break;
159 PrintAttribute(Tag
, Encoded
, Profile
);
162 void ARMAttributeParser::ARM_ISA_use(AttrType Tag
, const uint8_t *Data
,
164 static const char *const Strings
[] = { "Not Permitted", "Permitted" };
166 uint64_t Value
= ParseInteger(Data
, Offset
);
167 StringRef ValueDesc
=
168 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
169 PrintAttribute(Tag
, Value
, ValueDesc
);
172 void ARMAttributeParser::THUMB_ISA_use(AttrType Tag
, const uint8_t *Data
,
174 static const char *const Strings
[] = { "Not Permitted", "Thumb-1", "Thumb-2" };
176 uint64_t Value
= ParseInteger(Data
, Offset
);
177 StringRef ValueDesc
=
178 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
179 PrintAttribute(Tag
, Value
, ValueDesc
);
182 void ARMAttributeParser::FP_arch(AttrType Tag
, const uint8_t *Data
,
184 static const char *const Strings
[] = {
185 "Not Permitted", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16", "VFPv4",
186 "VFPv4-D16", "ARMv8-a FP", "ARMv8-a FP-D16"
189 uint64_t Value
= ParseInteger(Data
, Offset
);
190 StringRef ValueDesc
=
191 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
192 PrintAttribute(Tag
, Value
, ValueDesc
);
195 void ARMAttributeParser::WMMX_arch(AttrType Tag
, const uint8_t *Data
,
197 static const char *const Strings
[] = { "Not Permitted", "WMMXv1", "WMMXv2" };
199 uint64_t Value
= ParseInteger(Data
, Offset
);
200 StringRef ValueDesc
=
201 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
202 PrintAttribute(Tag
, Value
, ValueDesc
);
205 void ARMAttributeParser::Advanced_SIMD_arch(AttrType Tag
, const uint8_t *Data
,
207 static const char *const Strings
[] = {
208 "Not Permitted", "NEONv1", "NEONv2+FMA", "ARMv8-a NEON", "ARMv8.1-a NEON"
211 uint64_t Value
= ParseInteger(Data
, Offset
);
212 StringRef ValueDesc
=
213 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
214 PrintAttribute(Tag
, Value
, ValueDesc
);
217 void ARMAttributeParser::PCS_config(AttrType Tag
, const uint8_t *Data
,
219 static const char *const Strings
[] = {
220 "None", "Bare Platform", "Linux Application", "Linux DSO", "Palm OS 2004",
221 "Reserved (Palm OS)", "Symbian OS 2004", "Reserved (Symbian OS)"
224 uint64_t Value
= ParseInteger(Data
, Offset
);
225 StringRef ValueDesc
=
226 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
227 PrintAttribute(Tag
, Value
, ValueDesc
);
230 void ARMAttributeParser::ABI_PCS_R9_use(AttrType Tag
, const uint8_t *Data
,
232 static const char *const Strings
[] = { "v6", "Static Base", "TLS", "Unused" };
234 uint64_t Value
= ParseInteger(Data
, Offset
);
235 StringRef ValueDesc
=
236 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
237 PrintAttribute(Tag
, Value
, ValueDesc
);
240 void ARMAttributeParser::ABI_PCS_RW_data(AttrType Tag
, const uint8_t *Data
,
242 static const char *const Strings
[] = {
243 "Absolute", "PC-relative", "SB-relative", "Not Permitted"
246 uint64_t Value
= ParseInteger(Data
, Offset
);
247 StringRef ValueDesc
=
248 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
249 PrintAttribute(Tag
, Value
, ValueDesc
);
252 void ARMAttributeParser::ABI_PCS_RO_data(AttrType Tag
, const uint8_t *Data
,
254 static const char *const Strings
[] = {
255 "Absolute", "PC-relative", "Not Permitted"
258 uint64_t Value
= ParseInteger(Data
, Offset
);
259 StringRef ValueDesc
=
260 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
261 PrintAttribute(Tag
, Value
, ValueDesc
);
264 void ARMAttributeParser::ABI_PCS_GOT_use(AttrType Tag
, const uint8_t *Data
,
266 static const char *const Strings
[] = {
267 "Not Permitted", "Direct", "GOT-Indirect"
270 uint64_t Value
= ParseInteger(Data
, Offset
);
271 StringRef ValueDesc
=
272 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
273 PrintAttribute(Tag
, Value
, ValueDesc
);
276 void ARMAttributeParser::ABI_PCS_wchar_t(AttrType Tag
, const uint8_t *Data
,
278 static const char *const Strings
[] = {
279 "Not Permitted", "Unknown", "2-byte", "Unknown", "4-byte"
282 uint64_t Value
= ParseInteger(Data
, Offset
);
283 StringRef ValueDesc
=
284 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
285 PrintAttribute(Tag
, Value
, ValueDesc
);
288 void ARMAttributeParser::ABI_FP_rounding(AttrType Tag
, const uint8_t *Data
,
290 static const char *const Strings
[] = { "IEEE-754", "Runtime" };
292 uint64_t Value
= ParseInteger(Data
, Offset
);
293 StringRef ValueDesc
=
294 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
295 PrintAttribute(Tag
, Value
, ValueDesc
);
298 void ARMAttributeParser::ABI_FP_denormal(AttrType Tag
, const uint8_t *Data
,
300 static const char *const Strings
[] = {
301 "Unsupported", "IEEE-754", "Sign Only"
304 uint64_t Value
= ParseInteger(Data
, Offset
);
305 StringRef ValueDesc
=
306 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
307 PrintAttribute(Tag
, Value
, ValueDesc
);
310 void ARMAttributeParser::ABI_FP_exceptions(AttrType Tag
, const uint8_t *Data
,
312 static const char *const Strings
[] = { "Not Permitted", "IEEE-754" };
314 uint64_t Value
= ParseInteger(Data
, Offset
);
315 StringRef ValueDesc
=
316 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
317 PrintAttribute(Tag
, Value
, ValueDesc
);
320 void ARMAttributeParser::ABI_FP_user_exceptions(AttrType Tag
,
323 static const char *const Strings
[] = { "Not Permitted", "IEEE-754" };
325 uint64_t Value
= ParseInteger(Data
, Offset
);
326 StringRef ValueDesc
=
327 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
328 PrintAttribute(Tag
, Value
, ValueDesc
);
331 void ARMAttributeParser::ABI_FP_number_model(AttrType Tag
, const uint8_t *Data
,
333 static const char *const Strings
[] = {
334 "Not Permitted", "Finite Only", "RTABI", "IEEE-754"
337 uint64_t Value
= ParseInteger(Data
, Offset
);
338 StringRef ValueDesc
=
339 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
340 PrintAttribute(Tag
, Value
, ValueDesc
);
343 void ARMAttributeParser::ABI_align_needed(AttrType Tag
, const uint8_t *Data
,
345 static const char *const Strings
[] = {
346 "Not Permitted", "8-byte alignment", "4-byte alignment", "Reserved"
349 uint64_t Value
= ParseInteger(Data
, Offset
);
351 std::string Description
;
352 if (Value
< array_lengthof(Strings
))
353 Description
= std::string(Strings
[Value
]);
354 else if (Value
<= 12)
355 Description
= std::string("8-byte alignment, ") + utostr(1ULL << Value
)
356 + std::string("-byte extended alignment");
358 Description
= "Invalid";
360 PrintAttribute(Tag
, Value
, Description
);
363 void ARMAttributeParser::ABI_align_preserved(AttrType Tag
, const uint8_t *Data
,
365 static const char *const Strings
[] = {
366 "Not Required", "8-byte data alignment", "8-byte data and code alignment",
370 uint64_t Value
= ParseInteger(Data
, Offset
);
372 std::string Description
;
373 if (Value
< array_lengthof(Strings
))
374 Description
= std::string(Strings
[Value
]);
375 else if (Value
<= 12)
376 Description
= std::string("8-byte stack alignment, ") +
377 utostr(1ULL << Value
) + std::string("-byte data alignment");
379 Description
= "Invalid";
381 PrintAttribute(Tag
, Value
, Description
);
384 void ARMAttributeParser::ABI_enum_size(AttrType Tag
, const uint8_t *Data
,
386 static const char *const Strings
[] = {
387 "Not Permitted", "Packed", "Int32", "External Int32"
390 uint64_t Value
= ParseInteger(Data
, Offset
);
391 StringRef ValueDesc
=
392 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
393 PrintAttribute(Tag
, Value
, ValueDesc
);
396 void ARMAttributeParser::ABI_HardFP_use(AttrType Tag
, const uint8_t *Data
,
398 static const char *const Strings
[] = {
399 "Tag_FP_arch", "Single-Precision", "Reserved", "Tag_FP_arch (deprecated)"
402 uint64_t Value
= ParseInteger(Data
, Offset
);
403 StringRef ValueDesc
=
404 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
405 PrintAttribute(Tag
, Value
, ValueDesc
);
408 void ARMAttributeParser::ABI_VFP_args(AttrType Tag
, const uint8_t *Data
,
410 static const char *const Strings
[] = {
411 "AAPCS", "AAPCS VFP", "Custom", "Not Permitted"
414 uint64_t Value
= ParseInteger(Data
, Offset
);
415 StringRef ValueDesc
=
416 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
417 PrintAttribute(Tag
, Value
, ValueDesc
);
420 void ARMAttributeParser::ABI_WMMX_args(AttrType Tag
, const uint8_t *Data
,
422 static const char *const Strings
[] = { "AAPCS", "iWMMX", "Custom" };
424 uint64_t Value
= ParseInteger(Data
, Offset
);
425 StringRef ValueDesc
=
426 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
427 PrintAttribute(Tag
, Value
, ValueDesc
);
430 void ARMAttributeParser::ABI_optimization_goals(AttrType Tag
,
433 static const char *const Strings
[] = {
434 "None", "Speed", "Aggressive Speed", "Size", "Aggressive Size", "Debugging",
438 uint64_t Value
= ParseInteger(Data
, Offset
);
439 StringRef ValueDesc
=
440 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
441 PrintAttribute(Tag
, Value
, ValueDesc
);
444 void ARMAttributeParser::ABI_FP_optimization_goals(AttrType Tag
,
447 static const char *const Strings
[] = {
448 "None", "Speed", "Aggressive Speed", "Size", "Aggressive Size", "Accuracy",
452 uint64_t Value
= ParseInteger(Data
, Offset
);
453 StringRef ValueDesc
=
454 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
455 PrintAttribute(Tag
, Value
, ValueDesc
);
458 void ARMAttributeParser::compatibility(AttrType Tag
, const uint8_t *Data
,
460 uint64_t Integer
= ParseInteger(Data
, Offset
);
461 StringRef String
= ParseString(Data
, Offset
);
464 DictScope
AS(*SW
, "Attribute");
465 SW
->printNumber("Tag", Tag
);
466 SW
->startLine() << "Value: " << Integer
<< ", " << String
<< '\n';
467 SW
->printString("TagName", AttrTypeAsString(Tag
, /*TagPrefix*/false));
470 SW
->printString("Description", StringRef("No Specific Requirements"));
473 SW
->printString("Description", StringRef("AEABI Conformant"));
476 SW
->printString("Description", StringRef("AEABI Non-Conformant"));
482 void ARMAttributeParser::CPU_unaligned_access(AttrType Tag
, const uint8_t *Data
,
484 static const char *const Strings
[] = { "Not Permitted", "v6-style" };
486 uint64_t Value
= ParseInteger(Data
, Offset
);
487 StringRef ValueDesc
=
488 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
489 PrintAttribute(Tag
, Value
, ValueDesc
);
492 void ARMAttributeParser::FP_HP_extension(AttrType Tag
, const uint8_t *Data
,
494 static const char *const Strings
[] = { "If Available", "Permitted" };
496 uint64_t Value
= ParseInteger(Data
, Offset
);
497 StringRef ValueDesc
=
498 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
499 PrintAttribute(Tag
, Value
, ValueDesc
);
502 void ARMAttributeParser::ABI_FP_16bit_format(AttrType Tag
, const uint8_t *Data
,
504 static const char *const Strings
[] = { "Not Permitted", "IEEE-754", "VFPv3" };
506 uint64_t Value
= ParseInteger(Data
, Offset
);
507 StringRef ValueDesc
=
508 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
509 PrintAttribute(Tag
, Value
, ValueDesc
);
512 void ARMAttributeParser::MPextension_use(AttrType Tag
, const uint8_t *Data
,
514 static const char *const Strings
[] = { "Not Permitted", "Permitted" };
516 uint64_t Value
= ParseInteger(Data
, Offset
);
517 StringRef ValueDesc
=
518 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
519 PrintAttribute(Tag
, Value
, ValueDesc
);
522 void ARMAttributeParser::DIV_use(AttrType Tag
, const uint8_t *Data
,
524 static const char *const Strings
[] = {
525 "If Available", "Not Permitted", "Permitted"
528 uint64_t Value
= ParseInteger(Data
, Offset
);
529 StringRef ValueDesc
=
530 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
531 PrintAttribute(Tag
, Value
, ValueDesc
);
534 void ARMAttributeParser::DSP_extension(AttrType Tag
, const uint8_t *Data
,
536 static const char *const Strings
[] = { "Not Permitted", "Permitted" };
538 uint64_t Value
= ParseInteger(Data
, Offset
);
539 StringRef ValueDesc
=
540 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
541 PrintAttribute(Tag
, Value
, ValueDesc
);
544 void ARMAttributeParser::T2EE_use(AttrType Tag
, const uint8_t *Data
,
546 static const char *const Strings
[] = { "Not Permitted", "Permitted" };
548 uint64_t Value
= ParseInteger(Data
, Offset
);
549 StringRef ValueDesc
=
550 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
551 PrintAttribute(Tag
, Value
, ValueDesc
);
554 void ARMAttributeParser::Virtualization_use(AttrType Tag
, const uint8_t *Data
,
556 static const char *const Strings
[] = {
557 "Not Permitted", "TrustZone", "Virtualization Extensions",
558 "TrustZone + Virtualization Extensions"
561 uint64_t Value
= ParseInteger(Data
, Offset
);
562 StringRef ValueDesc
=
563 (Value
< array_lengthof(Strings
)) ? Strings
[Value
] : nullptr;
564 PrintAttribute(Tag
, Value
, ValueDesc
);
567 void ARMAttributeParser::nodefaults(AttrType Tag
, const uint8_t *Data
,
569 uint64_t Value
= ParseInteger(Data
, Offset
);
570 PrintAttribute(Tag
, Value
, "Unspecified Tags UNDEFINED");
573 void ARMAttributeParser::ParseIndexList(const uint8_t *Data
, uint32_t &Offset
,
574 SmallVectorImpl
<uint8_t> &IndexList
) {
577 uint64_t Value
= decodeULEB128(Data
+ Offset
, &Length
);
578 Offset
= Offset
+ Length
;
581 IndexList
.push_back(Value
);
585 void ARMAttributeParser::ParseAttributeList(const uint8_t *Data
,
586 uint32_t &Offset
, uint32_t Length
) {
587 while (Offset
< Length
) {
589 uint64_t Tag
= decodeULEB128(Data
+ Offset
, &Length
);
592 bool Handled
= false;
593 for (unsigned AHI
= 0, AHE
= array_lengthof(DisplayRoutines
);
594 AHI
!= AHE
&& !Handled
; ++AHI
) {
595 if (uint64_t(DisplayRoutines
[AHI
].Attribute
) == Tag
) {
596 (this->*DisplayRoutines
[AHI
].Routine
)(ARMBuildAttrs::AttrType(Tag
),
604 errs() << "unhandled AEABI Tag " << Tag
605 << " (" << ARMBuildAttrs::AttrTypeAsString(Tag
) << ")\n";
610 IntegerAttribute(ARMBuildAttrs::AttrType(Tag
), Data
, Offset
);
612 StringAttribute(ARMBuildAttrs::AttrType(Tag
), Data
, Offset
);
617 void ARMAttributeParser::ParseSubsection(const uint8_t *Data
, uint32_t Length
) {
618 uint32_t Offset
= sizeof(uint32_t); /* SectionLength */
620 const char *VendorName
= reinterpret_cast<const char*>(Data
+ Offset
);
621 size_t VendorNameLength
= std::strlen(VendorName
);
622 Offset
= Offset
+ VendorNameLength
+ 1;
625 SW
->printNumber("SectionLength", Length
);
626 SW
->printString("Vendor", StringRef(VendorName
, VendorNameLength
));
629 if (StringRef(VendorName
, VendorNameLength
).lower() != "aeabi") {
633 while (Offset
< Length
) {
634 /// Tag_File | Tag_Section | Tag_Symbol uleb128:byte-size
635 uint8_t Tag
= Data
[Offset
];
636 Offset
= Offset
+ sizeof(Tag
);
639 *reinterpret_cast<const support::ulittle32_t
*>(Data
+ Offset
);
640 Offset
= Offset
+ sizeof(Size
);
643 SW
->printEnum("Tag", Tag
, makeArrayRef(TagNames
));
644 SW
->printNumber("Size", Size
);
648 errs() << "subsection length greater than section length\n";
652 StringRef ScopeName
, IndexName
;
653 SmallVector
<uint8_t, 8> Indicies
;
655 case ARMBuildAttrs::File
:
656 ScopeName
= "FileAttributes";
658 case ARMBuildAttrs::Section
:
659 ScopeName
= "SectionAttributes";
660 IndexName
= "Sections";
661 ParseIndexList(Data
, Offset
, Indicies
);
663 case ARMBuildAttrs::Symbol
:
664 ScopeName
= "SymbolAttributes";
665 IndexName
= "Symbols";
666 ParseIndexList(Data
, Offset
, Indicies
);
669 errs() << "unrecognised tag: 0x" << Twine::utohexstr(Tag
) << '\n';
674 DictScope
ASS(*SW
, ScopeName
);
675 if (!Indicies
.empty())
676 SW
->printList(IndexName
, Indicies
);
677 ParseAttributeList(Data
, Offset
, Length
);
679 ParseAttributeList(Data
, Offset
, Length
);
684 void ARMAttributeParser::Parse(ArrayRef
<uint8_t> Section
, bool isLittle
) {
686 unsigned SectionNumber
= 0;
688 while (Offset
< Section
.size()) {
689 uint32_t SectionLength
= isLittle
?
690 support::endian::read32le(Section
.data() + Offset
) :
691 support::endian::read32be(Section
.data() + Offset
);
694 SW
->startLine() << "Section " << ++SectionNumber
<< " {\n";
698 ParseSubsection(Section
.data() + Offset
, SectionLength
);
699 Offset
= Offset
+ SectionLength
;
703 SW
->startLine() << "}\n";