diff options
author | Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org> | 2021-09-28 20:11:26 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-09-28 20:18:48 +0930 |
commit | 0d62064867c74286360e821b75ef6799bedc4b34 (patch) | |
tree | bcee02b228cfb5569b40045b347651fa15f8822b /binutils/ar.c | |
parent | cee4c731af1e68814548ff00e4e7ecaa8ac07790 (diff) | |
download | fsf-binutils-gdb-0d62064867c74286360e821b75ef6799bedc4b34.zip fsf-binutils-gdb-0d62064867c74286360e821b75ef6799bedc4b34.tar.gz fsf-binutils-gdb-0d62064867c74286360e821b75ef6799bedc4b34.tar.bz2 |
PR28391, strip/objcopy --preserve-dates *.a: cannot set time
After commit 985e0264516 copy_archive function began to pass invalid
values to the utimensat(2) function when it tries to preserve
timestamps in ar archives. This happens because the bfd_stat_arch_elt
implementation for ar archives fills only the st_mtim.tv_sec part of
the st_mtim timespec structure, but leaves the st_mtim.tv_nsec part
and the whole st_atim timespec untouched leaving them uninitialized
PR 28391
* ar.c (extract_file): Clear buf for preserve_dates.
* objcopy.c (copy_archive): Likewise.
Diffstat (limited to 'binutils/ar.c')
-rw-r--r-- | binutils/ar.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/binutils/ar.c b/binutils/ar.c index 5d6976c..8885585 100644 --- a/binutils/ar.c +++ b/binutils/ar.c @@ -1180,6 +1180,9 @@ extract_file (bfd *abfd) bfd_size_type size; struct stat buf; + if (preserve_dates) + memset (&buf, 0, sizeof (buf)); + if (bfd_stat_arch_elt (abfd, &buf) != 0) /* xgettext:c-format */ fatal (_("internal stat error on %s"), bfd_get_filename (abfd)); |