crosstool-ng/packages/binutils/2.37/0011-pr28391-strip-objcopy-preserve-dates-a-cannot-set-time.patch
Alexey Neyman 86c2982568 Run patches thru manage-packages -P
This refreshes the line numbers, removes any fuzz (which would make any
future forward ports easier) and standardizes the patch/file headers
(which makes them easier to read).

Signed-off-by: Alexey Neyman <stilor@att.net>
2022-02-11 00:47:51 -08:00

45 lines
1.4 KiB
Diff

From 6b02746a0e29b1007efd4feb137e2da3e681fc68 Mon Sep 17 00:00:00 2001
From: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Date: Tue, 28 Sep 2021 20:11:26 +0930
Subject: [PATCH] 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.
(cherry picked from commit 0d62064867c74286360e821b75ef6799bedc4b34)
---
binutils/ar.c | 3 +++
binutils/objcopy.c | 1 +
2 files changed, 4 insertions(+)
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -1180,6 +1180,9 @@
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));
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3600,6 +3600,7 @@
if (preserve_dates)
{
+ memset (&buf, 0, sizeof (buf));
stat_status = bfd_stat_arch_elt (this_element, &buf);
if (stat_status != 0)