Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Factory:PowerPC
mingw64-binutils
reproducible.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File reproducible.patch of Package mingw64-binutils
>From bdbdaf4f9dace4ba60cb3debe9afc876a6567ffa Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de> Date: Thu, 20 Jul 2023 07:11:44 +0200 Subject: [PATCH] bfd/peXXigen.c: respect SOURCE_DATE_EPOCH environment variable Instead of obtaining the current time via time(0), use the seconds since Unix epoch stored in the SOURCE_DATE_EPOCH environment variable to create a reproducible timestamp. Signed-off-by: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de> --- bfd/peXXigen.c | 11 ++++++++++- binutils/doc/binutils.texi | 4 ++++ ld/ld.texi | 5 ++++- ld/pe-dll.c | 11 ++++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index da53f349dd0..7a5e5961162 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -838,7 +838,16 @@ _bfd_XXi_only_swap_filehdr_out (bfd * abfd, void * in, void * out) /* Use a real timestamp by default, unless the no-insert-timestamp option was chosen. */ if ((pe_data (abfd)->timestamp) == -1) - H_PUT_32 (abfd, time (0), filehdr_out->f_timdat); + { + 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, filehdr_out->f_timdat); + } else H_PUT_32 (abfd, pe_data (abfd)->timestamp, filehdr_out->f_timdat); diff --git a/ld/ld.texi b/ld/ld.texi index 75e82eda004..02ace7778d9 100644 --- a/ld/ld.texi +++ b/ld/ld.texi @@ -3569,7 +3569,10 @@ will result in slightly different images being produced each time the same sources are linked. The option @option{--no-insert-timestamp} can be used to insert a zero value for the timestamp, this ensuring that binaries produced from identical sources will compare -identically. +identically. Instead of inserting a zero value for the timestamp, +an arbitrary reproducible timestamp can be inserted by setting the +@code{SOURCE_DATE_EPOCH} environment variable to the desired number of +seconds since Unix epoch. @kindex --enable-reloc-section @item --enable-reloc-section diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 02e03d16948..e1465d4d115 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -1231,7 +1231,16 @@ 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); -- 2.40.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor