]> git.eshelyaron.com Git - emacs.git/commitdiff
fixup data relocs at load time
authorAndrea Corallo <andrea_corallo@yahoo.it>
Sun, 18 Aug 2019 14:47:43 +0000 (16:47 +0200)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:34:02 +0000 (11:34 +0100)
src/emacs-module.c

index 1ebcf19c2dabc9262954839d77d33646f2537088..7b9a5d843d0ebe628370213e4b89acbd9957eecc 100644 (file)
@@ -944,6 +944,24 @@ module_signal_or_throw (struct emacs_env_private *env)
     }
 }
 
+typedef char *(*f_comp_data_relocs) (void);
+
+static int
+comp_load_unit (dynlib_handle_ptr handle, struct emacs_runtime *rt)
+{
+  Lisp_Object *data_relocs = dynlib_sym (handle, "data_relocs");
+  f_comp_data_relocs f = dynlib_sym (handle, "text_data_relocs");
+  char *text_data_relocs = f();
+
+  Lisp_Object d_vec = Fread (build_string (text_data_relocs));
+  EMACS_UINT d_vec_len = XFIXNUM (Flength (d_vec));
+
+  for (EMACS_UINT i = 0; i < d_vec_len; i++)
+    data_relocs[i] = AREF (d_vec, i);
+
+  return 0;
+}
+
 /* Live runtime and environment objects, for assertions.  */
 static Lisp_Object Vmodule_runtimes;
 static Lisp_Object Vmodule_environments;
@@ -966,10 +984,13 @@ DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0,
   if (!gpl_sym && !native_comp)
     xsignal1 (Qmodule_not_gpl_compatible, file);
 
-  module_init = (emacs_init_function) dynlib_func (handle, "emacs_module_init");
-  if (!module_init)
-    xsignal1 (Qmissing_module_init_function, file);
-
+  if (!native_comp)
+    {
+      module_init =
+       (emacs_init_function) dynlib_func (handle, "emacs_module_init");
+      if (!module_init)
+       xsignal1 (Qmissing_module_init_function, file);
+    }
   struct emacs_runtime rt_pub;
   struct emacs_runtime_private rt_priv;
   emacs_env env_pub;
@@ -990,7 +1011,7 @@ DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0,
   ptrdiff_t count = SPECPDL_INDEX ();
   record_unwind_protect_ptr (finalize_runtime_unwind, rt);
 
-  int r = module_init (rt);
+  int r = native_comp ? comp_load_unit (handle, rt) : module_init (rt);
 
   /* Process the quit flag first, so that quitting doesn't get
      overridden by other non-local exits.  */