From: George Rimar Date: Wed, 6 Mar 2019 14:12:18 +0000 (+0000) Subject: [llvm-objcopy] - Remove dead code. NFCI. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34045966baa3e99de6250705aaec2de35bc00aeb;p=llvm [llvm-objcopy] - Remove dead code. NFCI. DecompressedSection can only be created if --decompress-debug-sections is specified. https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-objcopy/ELF/ELFObjcopy.cpp#L492 If it is specified when !zlib::isAvailable(), we error out early when parsing the options: https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-objcopy/CopyConfig.cpp#L657 What means the code I am removing in this patch is dead. Differential revision: https://reviews.llvm.org/D59017 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355505 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/llvm-objcopy/ELF/Object.cpp b/tools/llvm-objcopy/ELF/Object.cpp index 6bc17966198..ead2a889438 100644 --- a/tools/llvm-objcopy/ELF/Object.cpp +++ b/tools/llvm-objcopy/ELF/Object.cpp @@ -182,13 +182,6 @@ getDecompressedSizeAndAlignment(ArrayRef Data) { template void ELFSectionWriter::visit(const DecompressedSection &Sec) { - uint8_t *Buf = Out.getBufferStart() + Sec.Offset; - - if (!zlib::isAvailable()) { - std::copy(Sec.OriginalData.begin(), Sec.OriginalData.end(), Buf); - return; - } - const size_t DataOffset = isDataGnuCompressed(Sec.OriginalData) ? (ZlibGnuMagic.size() + sizeof(Sec.Size)) : sizeof(Elf_Chdr_Impl); @@ -202,6 +195,7 @@ void ELFSectionWriter::visit(const DecompressedSection &Sec) { static_cast(Sec.Size))) reportError(Sec.Name, std::move(E)); + uint8_t *Buf = Out.getBufferStart() + Sec.Offset; std::copy(DecompressedContent.begin(), DecompressedContent.end(), Buf); }