[rebase - The rebase tool, core of the automatic rebase facility during postinstall] branch master, updated. 2b306dafb760311b04633e611e9931ed638ad15b
corinna@sourceware.org
corinna@sourceware.org
Thu Jan 11 22:09:00 GMT 2018
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/rebase.git;h=2b306dafb760311b04633e611e9931ed638ad15b
commit 2b306dafb760311b04633e611e9931ed638ad15b
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Thu Jan 11 23:07:57 2018 +0100
Bump to version 4.4.4
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/rebase.git;h=bfd38364751b12596cf6d987ebcf7e4a7b595980
commit bfd38364751b12596cf6d987ebcf7e4a7b595980
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Thu Jan 11 23:07:34 2018 +0100
rework check if DLLs fit into memory
* new function check_base_address_sanity, called min loop
when trying to evaluate new address for a DLL, as well
as checking validity of start address parameter.
* Check for invalid `end' index only where it can occur.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/rebase.git;h=f5eb52bf39fb64e45282adf6afbe78371989631a
commit f5eb52bf39fb64e45282adf6afbe78371989631a
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Thu Jan 11 17:09:15 2018 +0100
Patch "out of available DLL slots" patch
Commit a7d415a25c1b902a98dbc2b0e2fd8928b58e3f61 introduced
a typo which handled the completly innocent situation of
reaching the first array member (end ==0) as error. Fix this
and only handle indices < 0 as out of slot error.
Also, on 64 bit, don't allow rebasing DLLs beneath the Cygwin
DLL address since that's reserved for stacks anyway.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/rebase.git;h=f7fcd7485c3da8483e20315d72fb9ac05e3fcc92
commit f7fcd7485c3da8483e20315d72fb9ac05e3fcc92
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Thu Jan 11 17:01:50 2018 +0100
merge_image_info: clear up usage of new_base
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/rebase.git;h=ea650bfc9262f44de24667f8c96ccb775f7bdf77
commit ea650bfc9262f44de24667f8c96ccb775f7bdf77
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Thu Jan 11 17:01:23 2018 +0100
add tags to .gitignore
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
.gitignore | 1 +
configure.ac | 2 +-
rebase.c | 77 +++++++++++++++++++++++++++++++++++++++++++--------------
3 files changed, 60 insertions(+), 20 deletions(-)
diff --git a/.gitignore b/.gitignore
index c153367..4a8b601 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
autom4te.cache
configure
+tags
diff --git a/configure.ac b/configure.ac
index 4c20bde..1dc9bf4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
# configure.ac for rebase
AC_PREREQ([2.64])
-AC_INIT([rebase], [4.4.3], [cygwin@cygwin.com])
+AC_INIT([rebase], [4.4.4], [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 5b52f76..6f98d37 100644
--- a/rebase.c
+++ b/rebase.c
@@ -67,6 +67,7 @@ WORD machine = IMAGE_FILE_MACHINE_AMD64;
WORD machine = IMAGE_FILE_MACHINE_I386;
#endif
ULONG64 image_base = 0;
+ULONG64 low_addr;
BOOL down_flag = FALSE;
BOOL image_info_flag = FALSE;
BOOL image_storage_flag = FALSE;
@@ -116,6 +117,30 @@ ULONG cygwin_dll_image_size = 0;
#define LONG_PATH_MAX 32768
+int
+check_base_address_sanity (ULONG64 addr, BOOL at_start)
+{
+#if defined(__CYGWIN__) || defined(__MSYS__)
+ /* Sanity checks for Cygwin:
+ *
+ * - No DLLs below 0x38000000 on 32 bit, W10 1703+ rebase those on
+ * runtime anyway
+ * - No DLLs below 0x2:00000000, ever, on 64 bit.
+ */
+ if (addr <= low_addr)
+ {
+ if (at_start)
+ fprintf (stderr, "%s: Invalid Baseaddress 0x%" PRIx64 ", must be > 0x%" PRIx64 "\n",
+ progname, (uint64_t) addr, (uint64_t) low_addr);
+ else
+ fprintf (stderr, "%s: Too many DLLs for available address space: %s\n",
+ progname, strerror (ENOMEM));
+ return -1;
+ }
+#endif
+ return 0;
+}
+
void
gen_progname (const char *arg0)
{
@@ -743,7 +768,7 @@ merge_image_info ()
end = img_info_size - 1;
while (img_info_list[0].base == 0)
{
- ULONG64 new_base;
+ ULONG64 new_base = 0;
/* Skip trailing entries as long as there is no hole. */
while (end > 0
@@ -753,28 +778,26 @@ merge_image_info ()
floating_image_base = img_info_list[end].base;
--end;
}
- /* No hole? We're in serious trouble! */
- if (end <= 0)
- {
- fprintf (stderr,
- "%s: Too many DLLs for available address space: %s\n",
- progname, strerror (ENOMEM));
- return -1;
- }
+
/* Test if one of the DLLs with address 0 fits into the hole. */
- for (i = 0, new_base = 0; img_info_list[i].base == 0; ++i, new_base = 0)
+ for (i = 0; img_info_list[i].base == 0; ++i)
{
- new_base = floating_image_base - img_info_list[i].slot_size - offset;
- if (new_base >= img_info_list[end].base
- + img_info_list[end].slot_size
+ ULONG64 base = floating_image_base - img_info_list[i].slot_size
+ - offset;
+ /* Check if address is still valid */
+ if (check_base_address_sanity (base, FALSE))
+ return -1;
+ if (base >= img_info_list[end].base + img_info_list[end].slot_size
#if defined(__CYGWIN__) || defined(__MSYS__)
/* Don't overlap the Cygwin/MSYS DLL. */
- && (new_base >= cygwin_dll_image_base + cygwin_dll_image_size
- || new_base + img_info_list[i].slot_size
- <= cygwin_dll_image_base)
+ && (base >= cygwin_dll_image_base + cygwin_dll_image_size
+ || base + img_info_list[i].slot_size <= cygwin_dll_image_base)
#endif
)
- break;
+ {
+ new_base = base;
+ break;
+ }
}
/* Found a match. Mount into list. */
if (new_base)
@@ -791,12 +814,18 @@ merge_image_info ()
#if defined(__CYGWIN__) || defined(__MSYS__)
if (floating_image_base >= cygwin_dll_image_base + cygwin_dll_image_size
&& img_info_list[end].base < cygwin_dll_image_base)
- floating_image_base = cygwin_dll_image_base;
+ floating_image_base = cygwin_dll_image_base;
else
#endif
{
floating_image_base = img_info_list[end].base;
- --end;
+ if (--end < 0)
+ {
+ fprintf (stderr,
+ "%s: Too many DLLs for available address space: %s\n",
+ progname, strerror (ENOMEM));
+ return -1;
+ }
}
}
@@ -1219,6 +1248,16 @@ parse_args (int argc, char *argv[])
exit (1);
}
+ /* The low address for 32 bit is extremly low, and apparently
+ W10 1703 and later rebase all DLLs with start addresses < 0x38000000
+ at runtime. However, we have so many DLLs that a hardcoded lowest
+ address of 0x38000000 is just not feasible. */
+ low_addr = (machine == IMAGE_FILE_MACHINE_I386) ? 0x001000000ULL
+ : 0x200000000ULL;
+
+ if (image_base && check_base_address_sanity (image_base, TRUE) < 0)
+ exit (1);
+
args_index = optind;
/* Initialize db_file and tmp_file from pattern */
More information about the Cygwin-apps-cvs
mailing list