#ifndef LLVM_OBJECT_DECOMPRESSOR_H
#define LLVM_OBJECT_DECOMPRESSOR_H
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Object/ObjectFile.h"
namespace llvm {
namespace object {
class Decompressor {
public:
static Expected<Decompressor> create(StringRef Name, StringRef Data,
bool IsLE, bool Is64Bit);
template <class T> Error resizeAndDecompress(T &Out) {
Out.resize(DecompressedSize);
return decompress({Out.data(), (size_t)DecompressedSize});
}
Error decompress(MutableArrayRef<char> Buffer);
uint64_t getDecompressedSize() { return DecompressedSize; }
static bool isCompressed(const object::SectionRef &Section);
static bool isCompressedELFSection(uint64_t Flags, StringRef Name);
static bool isGnuStyle(StringRef Name);
private:
Decompressor(StringRef Data);
Error consumeCompressedGnuHeader();
Error consumeCompressedZLibHeader(bool Is64Bit, bool IsLittleEndian);
StringRef SectionData;
uint64_t DecompressedSize;
};
} }
#endif