emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/no-purespace 4e11f9c96df 1/3: * Revert "Remove check_comp_unit_r


From: Andrea Corallo
Subject: scratch/no-purespace 4e11f9c96df 1/3: * Revert "Remove check_comp_unit_relocs"
Date: Wed, 18 Dec 2024 17:18:08 -0500 (EST)

branch: scratch/no-purespace
commit 4e11f9c96df98dd3f10c1153bc49209f2383a0ee
Author: Andrea Corallo <acorallo@gnu.org>
Commit: Andrea Corallo <acorallo@gnu.org>

    * Revert "Remove check_comp_unit_relocs"
    
    This reverts commit 81fc23b5d6a60ca4f3d269ab2c88eb9a850bac4c as the
    check is still useful but needs to be updated for the new reloc layout.
    
    * src/comp.c (check_comp_unit_relocs): Re-add.
    (load_comp_unit): Make use of.
---
 src/comp.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/comp.c b/src/comp.c
index aa24f61ac87..ac26ead08d9 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -5160,6 +5160,32 @@ load_static_obj (struct Lisp_Native_Comp_Unit *comp_u, 
const char *name)
 
 }
 
+/* Return false when something is wrong or true otherwise.  */
+
+static bool
+check_comp_unit_relocs (struct Lisp_Native_Comp_Unit *comp_u)
+{
+  dynlib_handle_ptr handle = comp_u->handle;
+  Lisp_Object *data_relocs = dynlib_sym (handle, DATA_RELOC_SYM);
+
+  EMACS_INT d_vec_len = XFIXNUM (Flength (comp_u->data_vec));
+
+  for (ptrdiff_t i = 0; i < d_vec_len; i++)
+    {
+      Lisp_Object x = data_relocs[i];
+      if (EQ (x, Qlambda_fixup))
+       return false;
+      else if (NATIVE_COMP_FUNCTIONP (x))
+       {
+         if (NILP (Fgethash (x, comp_u->lambda_gc_guard_h, Qnil)))
+           return false;
+       }
+      else if (!EQ (x, AREF (comp_u->data_vec, i)))
+       return false;
+    }
+  return true;
+}
+
 static void
 unset_cu_load_ongoing (Lisp_Object comp_u)
 {
@@ -5289,6 +5315,7 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, 
bool loading_dump,
       /* Make sure data_ephemeral_vec still exists after top_level_run has run.
         Guard against sibling call optimization (or any other).  */
       data_ephemeral_vec = data_ephemeral_vec;
+      eassert (check_comp_unit_relocs (comp_u));
     }
 
   if (!recursive_load)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]