Bug 252727 - readelf returns 0 (success) even on error
Summary: readelf returns 0 (success) even on error
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Ed Maste
Depends on:
Reported: 2021-01-16 01:19 UTC by Ed Maste
Modified: 2021-01-25 20:17 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer 2021-01-16 01:19:08 UTC
$ readelf -l /dev/null;  echo $?
readelf: elf_begin() failed: Invalid argument

This prevents error handling in shell scripts.
Comment 1 Ed Maste freebsd_committer 2021-01-16 01:30:19 UTC
Experimenting with GNU readelf, I see:
- rv = 1 if one or more files failed, regardless of where in the argument list it appears
- files specified after a failure are still processed
- specifying a non-ELF file results in failure (/dev/null, shell script, etc.)
- unsure of behaviour for a malformed ELF file