Go to the documentation of this file.
21 bool IsLE,
bool Is64Bit) {
26 Error Err = isGnuStyle(
Name) ?
D.consumeCompressedGnuHeader()
27 :
D.consumeCompressedZLibHeader(Is64Bit, IsLE);
33 Decompressor::Decompressor(
StringRef Data)
34 : SectionData(
Data), DecompressedSize(0) {}
36 Error Decompressor::consumeCompressedGnuHeader() {
38 return createError(
"corrupted compressed section header");
40 SectionData = SectionData.
substr(4);
43 if (SectionData.
size() < 8)
44 return createError(
"corrupted uncompressed section size");
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");
60 if (Extractor.getUnsigned(&Offset, Is64Bit ?
sizeof(
Elf64_Word)
69 DecompressedSize = Extractor.getUnsigned(
71 SectionData = SectionData.substr(HdrSize);
76 return Name.startswith(
".zdebug");
80 if (Section.isCompressed())
96 size_t Size = Buffer.
size();
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
This is an optimization pass for GlobalISel generic memory operations.
Error uncompress(StringRef InputBuffer, char *UncompressedBuffer, size_t &UncompressedSize)
static ErrorSuccess success()
Create a success value.
Error decompress(MutableArrayRef< char > Buffer)
Uncompress section data to raw buffer provided.
static bool isCompressed(const object::SectionRef &Section)
Return true if section is compressed, including gnu-styled case.
Tagged union holding either a T or a Error.
void consumeError(Error Err)
Consume a Error without doing anything.
uint64_t read64be(const void *P)
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
static Error createError(const Twine &Err)
This is a value type class that represents a single section in the list of sections in the object fil...
bar al al movzbl eax ret Missed when stored in a memory object
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
static bool isGnuStyle(StringRef Name)
Return true if section name matches gnu style compressed one.
StringRef - Represent a constant reference to a string, i.e.
constexpr LLVM_NODISCARD size_t size() const
size - Get the string size.
Lightweight error class with error context and mandatory checking.
Error takeError()
Take ownership of the stored error.
size_t size() const
size - Get the array size.
const LLVM_NODISCARD char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Error createError(const Twine &Err)
Decompressor helps to handle decompression of compressed sections.
static bool isCompressedELFSection(uint64_t Flags, StringRef Name)
Return true if section is a ELF compressed one.