* [Bug tools/21522] New: eu-strip generates empty output if there is nothing to do
@ 2017-05-30 14:37 paulo.cesar.pereira.de.andrade at gmail dot com
2017-06-07 12:13 ` [Bug tools/21522] " mark at klomp dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: paulo.cesar.pereira.de.andrade at gmail dot com @ 2017-05-30 14:37 UTC (permalink / raw)
To: elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=21522
Bug ID: 21522
Summary: eu-strip generates empty output if there is nothing to
do
Product: elfutils
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: tools
Assignee: unassigned at sourceware dot org
Reporter: paulo.cesar.pereira.de.andrade at gmail dot com
CC: elfutils-devel at sourceware dot org
Target Milestone: ---
Steps to reproduce:
$ cat test.c
int main() { return 1; }
$ gcc test.c
$ eu-strip -g -o test ./a.out
The "test" file will have zero bytes.
This happens because of the test in src/strip.c:
/* Test whether we are doing anything at all. */
if (cnt == idx)
/* Nope, all removable sections are already gone. */
goto fail_close;
Note also that, if the test is removed, it still
generates a different binary, so, the test is incomplete,
or should be removed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tools/21522] eu-strip generates empty output if there is nothing to do
2017-05-30 14:37 [Bug tools/21522] New: eu-strip generates empty output if there is nothing to do paulo.cesar.pereira.de.andrade at gmail dot com
@ 2017-06-07 12:13 ` mark at klomp dot org
2017-06-13 14:20 ` mark at klomp dot org
2017-06-14 18:50 ` mark at klomp dot org
2 siblings, 0 replies; 4+ messages in thread
From: mark at klomp dot org @ 2017-06-07 12:13 UTC (permalink / raw)
To: elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=21522
Mark Wielaard <mark at klomp dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mark at klomp dot org
--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
We seem to never remove the output file if we created it, but couldn't finish
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, const
char *fname,
/* Test whether we are doing anything at all. */
if (cnt == idx)
- /* Nope, all removable sections are already gone. */
- goto fail_close;
+ {
+ /* Nope, all removable sections are already gone. */
+ result = 1;
+ goto fail_close;
+ }
/* Create the reference to the file with the debug info. */
if (debug_fname != 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 != NULL)
- close (fd);
+ {
+ close (fd);
+ if (result != 0)
+ unlink (output_fname);
+ }
return result;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tools/21522] eu-strip generates empty output if there is nothing to do
2017-05-30 14:37 [Bug tools/21522] New: eu-strip generates empty output if there is nothing to do paulo.cesar.pereira.de.andrade at gmail dot com
2017-06-07 12:13 ` [Bug tools/21522] " mark at klomp dot org
@ 2017-06-13 14:20 ` mark at klomp dot org
2017-06-14 18:50 ` mark at klomp dot org
2 siblings, 0 replies; 4+ messages in thread
From: mark at klomp dot org @ 2017-06-13 14:20 UTC (permalink / raw)
To: elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=21522
Mark Wielaard <mark at klomp dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2017-06-07
Ever confirmed|0 |1
--- Comment #2 from Mark Wielaard <mark at klomp dot org> ---
The patch that I came up with works slightly different. While writing a
testcase I noticed we have a similar (though opposite) issue with -f debug.
Also it felt more correct to always make sure the -o output file was correct
(and not just not generate it if nothing was stripped out).
https://sourceware.org/ml/elfutils-devel/2017-q2/msg00237.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tools/21522] eu-strip generates empty output if there is nothing to do
2017-05-30 14:37 [Bug tools/21522] New: eu-strip generates empty output if there is nothing to do paulo.cesar.pereira.de.andrade at gmail dot com
2017-06-07 12:13 ` [Bug tools/21522] " mark at klomp dot org
2017-06-13 14:20 ` mark at klomp dot org
@ 2017-06-14 18:50 ` mark at klomp dot org
2 siblings, 0 replies; 4+ messages in thread
From: mark at klomp dot org @ 2017-06-14 18:50 UTC (permalink / raw)
To: elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=21522
Mark Wielaard <mark at klomp dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Mark Wielaard <mark at klomp dot org> ---
commit b58aebe71e0b4863db1b7fd3e942e36303257f3a
Author: Mark Wielaard <mark@klomp.org>
Date: Wed Jun 7 20:32:38 2017 +0200
strip: Don't generate empty output file when nothing to do.
If there was nothing to do strip would skip generating a separate
debug file if one was requested, but it would also not finish the
creation of a new output file (with the non-stripped sections).
Also if there was an error any partially created output would be kept.
Make sure that when the -o output file option is given we always generate
a complete output file (except on error). Also make sure that when the -f
debug file option is given it is only generated when it is not empty.
Add testcase run-strip-nothing.sh that tests the various combinations.
https://sourceware.org/bugzilla/show_bug.cgi?id=21522
Signed-off-by: Mark Wielaard <mark@klomp.org>
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-14 13:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30 14:37 [Bug tools/21522] New: eu-strip generates empty output if there is nothing to do paulo.cesar.pereira.de.andrade at gmail dot com
2017-06-07 12:13 ` [Bug tools/21522] " mark at klomp dot org
2017-06-13 14:20 ` mark at klomp dot org
2017-06-14 18:50 ` mark at klomp dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).