[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

llvm-svn: 355501
This commit is contained in:
George Rimar 2019-03-06 14:01:54 +00:00
parent a033572d67
commit f2eb8caa3f
1 changed files with 2 additions and 1 deletions

View File

@ -1111,7 +1111,8 @@ SectionBase &ELFBuilder<ELFT>::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<ELFT>(Data);