[llvm] [llvm-objdump] Return non-zero exit code for invalid MachO files (PR #172886)
Ryan Mansfield via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 17 06:47:20 PST 2026
rjmansfield wrote:
> Can I get the motivation for this change, please, including adding it to the PR description? I note in particular that this possibly diverges from the behaviour for other platforms (e.g. ELF) and secondly, there's code in `parseInputMachO` that reports an error under other cases, so not reporting an error here seems like a deliberate design decision. Indeed, reviewing the file history, that looks to be the case: [98898f2](https://github.com/llvm/llvm-project/commit/98898f2b0283629a03e52950da0007bb82b01ef7).
I had observed the difference in error codes and then noticed that someone had filed an issue about it.
All other LLVM binary tools (llvm-nm, llvm-readobj, llvm-size) correctly return non-zero exit codes for invalid files, and llvm-objdump in non-MachO mode already does this.
```
% ./bin/llvm-objdump -d /dev/null
./bin/llvm-objdump: error: '/dev/null': The file was not recognized as a valid object file
% echo $?
1
% ./bin/llvm-objdump -d -m /dev/null
/dev/null: is not an object file
% echo $?
0
```
The classic binutils objdump also returns 1 on an invalid objects and I think most expect non-zero codes on error. I missed 98898f2 which gives historical context for the behaviour. I don't think I'd have opened a PR had I seen it.
I will abandon the PR and then someone can resolve the bug as won't fix.
https://github.com/llvm/llvm-project/pull/172886
More information about the llvm-commits
mailing list