From c80500fed5e72f253edeca4d45a485d57fc4ebef Mon Sep 17 00:00:00 2001 From: George Rimar Date: Wed, 6 Mar 2019 14:01:54 +0000 Subject: [PATCH] [llvm-objcopy] - Fix incorrect CompressedSection creation. We should create CompressedSection only if the section has SHF_COMPRESSED flag or it's name starts from '.zdebug'. Currently, we create it if section's data starts from ZLIB signature. Differential revision: https://reviews.llvm.org/D59018 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355501 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-objcopy/ELF/Object.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/llvm-objcopy/ELF/Object.cpp b/tools/llvm-objcopy/ELF/Object.cpp index e2944ae3e24..c90e7c64612 100644 --- a/tools/llvm-objcopy/ELF/Object.cpp +++ b/tools/llvm-objcopy/ELF/Object.cpp @@ -1111,7 +1111,8 @@ SectionBase &ELFBuilder::makeSection(const Elf_Shdr &Shdr) { default: { Data = unwrapOrError(ElfFile.getSectionContents(&Shdr)); - if (isDataGnuCompressed(Data) || (Shdr.sh_flags & ELF::SHF_COMPRESSED)) { + StringRef Name = unwrapOrError(ElfFile.getSectionName(&Shdr)); + if (Name.startswith(".zdebug") || (Shdr.sh_flags & ELF::SHF_COMPRESSED)) { uint64_t DecompressedSize, DecompressedAlign; std::tie(DecompressedSize, DecompressedAlign) = getDecompressedSizeAndAlignment(Data); -- 2.11.0