mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-14 20:37:06 +00:00
strip/objcopy: handle empty file as unknown
Previously strip reported a somewhat cryptic error for empty files:
strip: elf_begin() failed: Invalid argument
Add a special case to treat empty files as with an unknown file format.
This is consistent with llvm-strip. GNU strip produces no output which
does not seem like useful behaviour (but it does exit with status 1).
Reported by: andrew
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32648
(cherry picked from commit 179219ea04
)
This commit is contained in:
parent
96e101bec9
commit
8d91740f96
|
@ -738,6 +738,8 @@ create_file(struct elfcopy *ecp, const char *src, const char *dst)
|
|||
|
||||
if ((ecp->ein = elf_begin(ifd, ELF_C_READ, NULL)) == NULL) {
|
||||
cleanup_tempfile(tempfile);
|
||||
if (fstat(ifd, &sb) == 0 && sb.st_size == 0)
|
||||
errx(EXIT_FAILURE, "file format not recognized");
|
||||
errx(EXIT_FAILURE, "elf_begin() failed: %s",
|
||||
elf_errmsg(-1));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue