[llvm-objcopy] --compress-debug-sections: remove tail padding for ELFCLASS32
authorFangrui Song <i@maskray.me>
Thu, 22 Sep 2022 17:26:47 +0000 (10:26 -0700)
committerFangrui Song <i@maskray.me>
Thu, 22 Sep 2022 17:26:47 +0000 (10:26 -0700)
commitc997fe658655b42237f556c11c7f5bc8ec60658b
treee785d2984e6df992aaaa9e02964344807410fda2
parent6b93f30b1c633b11dceff7080d4035492583ce17
[llvm-objcopy] --compress-debug-sections: remove tail padding for ELFCLASS32

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.

Reviewed By: jhenderson, phosek

Differential Revision: https://reviews.llvm.org/D134385
llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
llvm/lib/ObjCopy/ELF/ELFObject.cpp
llvm/lib/ObjCopy/ELF/ELFObject.h
llvm/test/tools/llvm-objcopy/ELF/Inputs/compress-debug-sections.yaml
llvm/test/tools/llvm-objcopy/ELF/compress-debug-sections-zstd.test