[PATCH] D28105: [DWARF] - Introduce DWARFCompression class.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 10 11:45:03 PST 2017


George Rimar via Phabricator <reviews at reviews.llvm.org> writes:
> +  // Consume uncompressed section size (big-endian 8 bytes).
> +  DataExtractor extractor(SectionData, false, 8);
> +  uint32_t Offset = 0;
> +  uint64_t Size = extractor.getU64(&Offset);

Please use read64be.

> +  DataExtractor Extractor(SectionData, IsLittleEndian, 0);
> +  uint32_t Offset = 0;
> +  if (Extractor.getUnsigned(&Offset, Is64Bit ? sizeof(Elf64_Word)
> +                                             : sizeof(Elf32_Word)) !=
> +      ELFCOMPRESS_ZLIB)
> +    return createError("unsupported compression type");

We should probably add a version of read that takes size and endianess
as run time values instead of templates, but this is fine for now.

> +bool Decompressor::isCompressed(const object::SectionRef &Section) {
> +  StringRef Name;
> +  Section.getName(Name);

Do we get compressed sections on non-elf?
You should check the error of getName.

> +  return Section.isCompressed() || isGnuStyle(Name);
> +}
> +
> +bool Decompressor::isCompressedELFSection(uint64_t Flags, StringRef Name) {
> +  return (Flags & ELF::SHF_COMPRESSED) || isGnuStyle(Name);
> +}

Why do you need a special version for ELF?

Cheers,
Rafael


More information about the llvm-commits mailing list