From 91e2cd4fa90b13f0327615b76bd0d027a6c39a65 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 25 Jul 2022 00:06:36 -0700 Subject: [PATCH] [llvm-objcopy] Remove getDecompressedSizeAndAlignment. NFC --- llvm/lib/ObjCopy/ELF/ELFObject.cpp | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp index 9f7408c..b127e1b 100644 --- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp +++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp @@ -435,17 +435,6 @@ Error SectionWriter::visit(const OwnedDataSection &Sec) { } template -static std::tuple -getDecompressedSizeAndAlignment(ArrayRef Data) { - const uint64_t DecompressedSize = - reinterpret_cast *>(Data.data())->ch_size; - const uint64_t DecompressedAlign = - reinterpret_cast *>(Data.data())->ch_addralign; - - return std::make_tuple(DecompressedSize, DecompressedAlign); -} - -template Error ELFSectionWriter::visit(const DecompressedSection &Sec) { ArrayRef Compressed = Sec.OriginalData.slice(sizeof(Elf_Chdr_Impl)); @@ -1714,15 +1703,11 @@ Expected ELFBuilder::makeSection(const Elf_Shdr &Shdr) { if (!Name) return Name.takeError(); - if (Shdr.sh_flags & ELF::SHF_COMPRESSED) { - uint64_t DecompressedSize, DecompressedAlign; - std::tie(DecompressedSize, DecompressedAlign) = - getDecompressedSizeAndAlignment(*Data); - return Obj.addSection( - CompressedSection(*Data, DecompressedSize, DecompressedAlign)); - } - - return Obj.addSection
(*Data); + if (!(Shdr.sh_flags & ELF::SHF_COMPRESSED)) + return Obj.addSection
(*Data); + auto *Chdr = reinterpret_cast *>(Data->data()); + return Obj.addSection( + CompressedSection(*Data, Chdr->ch_size, Chdr->ch_addralign)); } } } -- 2.7.4