From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84256 invoked by alias); 2 Jun 2017 13:18:24 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 84213 invoked by uid 48); 2 Jun 2017 13:18:20 -0000 From: "mark at klomp dot org" To: elfutils-devel@sourceware.org Subject: [Bug tools/21522] eu-strip generates empty output if there is nothing to do Date: Wed, 07 Jun 2017 12:13:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: tools X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mark at klomp dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2017-q2/txt/msg00235.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=3D21522 Mark Wielaard changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mark at klomp dot org --- Comment #1 from Mark Wielaard --- We seem to never remove the output file if we created it, but couldn't fini= sh it (either because there is nothing to do or some error occurred). We should always remove it in that case. Testing the following: diff --git a/src/strip.c b/src/strip.c index f747441..c5dbc9c 100644 --- a/src/strip.c +++ b/src/strip.c @@ -1063,8 +1063,11 @@ handle_elf (int fd, Elf *elf, const char *prefix, co= nst char *fname, /* Test whether we are doing anything at all. */ if (cnt =3D=3D idx) - /* Nope, all removable sections are already gone. */ - goto fail_close; + { + /* Nope, all removable sections are already gone. */ + result =3D 1; + goto fail_close; + } /* Create the reference to the file with the debug info. */ if (debug_fname !=3D NULL && !remove_shdrs) @@ -2226,7 +2229,11 @@ cannot set access and modification date of '%s'"), /* Close the file descriptor if we created a new file. */ if (output_fname !=3D NULL) - close (fd); + { + close (fd); + if (result !=3D 0) + unlink (output_fname); + } return result; } --=20 You are receiving this mail because: You are on the CC list for the bug.