[rebase - The rebase tool, core of the automatic rebase facility during postinstall] branch master, updated. fb5cf7cb863c8b64c6d8985cfe663f8c30178c7b
Corinna Vinschen
corinna@sourceware.org
Tue Aug 8 18:11:24 GMT 2023
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/rebase.git;h=fb5cf7cb863c8b64c6d8985cfe663f8c30178c7b
commit fb5cf7cb863c8b64c6d8985cfe663f8c30178c7b
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Tue Aug 8 20:10:37 2023 +0200
Bump to version 4.6.5
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/rebase.git;h=f1d249ba44a4d7d763596720448d2f6ff901518e
commit f1d249ba44a4d7d763596720448d2f6ff901518e
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Tue Aug 8 20:10:04 2023 +0200
bump autoconf dependency to latest autoconf 2.71
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/rebase.git;h=72ca3108e541b7705d12d5d9086751b07ea7c473
commit 72ca3108e541b7705d12d5d9086751b07ea7c473
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Tue Aug 8 20:01:57 2023 +0200
drop precomposed setup.hint
The .hint file gets autogenerated anyway these days.
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/rebase.git;h=3257915f4db88eadcb617673f84ebbb39bb186fa
commit 3257915f4db88eadcb617673f84ebbb39bb186fa
Author: Christian Franke <christian.franke@t-online.de>
Date: Tue Aug 8 12:04:25 2023 +0200
rebase: Add -c, --checksum option
If specified, the file checksum in the PE header is updated after
rebasing.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/rebase.git;h=645e4100bcb27d5cdc6314df46495eecfd967317
commit 645e4100bcb27d5cdc6314df46495eecfd967317
Author: Christian Franke <christian.franke@t-online.de>
Date: Tue Aug 8 10:52:14 2023 +0200
Add missing pechecksum.* to SRC_DISTFILES
Signed-off-by: Christian Franke <christian.franke@t-online.de>
Diff:
---
Makefile.in | 9 +++++----
configure.ac | 4 ++--
rebase.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++----
setup.hint | 6 ------
4 files changed, 53 insertions(+), 16 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 46df1d54a8e9..e7b7f6acfa76 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -74,7 +74,7 @@ override CXX_LDFLAGS+=@EXTRA_CXX_LDFLAG_OVERRIDES@
LIBIMAGEHELPER = imagehelper/libimagehelper.a
-REBASE_OBJS = rebase.$(O) rebase-db.$(O) $(LIBOBJS)
+REBASE_OBJS = rebase.$(O) rebase-db.$(O) pechecksum.$(O) $(LIBOBJS)
REBASE_LIBS = $(LIBIMAGEHELPER)
REBASE_DUMP_OBJS = rebase-dump.$(O) rebase-db.$(O) $(LIBOBJS)
@@ -84,8 +84,9 @@ PEFLAGS_OBJS = peflags.$(O) pechecksum.$(O) $(LIBOBJS)
PEFLAGS_LIBS =
SRC_DISTFILES = configure.ac configure Makefile.in \
- peflagsall.in rebaseall.in peflags.c rebase.c \
- build.sh ChangeLog COPYING NEWS README setup.hint Todo \
+ peflagsall.in rebaseall.in \
+ pechecksum.c pechecksum.h peflags.c rebase.c \
+ build.sh ChangeLog COPYING NEWS README Todo \
build-aux/config.guess build-aux/config.sub \
build-aux/install-sh getopt.h_ getopt_long.c \
rebase-db.c rebase-db.h rebase-dump.c strtoll.c
@@ -99,7 +100,7 @@ $(LIBIMAGEHELPER):
rebase$(EXEEXT): $(REBASE_LIBS) $(REBASE_OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(CXX_LDFLAGS) -o $@ $(REBASE_OBJS) $(REBASE_LIBS)
-rebase.$(O):: rebase.c rebase-db.h Makefile
+rebase.$(O):: rebase.c pechecksum.h rebase-db.h Makefile
rebase-db.$(O):: rebase-db.c rebase-db.h Makefile
diff --git a/configure.ac b/configure.ac
index dee836b628ec..071606864743 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,8 +1,8 @@
# -*- autoconf -*- vim: filetype=config
# configure.ac for rebase
-AC_PREREQ([2.64])
-AC_INIT([rebase], [4.6.4], [cygwin@cygwin.com])
+AC_PREREQ([2.71])
+AC_INIT([rebase], [4.6.5], [cygwin@cygwin.com])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_SRCDIR([peflags.c])
AC_PREFIX_DEFAULT([/usr])
diff --git a/rebase.c b/rebase.c
index 7417d4d054cc..50cc79f8b9f7 100644
--- a/rebase.c
+++ b/rebase.c
@@ -39,6 +39,7 @@
#include <errno.h>
#include <io.h>
#include "imagehelper.h"
+#include "pechecksum.h"
#include "rebase-db.h"
#include <versionhelpers.h> /* requires <windows.h> */
@@ -74,6 +75,7 @@ WORD machine = IMAGE_FILE_MACHINE_I386;
ULONG64 image_base = 0;
ULONG64 low_addr;
BOOL down_flag = FALSE;
+BOOL checksum_flag = FALSE;
BOOL image_info_flag = FALSE;
BOOL image_storage_flag = FALSE;
BOOL image_oblivious_flag = FALSE;
@@ -1188,6 +1190,32 @@ print_overlapped ()
}
}
+static BOOL
+update_checksum (const char *pathname)
+{
+ int fd, err;
+ unsigned old_checksum, new_checksum;
+
+ if ((fd = open (pathname, O_RDWR | O_BINARY)) == -1)
+ {
+ fprintf (stderr, "%s: failed to reopen for checksum update: %s\n",
+ pathname, strerror (errno));
+ return FALSE;
+ }
+ new_checksum = pe32_checksum (fd, 1, &old_checksum);
+ err = errno;
+ close(fd);
+ if (!new_checksum)
+ {
+ fprintf (stderr, "%s: checksum update failed: %s\n", pathname,
+ strerror (err));
+ /* Assume file is unchanged. */
+ return FALSE;
+ }
+
+ return (new_checksum != old_checksum);
+}
+
BOOL
rebase (const char *pathname, ULONG64 *new_image_base, BOOL down_flag)
{
@@ -1279,13 +1307,18 @@ retry:
}
#endif
+ /* Update checksum, if requested. */
+ status = (checksum_flag ? update_checksum (pathname) : FALSE);
+
/* Display rebase results, if verbose. */
if (verbose)
{
- printf ("%s: new base = %" PRIx64 ", new size = %x\n",
+ printf ("%s: new base = %" PRIx64 ", new size = %x%s\n",
pathname,
(uint64_t) ((down_flag) ? *new_image_base : prev_new_image_base),
- (uint32_t) (new_image_size + offset));
+ (uint32_t) (new_image_size + offset),
+ (checksum_flag ? (status ? ", checksum updated" :
+ ", checksum unchanged") : ""));
}
/* Calculate next base address, if rebasing up. */
@@ -1299,6 +1332,7 @@ static struct option long_options[] = {
{"32", no_argument, NULL, '4'},
{"64", no_argument, NULL, '8'},
{"base", required_argument, NULL, 'b'},
+ {"checksum", no_argument, NULL, 'c'},
{"down", no_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
{"usage", no_argument, NULL, 'h'},
@@ -1316,7 +1350,7 @@ static struct option long_options[] = {
{NULL, no_argument, NULL, 0 }
};
-static const char *short_options = "48b:dhiMno:OqstT:vV";
+static const char *short_options = "48b:cdhiMno:OqstT:vV";
void
parse_args (int argc, char *argv[])
@@ -1341,6 +1375,9 @@ parse_args (int argc, char *argv[])
image_base = string_to_ulonglong (optarg);
force_rebase_flag = TRUE;
break;
+ case 'c':
+ checksum_flag = TRUE;
+ break;
case 'd':
down_flag = TRUE;
break;
@@ -1625,6 +1662,10 @@ Rebase PE files, usually DLLs, to a specified address or address range.\n\
One of the options -b, -s or -i is mandatory. If no rebase database exists\n\
yet, -b is required together with -s.\n\
\n\
+ -c, --checksum Update the file's checksum in the PE header if the\n\
+ file has been successfully rebased. This also bumps\n\
+ the file's modification time (like -t) if the\n\
+ checksum has been changed.\n\
-d, --down Treat the BaseAddress as upper ceiling and rebase\n\
files top-down from there. Without this option the\n\
files are rebased from BaseAddress bottom-up.\n\
@@ -1634,7 +1675,8 @@ Rebase PE files, usually DLLs, to a specified address or address range.\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\
- Usually rebase does not change the file's time.\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\
of FILE is one DLL per line.\n\
-q, --quiet Be quiet about non-critical issues.\n\
diff --git a/setup.hint b/setup.hint
deleted file mode 100644
index f6f6d72eff66..000000000000
--- a/setup.hint
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id$
-sdesc: "utilities for rebasing DLLs to load at alternate addresses"
-ldesc: "This package contains the Cygwin rebase utilities. Use rebase for
-specific DLLs or rebaseall for all DLLs installed by Cygwin's setup.exe."
-category: System Utils Base
-requires: dash cygwin coreutils grep gzip sed
More information about the Cygwin-apps-cvs
mailing list