From: Fangrui Song Date: Mon, 25 Jul 2022 07:06:36 +0000 (-0700) Subject: [llvm-objcopy] Remove getDecompressedSizeAndAlignment. NFC X-Git-Tag: upstream/15.0.7~615 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91e2cd4fa90b13f0327615b76bd0d027a6c39a65;p=platform%2Fupstream%2Fllvm.git [llvm-objcopy] Remove getDecompressedSizeAndAlignment. NFC --- 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)); } } }