[PATCH] D59018: [llvm-objcopy] - Fix incorrect CompressedSection creation.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 6 04:56:24 PST 2019


grimar added a comment.

In D59018#1419679 <https://reviews.llvm.org/D59018#1419679>, @jhenderson wrote:

> The code change looks good, but I'm not sure I understand why you can't test this, i.e. where you have an input with a compressed section starting with .zdebug and showing that it is decompressed?


The case when we have a compressed section starting with `.zdebug` is tested in compress-debug-sections-zlib-gnu.test I think.

Here we have a bit different problem. Imagine you have a section `.foo` (so its name does not start from `.z*`). And if that `.foo` has `ZLIB` bytes at the start,
then the current code will create `CompressedSection`. But it is incorrect because `.foo` is not a gnu style compressed section because of its name.

if we have no compression flags, that will just work like if `.foo` would be a regular section.
If we have `--decompress-debug-sections` flag then the following code will be called:

  replaceDebugSections(
      Config, Obj, RemovePred,
      [](const SectionBase &S) { return isa<CompressedSection>(&S); },
      [&Obj](const SectionBase *S) {
        auto CS = cast<CompressedSection>(S);
        return &Obj.addSection<DecompressedSection>(*CS);
      });

But since ` isa<CompressedSection>(&S);` will return `false`, this section will not be converted to `DecompressedSection`
and we will handle it as a regular section.

So I can't test this, code already just works, though it is definitely not correct to create `.foo` as a compressed section.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59018/new/

https://reviews.llvm.org/D59018





More information about the llvm-commits mailing list