27 #define ATTRIBUTE_HANDLER(Attr_) \ 28 { ARMBuildAttrs::Attr_, &ARMAttributeParser::Attr_ } 30 const ARMAttributeParser::DisplayHandler
31 ARMAttributeParser::DisplayRoutines[] = {
72 #undef ATTRIBUTE_HANDLER 74 uint64_t ARMAttributeParser::ParseInteger(
const uint8_t *
Data,
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;
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));
100 void ARMAttributeParser::StringAttribute(
AttrType Tag,
const uint8_t *Data,
103 StringRef ValueDesc = ParseString(Data, Offset);
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,
116 Attributes.insert(std::make_pair(Tag, Value));
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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;
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;
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);
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);
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);
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);
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);
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);
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);
465 SW->printNumber(
"Tag", Tag);
466 SW->startLine() <<
"Value: " << Integer <<
", " << String <<
'\n';
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);
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);
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);
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);
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);
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);
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);
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);
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,
578 Offset = Offset + Length;
585 void ARMAttributeParser::ParseAttributeList(
const uint8_t *Data,
587 while (Offset < Length) {
592 bool Handled =
false;
594 AHI != AHE && !Handled; ++AHI) {
595 if (uint64_t(DisplayRoutines[AHI].
Attribute) == Tag) {
604 errs() <<
"unhandled AEABI Tag " << Tag
617 void ARMAttributeParser::ParseSubsection(
const uint8_t *Data,
uint32_t Length) {
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) {
635 uint8_t Tag = Data[
Offset];
636 Offset = Offset +
sizeof(Tag);
640 Offset = Offset +
sizeof(
Size);
644 SW->printNumber(
"Size", Size);
648 errs() <<
"subsection length greater than section length\n";
656 ScopeName =
"FileAttributes";
659 ScopeName =
"SectionAttributes";
660 IndexName =
"Sections";
661 ParseIndexList(Data, Offset, Indicies);
664 ScopeName =
"SymbolAttributes";
665 IndexName =
"Symbols";
666 ParseIndexList(Data, Offset, Indicies);
675 if (!Indicies.
empty())
676 SW->printList(IndexName, Indicies);
677 ParseAttributeList(Data, Offset, Length);
679 ParseAttributeList(Data, Offset, Length);
686 unsigned SectionNumber = 0;
688 while (Offset < Section.
size()) {
694 SW->startLine() <<
"Section " << ++SectionNumber <<
" {\n";
698 ParseSubsection(Section.
data() +
Offset, SectionLength);
699 Offset = Offset + SectionLength;
703 SW->startLine() <<
"}\n";
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
This class represents lattice values for constants.
#define ATTRIBUTE_HANDLER(Attr_)
void push_back(const T &Elt)
uint32_t read32be(const void *P)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
StringRef AttrTypeAsString(unsigned Attr, bool HasTagPrefix=true)
size_t size() const
size - Get the array size.
uint64_t decodeULEB128(const uint8_t *p, unsigned *n=nullptr, const uint8_t *end=nullptr, const char **error=nullptr)
Utility function to decode a ULEB128 value.
static const EnumEntry< unsigned > TagNames[]
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
static Twine utohexstr(const uint64_t &Val)
std::string utostr(uint64_t X, bool isNeg=false)
LLVM_NODISCARD bool empty() const
uint32_t read32le(const void *P)
LLVM Value Representation.
void Parse(ArrayRef< uint8_t > Section, bool isLittle)
StringRef - Represent a constant reference to a string, i.e.