Bug 22555 - readelf exit status is 0 for empty zero-length file
Summary: readelf exit status is 0 for empty zero-length file
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.29
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-06 10:01 UTC by Michael Stahl
Modified: 2017-12-06 10:19 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Stahl 2017-12-06 10:01:48 UTC
from Fedora 26 to Fedora 27, the readelf exit status changed from 1
to 0 when running "readelf -d" on an empty file:

old:

> touch /tmp/foo
> readelf -d /tmp/foo 
readelf: /tmp/foo: Error: Failed to read file's magic number
> echo $?
1
> readelf --version
GNU readelf version 2.27-28.fc26
Copyright (C) 2016 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

new:

> touch /tmp/foo
> readelf -d /tmp/foo
readelf: /tmp/foo: Error: Failed to read file's magic number
> echo $?
0
> readelf --version
GNU readelf version 2.29-6.fc27
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.


but readelf still prints an error - so i think it should not exit with 0.
Comment 1 Nick Clifton 2017-12-06 10:19:15 UTC
Hi Michael,

  This is a Fedora specific bug.  The FSF binutils sources do the right
  thing.  Please could you refile the bug report using the Fedora bugzilla
  system here:

https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora

  Cheers
Nick