aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2022-07-14 22:38:17 +0000
committerDavid Blaikie <dblaikie@gmail.com>2022-07-14 22:38:59 +0000
commitd63ec445caa8e812685805afd458fb28bf7e6875 (patch)
tree1898b00bf2d919049c98af41f814d27d76c3d66b /llvm/lib/MC/ELFObjectWriter.cpp
parent6ab7307177c336d7ca5910fc434c012f35245fd1 (diff)
downloadllvm-d63ec445caa8e812685805afd458fb28bf7e6875.zip
llvm-d63ec445caa8e812685805afd458fb28bf7e6875.tar.gz
llvm-d63ec445caa8e812685805afd458fb28bf7e6875.tar.bz2
Remove zlibgnu support in llvm-mc
The feature's been removed from most other tools in LLVM at this point.
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp49
1 files changed, 19 insertions, 30 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 78204ff..e2e98d3 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -146,7 +146,7 @@ struct ELFWriter {
bool maybeWriteCompression(uint64_t Size,
SmallVectorImpl<uint8_t> &CompressedContents,
- bool ZLibStyle, unsigned Alignment);
+ unsigned Alignment);
public:
ELFWriter(ELFObjectWriter &OWriter, raw_pwrite_stream &OS,
@@ -819,36 +819,25 @@ MCSectionELF *ELFWriter::createRelocationSection(MCContext &Ctx,
// Include the debug info compression header.
bool ELFWriter::maybeWriteCompression(
- uint64_t Size, SmallVectorImpl<uint8_t> &CompressedContents, bool ZLibStyle,
+ uint64_t Size, SmallVectorImpl<uint8_t> &CompressedContents,
unsigned Alignment) {
- if (ZLibStyle) {
- uint64_t HdrSize =
- is64Bit() ? sizeof(ELF::Elf32_Chdr) : sizeof(ELF::Elf64_Chdr);
- if (Size <= HdrSize + CompressedContents.size())
- return false;
- // Platform specific header is followed by compressed data.
- if (is64Bit()) {
- // Write Elf64_Chdr header.
- write(static_cast<ELF::Elf64_Word>(ELF::ELFCOMPRESS_ZLIB));
- write(static_cast<ELF::Elf64_Word>(0)); // ch_reserved field.
- write(static_cast<ELF::Elf64_Xword>(Size));
- write(static_cast<ELF::Elf64_Xword>(Alignment));
- } else {
- // Write Elf32_Chdr header otherwise.
- write(static_cast<ELF::Elf32_Word>(ELF::ELFCOMPRESS_ZLIB));
- write(static_cast<ELF::Elf32_Word>(Size));
- write(static_cast<ELF::Elf32_Word>(Alignment));
- }
- return true;
- }
-
- // "ZLIB" followed by 8 bytes representing the uncompressed size of the section,
- // useful for consumers to preallocate a buffer to decompress into.
- const StringRef Magic = "ZLIB";
- if (Size <= Magic.size() + sizeof(Size) + CompressedContents.size())
+ uint64_t HdrSize =
+ is64Bit() ? sizeof(ELF::Elf32_Chdr) : sizeof(ELF::Elf64_Chdr);
+ if (Size <= HdrSize + CompressedContents.size())
return false;
- W.OS << Magic;
- support::endian::write(W.OS, Size, support::big);
+ // Platform specific header is followed by compressed data.
+ if (is64Bit()) {
+ // Write Elf64_Chdr header.
+ write(static_cast<ELF::Elf64_Word>(ELF::ELFCOMPRESS_ZLIB));
+ write(static_cast<ELF::Elf64_Word>(0)); // ch_reserved field.
+ write(static_cast<ELF::Elf64_Xword>(Size));
+ write(static_cast<ELF::Elf64_Xword>(Alignment));
+ } else {
+ // Write Elf32_Chdr header otherwise.
+ write(static_cast<ELF::Elf32_Word>(ELF::ELFCOMPRESS_ZLIB));
+ write(static_cast<ELF::Elf32_Word>(Size));
+ write(static_cast<ELF::Elf32_Word>(Alignment));
+ }
return true;
}
@@ -883,7 +872,7 @@ void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
bool ZlibStyle = MAI->compressDebugSections() == DebugCompressionType::Z;
if (!maybeWriteCompression(UncompressedData.size(), CompressedContents,
- ZlibStyle, Sec.getAlignment())) {
+ Sec.getAlignment())) {
W.OS << UncompressedData;
return;
}