]> git.eshelyaron.com Git - emacs.git/commitdiff
never load a compilation unit without filling the func link table
authorAndrea Corallo <akrl@sdf.org>
Wed, 25 Dec 2019 15:02:46 +0000 (16:02 +0100)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:38:16 +0000 (11:38 +0100)
src/comp.c
src/comp.h
src/emacs.c

index 6f5658191c0dbc5d283bb6e209188e9e51cb875c..9baa990061b53119c771ee7cedb543f975e3ace7 100644 (file)
@@ -3113,14 +3113,19 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file,
 }
 
 \f
-void
-fill_freloc (void)
+static void
+freloc_check_fill (void)
 {
+  if (freloc.size)
+    return;
+
   if (ARRAYELTS (helper_link_table) > F_RELOC_MAX_SIZE)
     goto overflow;
   memcpy (freloc.link_table, helper_link_table, sizeof (helper_link_table));
   freloc.size = ARRAYELTS (helper_link_table);
 
+  eassert (!NILP (Vcomp_subr_list));
+
   Lisp_Object subr_l = Vcomp_subr_list;
   FOR_EACH_TAIL (subr_l)
     {
@@ -3136,12 +3141,6 @@ fill_freloc (void)
   fatal ("Overflowing function relocation table, increase F_RELOC_MAX_SIZE");
 }
 
-int
-filled_freloc (void)
-{
-  return freloc.link_table[0] ? 1 : 0;
-}
-
 /******************************************************************************/
 /* Helper functions called from the run-time.                                */
 /* These can't be statics till shared mechanism is used to solve relocations. */
@@ -3217,6 +3216,8 @@ load_static_obj (dynlib_handle_ptr handle, const char *name)
 void
 load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump)
 {
+  freloc_check_fill ();
+
   dynlib_handle_ptr handle = comp_u->handle;
   struct thread_state ***current_thread_reloc =
     dynlib_sym (handle, CURRENT_THREAD_RELOC_SYM);
@@ -3303,9 +3304,6 @@ DEFUN ("native-elisp-load", Fnative_elisp_load, Snative_elisp_load, 1, 1, 0,
 {
   CHECK_STRING (file);
 
-  if (!freloc.link_table[0])
-    xsignal2 (Qnative_lisp_load_failed, file,
-             build_string ("Empty relocation table"));
   struct Lisp_Native_Comp_Unit *comp_u = allocate_native_comp_unit();
   comp_u->handle = dynlib_open (SSDATA (file));
   if (!comp_u->handle)
@@ -3430,7 +3428,8 @@ syms_of_comp (void)
               doc: /* The compiler context.  */);
   Vcomp_ctxt = Qnil;
 
-  /* FIXME should be initialized but not here... */
+  /* FIXME should be initialized but not here...  Plus this don't have
+     to be necessarily exposed to lisp but can easy debug for now.  */
   DEFVAR_LISP ("comp-subr-list", Vcomp_subr_list,
               doc: /* List of all defined subrs.  */);
   DEFVAR_LISP ("comp-sym-subr-c-name-h", Vcomp_sym_subr_c_name_h,
index f756e38d2925cece620a6462e9a412e313b8b051..33b735480090fa75a8bf5f088d38ee9592a0097e 100644 (file)
@@ -60,10 +60,5 @@ XNATIVE_COMP_UNIT (Lisp_Object a)
 extern void load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u,
                            bool loading_dump);
 extern void syms_of_comp (void);
-/* Fill the freloc structure. Must be called before any eln is loaded.  */
-extern void fill_freloc (void);
-/* Return 1 if freloc is filled or 0 otherwise.  */
-extern int filled_freloc (void);
-
 #endif
 #endif
index 0798e0702f20fbd389cbe977edbf2e1fbda09c25..90ab7ac1e8ef69d4ce90f15b8774a5b109c6119a 100644 (file)
@@ -2050,10 +2050,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
     moncontrol (0);
 #endif
 
-#ifdef HAVE_NATIVE_COMP
-  fill_freloc ();
-#endif
-
   initialized = true;
 
   if (dump_mode)