21 uint64_t *OffsetPtr) {
22 HeaderOffset = *OffsetPtr;
25 std::tie(HeaderData.Length, Format) =
Data.getInitialLength(OffsetPtr, &Err);
29 SectionName.data(), HeaderOffset,
toString(std::move(Err)).
c_str());
36 "%s table at offset 0x%" PRIx64
37 " has too small length (0x%" PRIx64
38 ") to contain a complete header",
39 SectionName.data(), HeaderOffset, FullLength);
40 assert(FullLength ==
length() &&
"Inconsistent calculation of length.");
41 uint64_t End = HeaderOffset + FullLength;
42 if (!
Data.isValidOffsetForDataOfSize(HeaderOffset, FullLength))
44 "section is not large enough to contain a %s table "
45 "of length 0x%" PRIx64
" at offset 0x%" PRIx64,
46 SectionName.data(), FullLength, HeaderOffset);
48 HeaderData.Version =
Data.getU16(OffsetPtr);
49 HeaderData.AddrSize =
Data.getU8(OffsetPtr);
50 HeaderData.SegSize =
Data.getU8(OffsetPtr);
51 HeaderData.OffsetEntryCount =
Data.getU32(OffsetPtr);
54 if (HeaderData.Version < 5 || HeaderData.Version > 6)
56 "unrecognised %s table version %" PRIu16
57 " in table at offset 0x%" PRIx64,
58 SectionName.data(), HeaderData.Version, HeaderOffset);
61 "%s table at offset 0x%" PRIx64, SectionName.data(), HeaderOffset))
63 if (HeaderData.SegSize != 0)
65 "%s table at offset 0x%" PRIx64
66 " has unsupported segment selector size %" PRIu8,
67 SectionName.data(), HeaderOffset, HeaderData.SegSize);
69 HeaderData.OffsetEntryCount * OffsetByteSize)
71 "%s table at offset 0x%" PRIx64
" has more offset entries (%" PRIu32
72 ") than there is space for",
73 SectionName.data(), HeaderOffset, HeaderData.OffsetEntryCount);
74 Data.setAddressSize(HeaderData.AddrSize);
75 *OffsetPtr += HeaderData.OffsetEntryCount * OffsetByteSize;
static Error checkAddressSizeSupported(unsigned AddressSize, std::error_code EC, char const *Fmt, const Ts &...Vals)
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)