22 bool IsLE,
bool Is64Bit) {
27 Error Err = isGnuStyle(Name) ? D.consumeCompressedGnuHeader()
28 : D.consumeCompressedZLibHeader(Is64Bit, IsLE);
30 return std::move(Err);
35 : SectionData(Data), DecompressedSize(0) {}
37 Error Decompressor::consumeCompressedGnuHeader() {
38 if (!SectionData.startswith(
"ZLIB"))
39 return createError(
"corrupted compressed section header");
41 SectionData = SectionData.substr(4);
44 if (SectionData.size() < 8)
45 return createError(
"corrupted uncompressed section size");
46 DecompressedSize =
read64be(SectionData.data());
47 SectionData = SectionData.substr(8);
52 Error Decompressor::consumeCompressedZLibHeader(
bool Is64Bit,
53 bool IsLittleEndian) {
55 uint64_t HdrSize = Is64Bit ?
sizeof(Elf64_Chdr) :
sizeof(Elf32_Chdr);
56 if (SectionData.size() < HdrSize)
57 return createError(
"corrupted compressed section header");
72 SectionData = SectionData.substr(HdrSize);
87 bool Decompressor::isCompressedELFSection(uint64_t Flags,
StringRef Name) {
This class represents lattice values for constants.
static Error createError(StringRef Err)
uint64_t read64be(const void *P)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Decompressor helps to handle decompression of compressed sections.
Tagged union holding either a T or a Error.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
bool isCompressed() const
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
size_t size() const
size - Get the array size.
static ErrorSuccess success()
Create a success value.
std::error_code getName(StringRef &Result) const
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
Error uncompress(StringRef InputBuffer, char *UncompressedBuffer, size_t &UncompressedSize)
This is a value type class that represents a single section in the list of sections in the object fil...