Page MenuHomePhabricator

fix extra bytes when compressing for 32bit objcopy
Needs ReviewPublic

Authored by ckissane on Sep 8 2022, 2:03 PM.

Details

Summary

fixes extra bytes that zlib is "ok" with but zstd detects and errors on when decompressing

Diff Detail

Event Timeline

ckissane created this revision.Sep 8 2022, 2:03 PM
Herald added a project: Restricted Project. · View Herald Transcript
ckissane requested review of this revision.Sep 8 2022, 2:03 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 8 2022, 2:03 PM
ckissane retitled this revision from fix extra bytes when compressing for 32bit objcopy to fix extra bytes when compressing for 32bit objcopy, and add zstd support to Decompressor.Sep 8 2022, 2:04 PM
ckissane edited the summary of this revision. (Show Details)
ckissane updated this revision to Diff 458871.Sep 8 2022, 2:24 PM
  • fix extra bytes when compressing for 32bit objcopy
  • fix lldb compressed section zstd test File Size
ckissane updated this revision to Diff 458875.Sep 8 2022, 2:33 PM
  • remove lldb changes
ckissane retitled this revision from fix extra bytes when compressing for 32bit objcopy, and add zstd support to Decompressor to fix extra bytes when compressing for 32bit objcopy.Sep 8 2022, 2:34 PM
ckissane edited the summary of this revision. (Show Details)
ckissane removed a project: Restricted Project.
phosek added a comment.Sep 8 2022, 7:21 PM

Would it be possible to write a test that covers this case?

See test/tools/llvm-objcopy/ELF/compress-debug-sections-zstd.test. Use a similar file for ELFCLASS32 which runs llvm-objcopy --compress-debug-sections=zstd then llvm-objcopy --decompress-debug-sections. Then compare the output with the original with just one llvm-objcopy run.

MaskRay added inline comments.Sep 8 2022, 9:45 PM
llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
509

This is incorrect. Config.OutputArch is usually unset (-O).

We need a field in Object and initialize it in llvm/lib/ObjCopy/ELF/ELFObject.cpp:1883

D134385 should fix the problem:)