[llvm] [llvm-objcopy] Report unsupported formats before compression (PR #202357)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 10 03:14:14 PDT 2026
================
@@ -0,0 +1,5 @@
+# UNSUPPORTED: zlib
+# RUN: yaml2obj %p/Inputs/compress-debug-sections.yaml -o %t
+# RUN: not llvm-objcopy --compress-sections '.debug_foo=zlib' %t /dev/null 2>&1 | FileCheck %s -DFILE=%t
----------------
jjppp wrote:
Thanks for pointing out! I noticed that `--compress-debug-sections` and `--decompress-debug-sections` already gives different errors (specific section name + reason during decompression VS plain reason during compression):
compress:
https://github.com/llvm/llvm-project/blob/0345e7d8edb268dc9318f439cb50bbaff399067a/llvm/tools/llvm-objcopy/ObjcopyOptions.cpp#L923-L925
decompress:
https://github.com/llvm/llvm-project/blob/0345e7d8edb268dc9318f439cb50bbaff399067a/llvm/lib/ObjCopy/ELF/ELFObject.cpp#L479-L483
--compress-debug-sections checks the validity of formats long before the compression actually happens during option parsing (as it compresses all the debug sections using the same format), which is probably why it gives an error without a specific section name.
Since this PR places a finer-grained check right before compression occurs (after the old check when parsing options), I think the old checks in `ObjcopyOptions.cpp` is now redundant. Is it OK that I just remove it?
https://github.com/llvm/llvm-project/pull/202357
More information about the llvm-commits
mailing list