18 template <
typename... Ts>
22 Stream <<
format(Fmt, Vals...);
28 HeaderOffset = *OffsetPtr;
31 return createError(
"section is not large enough to contain a " 32 "%s table length at offset 0x%" PRIx32,
35 HeaderData.Length = Data.
getU32(OffsetPtr);
36 if (HeaderData.Length == 0xffffffffu)
37 return createError(
"DWARF64 is not supported in %s at offset 0x%" PRIx32,
40 if (HeaderData.Length +
sizeof(
uint32_t) <
sizeof(Header))
42 " has too small length (0x%" PRIx32
43 ") to contain a complete header",
47 return createError(
"section is not large enough to contain a %s table " 48 "of length 0x%" PRIx32
" at offset 0x%" PRIx32,
51 HeaderData.Version = Data.
getU16(OffsetPtr);
52 HeaderData.AddrSize = Data.
getU8(OffsetPtr);
53 HeaderData.SegSize = Data.
getU8(OffsetPtr);
54 HeaderData.OffsetEntryCount = Data.
getU32(OffsetPtr);
57 if (HeaderData.Version != 5)
58 return createError(
"unrecognised %s table version %" PRIu16
59 " in table at offset 0x%" PRIx32,
60 SectionName.data(), HeaderData.Version, HeaderOffset);
61 if (HeaderData.AddrSize != 4 && HeaderData.AddrSize != 8)
63 " has unsupported address size %hhu",
64 SectionName.data(), HeaderOffset, HeaderData.AddrSize);
65 if (HeaderData.SegSize != 0)
67 " has unsupported segment selector size %" PRIu8,
68 SectionName.data(), HeaderOffset, HeaderData.SegSize);
69 if (End < HeaderOffset +
sizeof(HeaderData) +
70 HeaderData.OffsetEntryCount *
sizeof(
uint32_t))
72 "%s table at offset 0x%" PRIx32
" has more offset entries (%" PRIu32
73 ") than there is space for",
74 SectionName.data(), HeaderOffset, HeaderData.OffsetEntryCount);
76 for (
uint32_t I = 0;
I < HeaderData.OffsetEntryCount; ++
I)
77 Offsets.push_back(Data.
getU32(OffsetPtr));
83 OS <<
format(
"0x%8.8" PRIx32
": ", HeaderOffset);
85 "%s list header: length = 0x%8.8" PRIx32
", version = 0x%4.4" PRIx16
", " 86 "addr_size = 0x%2.2" PRIx8
", seg_size = 0x%2.2" PRIx8
87 ", offset_entry_count = " 89 ListTypeString.
data(), HeaderData.Length, HeaderData.Version,
90 HeaderData.AddrSize, HeaderData.SegSize, HeaderData.OffsetEntryCount);
92 if (HeaderData.OffsetEntryCount > 0) {
94 for (
const auto &Off : Offsets) {
95 OS <<
format(
"\n0x%8.8" PRIx32, Off);
97 OS <<
format(
" => 0x%8.8" PRIx32,
98 Off + HeaderOffset +
sizeof(HeaderData));
105 if (HeaderData.Length == 0)
108 return HeaderData.Length +
sizeof(
uint32_t);
Compute iterated dominance frontiers using a linear time algorithm.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
static Error createError(char const *Fmt, const Ts &... Vals)
Container for dump options that control which debug information will be dumped.
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
static ErrorSuccess success()
Create a success value.
This file contains constants used for implementing Dwarf debug support.
A raw_ostream that writes to an std::string.
Lightweight error class with error context and mandatory checking.
This class implements an extremely fast bulk output stream that can only output to a stream...
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...