[PATCH 1/1] BFD: Use SOURCE_DATE_EPOCH for COFF style armaps.

Manuel Jacob [email protected]
Wed Apr 15 21:57:31 GMT 2026


Previously, ar created archives where the files have timestamps corresponding to SOURCE_DATE_EPOCH (if set), but the armap has a timestamp corresponding to the current system time. This change ensures that the armap has a timestamp corresponding to SOURCE_DATE_EPOCH as well (if set).

Per SOURCE_DATE_EPOCH specification [1]: “Build processes MUST use this variable for embedded timestamps in place of the "current" date and time.”

This change is not relevant when deterministic mode is enabled, since in that case, the armap timestamp will be set to 0, regardless of SOURCE_DATE_EPOCH.

[1] https://reproducible-builds.org/specs/source-date-epoch/

Signed-off-by: Manuel Jacob <[email protected]>
---
 bfd/archive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bfd/archive.c b/bfd/archive.c
index db978dfea2c..44030eb3d63 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -2915,7 +2915,7 @@ _bfd_coff_write_armap (bfd *arch,
     return false;
   _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
 		    ((arch->flags & BFD_DETERMINISTIC_OUTPUT) == 0
-		     ? time (NULL) : 0));
+		     ? bfd_get_current_time (0) : 0));
   /* This, at least, is what Intel coff sets the values to.  */
   _bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", 0);
   _bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", 0);
-- 
2.53.0



More information about the Binutils mailing list