-const SmallVectorImpl<char> &MCCompressedFragment::getCompressedContents() const {
- assert(getParent()->size() == 1 &&
- "Only compress sections containing a single fragment");
- if (CompressedContents.empty()) {
- std::unique_ptr<MemoryBuffer> CompressedSection;
- zlib::Status Success =
- zlib::compress(StringRef(getContents().data(), getContents().size()),
- CompressedSection);
- (void)Success;
- assert(Success == zlib::StatusOK);
- CompressedContents.push_back('Z');
- CompressedContents.push_back('L');
- CompressedContents.push_back('I');
- CompressedContents.push_back('B');
- uint64_t Size = getContents().size();
- if (sys::IsLittleEndianHost)
- Size = sys::SwapByteOrder(Size);
- CompressedContents.append(reinterpret_cast<char *>(&Size),
- reinterpret_cast<char *>(&Size + 1));
- CompressedContents.append(CompressedSection->getBuffer().begin(),
- CompressedSection->getBuffer().end());
- }
- return CompressedContents;
-}
-
-SmallVectorImpl<char> &MCCompressedFragment::getContents() {
- assert(CompressedContents.empty() &&
- "Fragment contents should not be altered after compression");
- return MCDataFragment::getContents();
-}
-
-/* *** */
-
-MCSectionData::MCSectionData() : Section(0) {}