Index: ELF/InputSection.h =================================================================== --- ELF/InputSection.h +++ ELF/InputSection.h @@ -58,8 +58,9 @@ uint32_t Alignment; - // If a section is compressed, this vector has uncompressed section data. - SmallVector Uncompressed; + // If a section is compressed, this has the uncompressed section data. + std::unique_ptr UncompressedData; + size_t UncompressedDataSize = 0; std::vector Relocations; }; Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -53,8 +53,8 @@ template ArrayRef InputSectionBase::getSectionData() const { if (Compressed) - return ArrayRef((const uint8_t *)Uncompressed.data(), - Uncompressed.size()); + return ArrayRef((const uint8_t *)UncompressedData.get(), + UncompressedDataSize); return check(this->File->getObj().getSectionContents(this->Header)); } @@ -109,7 +109,10 @@ fatal(getName(this) + ": unsupported compression type"); StringRef Buf((const char *)Data.data(), Data.size()); - if (zlib::uncompress(Buf, Uncompressed, Hdr->ch_size) != zlib::StatusOK) + UncompressedDataSize = Hdr->ch_size; + UncompressedData.reset(new char[UncompressedDataSize]); + if (zlib::uncompress(Buf, UncompressedData.get(), UncompressedDataSize) != + zlib::StatusOK) fatal(getName(this) + ": error uncompressing section"); }