- Fixes warning when running strip on an object file (#2114597)

This commit is contained in:
yahmad 2022-08-10 20:20:47 +02:00
parent a95926d240
commit da676ef767
2 changed files with 57 additions and 1 deletions

View File

@ -0,0 +1,49 @@
From 0d62064867c74286360e821b75ef6799bedc4b34 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.
---
binutils/ar.c | 3 +++
binutils/objcopy.c | 1 +
2 files changed, 4 insertions(+)
diff --git a/binutils/ar.c b/binutils/ar.c
index 5d6976c7027..8885585ef75 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));
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index a6c2e0dcc26..fd7557fe433 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3600,6 +3600,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
if (preserve_dates)
{
+ memset (&buf, 0, sizeof (buf));
stat_status = bfd_stat_arch_elt (this_element, &buf);
if (stat_status != 0)
--
2.37.1

View File

@ -39,7 +39,7 @@
Summary: A GNU collection of binary utilities
Name: binutils%{?name_cross}%{?_with_debug:-debug}
Version: 2.37
Release: 23%{?dist}
Release: 24%{?dist}
License: GPLv3+
URL: https://sourceware.org/binutils
@ -333,6 +333,10 @@ Patch30: binutils-update-linker-manual.patch
# Purpose: Add a --package-metadata option to the linkers.
# Lifetime: Fixed in 2.39 (for ld.bfd)
Patch31: binutils-package-metadata.patch
# Purpose: Fixes warning when running strip on an object file
# Lifetime: Fixed in 2.38
Patch32: binutils-strip-objcopy-preserve-dates.patch
#----------------------------------------------------------------------------
Provides: bundled(libiberty)
@ -951,6 +955,9 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Wed Aug 10 2022 Yara Ahmad <yahmad@redhat.com> - 2.37-24
- Fixes warning when running strip on an object file (#2114597)
* Fri Aug 05 2022 Yara Ahmad <yahmad@redhat.com> - 2.37-23
- Add the --package-metadata option to the linkers. (#2099999)