llvm/llvm-project

llvm-objcopy crashes with unreachable error when (de)compression requested without selected value available

Open

#197877 opened on May 15, 2026

View on GitHub
 (7 comments) (0 reactions) (0 assignees)C++ (26,378 stars) (10,782 forks)batch import
good first issuetools:llvm-objcopy/strip

Description

llvm-objcopy crashes due to calling llvm_unreachable when compression::compress or compression::decompress is called without the selected compression type being installed on the machine.

The problem is that the tool doesn't call compression::getReasonIfUnsupported before compression::compress or compression::decompress. The correct thing to do is to call that first, then check the result and either report an Error based on the result or continuing and (de)compress as requested.

Discovered while triaging #197813.

I'll label this with good first issue as it's a trivial fix (but I don't have the personal time to fix it and put a PR up myself). There should be two tests for it. The first test should test that the correct error is emitted for zlib compression and decompression and the second the same for zstd. Each test should only run if zlib/zstd is NOT enabled on the target (i.e. something like UNSUPPORTED: zlib, but check other examples for REQUIRES/UNSUPPORTED tags to see the exact way of writing that).

Contributor guide