public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Christian Franke <Christian.Franke@t-online.de>
To: cygwin-apps@cygwin.com
Subject: [PATCH rebase 2/2] rebase: Don't update the PE header timestamp unless -t is used
Date: Sat, 12 Aug 2023 14:29:51 +0200	[thread overview]
Message-ID: <ea96781f-8552-96f4-695c-f36542a6ae41@t-online.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 110 bytes --]

This changes existing behavior but a new option --keep-timestamp is IMO 
not needed.

-- 
Regards,
Christian


[-- Attachment #2: 0001-rebase-Don-t-update-the-PE-header-timestamp-unless-t.patch --]
[-- Type: text/plain, Size: 2101 bytes --]

From 1c13ccb047ebfbcd2f239bedcd50a128fec659e9 Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.franke@t-online.de>
Date: Sat, 12 Aug 2023 14:17:04 +0200
Subject: [PATCH] rebase: Don't update the PE header timestamp unless -t is
 used

This enables reproducible rebase.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
---
 imagehelper/rebaseimage.cc | 6 ++++--
 rebase.c                   | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/imagehelper/rebaseimage.cc b/imagehelper/rebaseimage.cc
index 8827a14..0dec93c 100755
--- a/imagehelper/rebaseimage.cc
+++ b/imagehelper/rebaseimage.cc
@@ -111,12 +111,14 @@ BOOL ReBaseImage64 (
   if (dll.is64bit ())
     {
       ntheader64->OptionalHeader.ImageBase = *NewImageBase;
-      ntheader64->FileHeader.TimeDateStamp = TimeStamp;
+      if (ReBaseChangeFileTime)
+	ntheader64->FileHeader.TimeDateStamp = TimeStamp;
     }
   else
     {
       ntheader32->OptionalHeader.ImageBase = *NewImageBase;
-      ntheader32->FileHeader.TimeDateStamp = TimeStamp;
+      if (ReBaseChangeFileTime)
+	ntheader32->FileHeader.TimeDateStamp = TimeStamp;
     }
 
   int64_t difference = *NewImageBase - *OldImageBase;
diff --git a/rebase.c b/rebase.c
index 20a9902..6a531d0 100644
--- a/rebase.c
+++ b/rebase.c
@@ -1687,7 +1687,8 @@ Rebase PE files, usually DLLs, to a specified address or address range.\n\
   -o, --offset=OFFSET     Specify an additional offset between adjacent DLLs\n\
                           when rebasing.  Default is no offset.\n\
   -t, --touch             Use this option to make sure the file's modification\n\
-                          time is bumped if it has been successfully rebased.\n\
+                          time and the timestamp in the PE header are bumped if\n\
+                          the file has been successfully rebased.\n\
                           Usually rebase does not change the file's time unless\n\
                           the -c flag is also specified.\n\
   -T, --filelist=FILE     Also rebase the files specified in FILE.  The format\n\
-- 
2.39.0


                 reply	other threads:[~2023-08-12 12:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea96781f-8552-96f4-695c-f36542a6ae41@t-online.de \
    --to=christian.franke@t-online.de \
    --cc=cygwin-apps@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).