aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorJohannes Schauer Marin Rodrigues <josch@debian.org>2023-07-24 16:59:19 +0100
committerNick Clifton <nickc@redhat.com>2023-07-24 16:59:19 +0100
commit6badd1020f5bebd3f60a780b8e41a1b581046087 (patch)
tree0b1d5349acee5860922b00f2bf00c958d34b0d43 /ld
parent4701770c57af26fd410f652dc5f742a10d1c54dc (diff)
downloadgdb-6badd1020f5bebd3f60a780b8e41a1b581046087.zip
gdb-6badd1020f5bebd3f60a780b8e41a1b581046087.tar.gz
gdb-6badd1020f5bebd3f60a780b8e41a1b581046087.tar.bz2
objcopy embeds the current time and ignores SOURCE_DATE_EPOCH making the output unreproducible.
bfd * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): If inserting a timestamp, use the value held in the SOURCE_DATE_EPOCH environment variable, if it is defined. binutils * doc/binutils.texi (objcopy): Document change in behaviour of objcopy's --preserve-dates command line option. ld * pe-dll.c (fill_edata): If inserting a timestamp, use the value held in the SOURCE_DATE_EPOCH environment variable, if it is defined. * ld.texi (--insert-timestamp): Document change in behaviour.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog7
-rw-r--r--ld/ld.texi5
-rw-r--r--ld/pe-dll.c13
3 files changed, 24 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 2798849..99029f1 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2023-07-24 Johannes Schauer Marin Rodrigues <josch@debian.org>
+
+ * pe-dll.c (fill_edata): If inserting a timestamp, use the value
+ held in the SOURCE_DATE_EPOCH environment variable, if it is
+ defined.
+ * ld.texi (--insert-timestamp): Document change in behaviour.
+
2023-07-03 Nick Clifton <nickc@redhat.com>
* configure: Regenerate.
diff --git a/ld/ld.texi b/ld/ld.texi
index 75e82ed..24e9deb 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -3571,6 +3571,11 @@ can be used to insert a zero value for the timestamp, this ensuring
that binaries produced from identical sources will compare
identically.
+If @option{--insert-timestamp} is active then the time inserted is
+either the time that the linking takes place or, if the
+@code{SOURCE_DATE_EPOCH} environment variable is defined, the number
+of seconds since Unix epoch as specified by that variable.
+
@kindex --enable-reloc-section
@item --enable-reloc-section
@itemx --disable-reloc-section
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index 02e03d1..a95b85c 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -1231,7 +1231,18 @@ fill_edata (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED)
memset (edata_d, 0, edata_sz);
if (pe_data (abfd)->timestamp == -1)
- H_PUT_32 (abfd, time (0), edata_d + 4);
+ {
+ time_t now;
+ char *source_date_epoch;
+
+ source_date_epoch = getenv ("SOURCE_DATE_EPOCH");
+ if (source_date_epoch)
+ now = (time_t) strtoll (source_date_epoch, NULL, 10);
+ else
+ now = time (NULL);
+
+ H_PUT_32 (abfd, now, edata_d + 4);
+ }
else
H_PUT_32 (abfd, pe_data (abfd)->timestamp, edata_d + 4);