From: Andrea Corallo Date: Wed, 25 Dec 2019 15:02:46 +0000 (+0100) Subject: never load a compilation unit without filling the func link table X-Git-Tag: emacs-28.0.90~2727^2~880 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=44db9b912f1d8165383b5b30732fa9caa3d3a185;p=emacs.git never load a compilation unit without filling the func link table --- diff --git a/src/comp.c b/src/comp.c index 6f5658191c0..9baa990061b 100644 --- a/src/comp.c +++ b/src/comp.c @@ -3113,14 +3113,19 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file, } -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, diff --git a/src/comp.h b/src/comp.h index f756e38d292..33b73548009 100644 --- a/src/comp.h +++ b/src/comp.h @@ -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 diff --git a/src/emacs.c b/src/emacs.c index 0798e0702f2..90ab7ac1e8e 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -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)