/* Functions used to load eln files. */
/**************************************/
-static Lisp_Object Vnative_elisp_refs_hash;
-
typedef char *(*comp_lit_str_func) (void);
/* Deserialize read and return static object. */
XSETSUBR (tem, &x->s);
set_symbol_function (name, tem);
+ Fputhash (name, c_name, Vsym_subr_c_name_h);
LOADHIST_ATTACH (Fcons (Qdefun, name));
return Qnil;
/* FIXME should be initialized but not here... */
DEFVAR_LISP ("comp-subr-list", Vsubr_list,
doc: /* List of all defined subrs. */);
-
- /* Load mechanism. */
- staticpro (&Vnative_elisp_refs_hash);
- Vnative_elisp_refs_hash
- = make_hash_table (hashtest_eq, DEFAULT_HASH_SIZE,
- DEFAULT_REHASH_SIZE, DEFAULT_REHASH_THRESHOLD,
- Qnil, false);
+ DEFVAR_LISP ("comp-sym-subr-c-name-h", Vsym_subr_c_name_h,
+ doc: /* Hash table symbol-function -> function-c-name. For
+ internal use during */);
+ Vsym_subr_c_name_h = CALLN (Fmake_hash_table);
}
#endif /* HAVE_NATIVE_COMP */
RELOC_DUMP_TO_DUMP_PTR_RAW,
/* dump_mpz = [rebuild bignum] */
RELOC_NATIVE_COMP_UNIT,
+ RELOC_NATIVE_SUBR,
RELOC_BIGNUM,
/* dump_lv = make_lisp_ptr (dump_lv + dump_base,
type - RELOC_DUMP_TO_DUMP_LV)
dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec);
DUMP_FIELD_COPY (&out, subr, doc);
#endif
- return dump_object_finish (ctx, &out, sizeof (out));
+
+ dump_off subr_off = dump_object_finish (ctx, &out, sizeof (out));
+ if (ctx->flags.dump_object_contents && subr->native_comp_u)
+ /* We'll do the final addr relocation during VERY_LATE_RELOCS time
+ after the compilation units has been loaded. */
+ dump_push (&ctx->dump_relocs[VERY_LATE_RELOCS],
+ list2 (make_fixnum (RELOC_NATIVE_SUBR),
+ dump_off_to_lisp (subr_off)));
+ return subr_off;
}
#ifdef HAVE_NATIVE_COMP
dump_off comp_u_off = finish_dump_pvec (ctx, &out->header);
if (ctx->flags.dump_object_contents)
- /* We'll do the real elf load during the LATE_RELOCS_1 relocation time. */
- dump_push (&ctx->dump_relocs[LATE_RELOCS_1],
+ /* We'll do the real elf load during LATE_RELOCS relocation time. */
+ dump_push (&ctx->dump_relocs[LATE_RELOCS],
list2 (make_fixnum (RELOC_NATIVE_COMP_UNIT),
dump_off_to_lisp (comp_u_off)));
return comp_u_off;
if (!comp_u->handle)
error ("%s", dynlib_error ());
load_comp_unit (comp_u, true);
+ break;
+ }
+ case RELOC_NATIVE_SUBR:
+ {
+ struct Lisp_Subr *subr = dump_ptr (dump_base, reloc_offset);
+ Lisp_Object name = intern (subr->symbol_name);
+ struct Lisp_Native_Comp_Unit *comp_u =
+ XNATIVE_COMP_UNIT (subr->native_comp_u);
+ if (!comp_u->handle)
+ error ("can't relocate native subr with not loaded compilation unit");
+ Lisp_Object c_name = Fgethash (name, Vsym_subr_c_name_h, Qnil);
+ if (NILP (c_name))
+ error ("missing label name");
+ void *func = dynlib_sym (comp_u->handle, SSDATA (c_name));
+ if (!func)
+ error ("can't function in compilation unit");
+ subr->function.a0 = func;
+ break;
}
- break;
case RELOC_BIGNUM:
{
struct Lisp_Bignum *bignum = dump_ptr (dump_base, reloc_offset);