21 bool IsLE,
bool Is64Bit) {
26 Error Err = isGnuStyle(Name) ? D.consumeCompressedGnuHeader()
27 : D.consumeCompressedZLibHeader(Is64Bit, IsLE);
29 return std::move(Err);
34 : SectionData(Data), DecompressedSize(0) {}
36 Error Decompressor::consumeCompressedGnuHeader() {
37 if (!SectionData.startswith(
"ZLIB"))
38 return createError(
"corrupted compressed section header");
40 SectionData = SectionData.substr(4);
43 if (SectionData.size() < 8)
44 return createError(
"corrupted uncompressed section size");
45 DecompressedSize =
read64be(SectionData.data());
46 SectionData = SectionData.substr(8);
51 Error Decompressor::consumeCompressedZLibHeader(
bool Is64Bit,
52 bool IsLittleEndian) {
54 uint64_t HdrSize = Is64Bit ?
sizeof(Elf64_Chdr) :
sizeof(Elf32_Chdr);
55 if (SectionData.size() < HdrSize)
56 return createError(
"corrupted compressed section header");
71 SectionData = SectionData.substr(HdrSize);
86 bool Decompressor::isCompressedELFSection(uint64_t Flags,
StringRef Name) {
This class represents lattice values for constants.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
static Error createError(StringRef Err)
uint64_t read64be(const void *P)
Decompressor helps to handle decompression of compressed sections.
Tagged union holding either a T or a Error.
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...