21 if (!AccelSection.
isValidOffset(offsetof(Header, HeaderDataLength)+4))
24 Hdr.Magic = AccelSection.
getU32(&Offset);
25 Hdr.Version = AccelSection.
getU16(&Offset);
26 Hdr.HashFunction = AccelSection.
getU16(&Offset);
27 Hdr.NumBuckets = AccelSection.
getU32(&Offset);
28 Hdr.NumHashes = AccelSection.
getU32(&Offset);
29 Hdr.HeaderDataLength = AccelSection.
getU32(&Offset);
33 if (!AccelSection.
isValidOffset(
sizeof(Hdr) + Hdr.HeaderDataLength +
34 Hdr.NumBuckets*4 + Hdr.NumHashes*8))
37 HdrData.DIEOffsetBase = AccelSection.
getU32(&Offset);
38 uint32_t NumAtoms = AccelSection.
getU32(&Offset);
40 for (
unsigned i = 0; i < NumAtoms; ++i) {
41 uint16_t AtomType = AccelSection.
getU16(&Offset);
42 uint16_t AtomForm = AccelSection.
getU16(&Offset);
43 HdrData.Atoms.push_back(std::make_pair(AtomType, AtomForm));
51 OS <<
"Magic = " <<
format(
"0x%08x", Hdr.Magic) <<
'\n'
52 <<
"Version = " <<
format(
"0x%04x", Hdr.Version) <<
'\n'
53 <<
"Hash function = " <<
format(
"0x%08x", Hdr.HashFunction) <<
'\n'
54 <<
"Bucket count = " << Hdr.NumBuckets <<
'\n'
55 <<
"Hashes count = " << Hdr.NumHashes <<
'\n'
56 <<
"HeaderData length = " << Hdr.HeaderDataLength <<
'\n'
57 <<
"DIE offset base = " << HdrData.DIEOffsetBase <<
'\n'
58 <<
"Number of atoms = " << HdrData.Atoms.size() <<
'\n';
62 for (
const auto &Atom: HdrData.Atoms) {
63 OS <<
format(
"Atom[%d] Type: ", i++);
67 OS <<
format(
"DW_ATOM_Unknown_0x%x", Atom.first);
72 OS <<
format(
"DW_FORM_Unknown_0x%x", Atom.second);
78 uint32_t Offset =
sizeof(Hdr) + Hdr.HeaderDataLength;
79 unsigned HashesBase = Offset + Hdr.NumBuckets * 4;
80 unsigned OffsetsBase = HashesBase + Hdr.NumHashes * 4;
82 for (
unsigned Bucket = 0; Bucket < Hdr.NumBuckets; ++Bucket) {
83 unsigned Index = AccelSection.
getU32(&Offset);
85 OS <<
format(
"Bucket[%d]\n", Bucket);
86 if (Index == UINT32_MAX) {
91 for (
unsigned HashIdx = Index; HashIdx < Hdr.NumHashes; ++HashIdx) {
92 unsigned HashOffset = HashesBase + HashIdx*4;
93 unsigned OffsetsOffset = OffsetsBase + HashIdx*4;
94 uint32_t
Hash = AccelSection.
getU32(&HashOffset);
96 if (Hash % Hdr.NumBuckets != Bucket)
99 unsigned DataOffset = AccelSection.
getU32(&OffsetsOffset);
100 OS <<
format(
" Hash = 0x%08x Offset = 0x%08x\n", Hash, DataOffset);
102 OS <<
" Invalid section offset\n";
106 unsigned StringOffset = AccelSection.
getU32(&DataOffset);
108 if (Reloc != Relocs.
end())
109 StringOffset += Reloc->second.second;
112 OS <<
format(
" Name: %08x \"%s\"\n", StringOffset,
113 StringSection.
getCStr(&StringOffset));
114 unsigned NumData = AccelSection.
getU32(&DataOffset);
118 for (
auto &Atom : AtomForms) {
119 OS <<
format(
"{Atom[%d]: ", i++);
120 if (Atom.extractValue(AccelSection, &DataOffset,
nullptr))
121 Atom.dump(OS,
nullptr);
123 OS <<
"Error extracting the value";
void push_back(const T &Elt)
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
const char * AtomTypeString(unsigned Atom)
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
for(unsigned i=0, e=MI->getNumOperands();i!=e;++i)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void dump(raw_ostream &OS) const
iterator find(const KeyT &Val)
const char * FormEncodingString(unsigned Encoding)
This class implements an extremely fast bulk output stream that can only output to a stream...
std::string Hash(const Unit &U)