This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy] --compress-debug-sections: remove tail padding for ELFCLASS32

Authored by MaskRay on Sep 21 2022, 2:00 PM.



For an ELFCLASS32 object, a compressed section due to --compress-debug-sections={zlib,zstd} has a
tail padding of 12 zero bytes. zlib happily allows this while zstd is rigid and
reports error: '{{.*}}': failed to decompress section '.debug_foo': Src size is incorrect.

Cole Kissane reported the problem to me.

Diff Detail

Event Timeline

MaskRay created this revision.Sep 21 2022, 2:00 PM
MaskRay requested review of this revision.Sep 21 2022, 2:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2022, 2:00 PM
phosek accepted this revision.Sep 21 2022, 5:10 PM


This revision is now accepted and ready to land.Sep 21 2022, 5:10 PM
jhenderson accepted this revision.Sep 21 2022, 11:35 PM

LGTM too!

jhenderson added inline comments.Sep 21 2022, 11:38 PM

Actually one question: this seems to be assuming that BE and LE Elf_Chdr_Impl are the same size. I assume that's intentional, and it's fine if it is, but perhaps it deserves a static_assert or similar to protect us in case something odd changes in the future?

MaskRay marked an inline comment as done.Sep 22 2022, 10:25 AM
MaskRay added inline comments.

Thanks for the quick review. ELF has ELFCLASS32 and ELFCLASS64 distinction and endianness does not affect the structures. LLVMObject defines Elf_Chdr_Impl to provide ergonomic access for cross-endianness situations but I feel static_assert is rather unnecessary here.

This revision was landed with ongoing or failed builds.Sep 22 2022, 10:27 AM
This revision was automatically updated to reflect the committed changes.
MaskRay marked an inline comment as done.