[binutils-gdb] ecoff: check result of stat

Alan Modra amodra@sourceware.org
Mon Mar 3 21:54:17 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7720707bb85f461ad5d29f1cbc49f5c9a3c5d041

commit 7720707bb85f461ad5d29f1cbc49f5c9a3c5d041
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Mar 3 14:51:18 2025 +1030

    ecoff: check result of stat
    
            * ecoff.c (_bfd_ecoff_write_armap): Don't use statbuf.st_mtime
            if stat call returns non-zero.  Use ARMAP_TIME_OFFSET rather
            than its expansion.

Diff:
---
 bfd/ecoff.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index 5f9fa43b88f..a77107b38a7 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -3132,9 +3132,9 @@ _bfd_ecoff_write_armap (bfd *abfd,
      complain that the index is out of date.  Actually, the Ultrix
      linker just checks the archive name; the GNU linker may check the
      date.  */
-  stat (bfd_get_filename (abfd), &statbuf);
-  _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
-		    (long) (statbuf.st_mtime + 60));
+  if (stat (bfd_get_filename (abfd), &statbuf) == 0)
+    _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
+		      (long) (statbuf.st_mtime + ARMAP_TIME_OFFSET));
 
   /* The DECstation uses zeroes for the uid, gid and mode of the
      armap.  */


More information about the Binutils-cvs mailing list