23 HeaderOffset = *OffsetPtr;
26 std::tie(HeaderData.Length, Format) =
Data.getInitialLength(OffsetPtr, &Err);
30 SectionName.data(), HeaderOffset,
toString(std::move(Err)).
c_str());
37 "%s table at offset 0x%" PRIx64
38 " has too small length (0x%" PRIx64
39 ") to contain a complete header",
40 SectionName.data(), HeaderOffset, FullLength);
41 assert(FullLength ==
length() &&
"Inconsistent calculation of length.");
42 uint64_t End = HeaderOffset + FullLength;
43 if (!
Data.isValidOffsetForDataOfSize(HeaderOffset, FullLength))
45 "section is not large enough to contain a %s table "
46 "of length 0x%" PRIx64
" at offset 0x%" PRIx64,
47 SectionName.data(), FullLength, HeaderOffset);
49 HeaderData.Version =
Data.getU16(OffsetPtr);
50 HeaderData.AddrSize =
Data.getU8(OffsetPtr);
51 HeaderData.SegSize =
Data.getU8(OffsetPtr);
52 HeaderData.OffsetEntryCount =
Data.getU32(OffsetPtr);
55 if (HeaderData.Version < 5 || HeaderData.Version > 6)
57 "unrecognised %s table version %" PRIu16
58 " in table at offset 0x%" PRIx64,
59 SectionName.data(), HeaderData.Version, HeaderOffset);
62 "%s table at offset 0x%" PRIx64, SectionName.data(), HeaderOffset))
64 if (HeaderData.SegSize != 0)
66 "%s table at offset 0x%" PRIx64
67 " has unsupported segment selector size %" PRIu8,
68 SectionName.data(), HeaderOffset, HeaderData.SegSize);
70 HeaderData.OffsetEntryCount * OffsetByteSize)
72 "%s table at offset 0x%" PRIx64
" has more offset entries (%" PRIu32
73 ") than there is space for",
74 SectionName.data(), HeaderOffset, HeaderData.OffsetEntryCount);
75 Data.setAddressSize(HeaderData.AddrSize);
76 *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)