Corinna Vinschen wrote:
> ...
> Pushed.  Do you have a few more changes in the loop?  When you're
> finished, I'll release a new rebase.

The attached 0001-*.patch is the last one in the loop - I guessed. But during testing this I found the long standing bug fixed in 0002-*.patch.

That's all for now.

Thanks,
Christian

From c6e050fa69552e023d18df2cf1255a2a827f1bcc Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.fra...@t-online.de>
Date: Tue, 19 Jul 2022 10:36:20 +0200
Subject: [PATCH 1/2] Print list of DLLs which still overlap after rebasing

---
 rebase.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/rebase.c b/rebase.c
index 1f9f74b..8ca65cc 100644
--- a/rebase.c
+++ b/rebase.c
@@ -47,6 +47,7 @@ BOOL load_image_info ();
 BOOL merge_image_info ();
 BOOL collect_image_info (const char *pathname);
 void print_image_info ();
+static void print_overlapped ();
 BOOL rebase (const char *pathname, ULONG64 *new_image_base, BOOL down_flag);
 void parse_args (int argc, char *argv[]);
 unsigned long long string_to_ulonglong (const char *string);
@@ -323,6 +324,10 @@ main (int argc, char *argv[])
              }
            fprintf (stderr, "  %s\n", img_info_list[i].name);
          }
+      /* Print list of DLLs which still overlap.  This could occur if DLLs are
+        not rebaseable or if --merge-files is used incorrectly. */
+      if (img_info_size)
+       print_overlapped ();
       if (save_image_info () < 0)
        return 2;
     }
@@ -1149,6 +1154,39 @@ print_image_info ()
     }
 }
 
+static void
+print_overlapped ()
+{
+  BOOL header;
+  int i;
+  char overlaps[img_info_size];
+  memset (overlaps, 0, img_info_size);
+  qsort (img_info_list, img_info_size, sizeof (img_info_t), img_info_cmp);
+  for (header = FALSE, i = 0; i < img_info_size; ++i)
+    {
+      int j;
+      if (img_info_list[i].flag.needs_rebasing)
+       continue; /* Rebase failed. */
+      for (j = i + 1; j < img_info_size; ++j)
+       {
+         if (img_info_list[j].flag.needs_rebasing)
+           continue; /* Rebase failed. */
+         if (img_info_list[i].base + img_info_list[i].slot_size + offset
+             <= img_info_list[j].base)
+           break;
+         overlaps[i] = overlaps[j] = 1;
+       }
+      if (!overlaps[i])
+       continue;
+      if (!header)
+       {
+         fputs ("\nThe following DLLs still overlap:\n", stderr);
+         header = TRUE;
+       }
+      fprintf (stderr, "  %s\n", img_info_list[i].name);
+    }
+}
+
 BOOL
 rebase (const char *pathname, ULONG64 *new_image_base, BOOL down_flag)
 {
-- 
2.37.1

From d618ee13551b861699446f1eb0242f85a71006c6 Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.fra...@t-online.de>
Date: Tue, 19 Jul 2022 10:40:55 +0200
Subject: [PATCH 2/2] Fix index after removing missing DLL from list

---
 rebase.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/rebase.c b/rebase.c
index 8ca65cc..7417d4d 100644
--- a/rebase.c
+++ b/rebase.c
@@ -799,6 +799,7 @@ merge_image_info ()
              memmove (overlaps + i, overlaps + i + 1, img_info_size - i - 1);
              --img_info_rebase_start;
              --img_info_size;
+             --i;
              continue;
            }
          slot_size = roundup2 (cur_size, ALLOCATION_SLOT);
-- 
2.37.1

Reply via email to