X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fx86-arch.c;h=fab9d1f2a155e46c3b09804c3b266f7e09f40e95;hb=75b52379bdc2269961af6a1308eca63610f38ac3;hp=ec468cc0e4aac40fdf5ddda079041bc515673e08;hpb=e6c468c2b371f7deac2010cf03896a60974ea766;p=sbcl.git diff --git a/src/runtime/x86-arch.c b/src/runtime/x86-arch.c index ec468cc..fab9d1f 100644 --- a/src/runtime/x86-arch.c +++ b/src/runtime/x86-arch.c @@ -356,3 +356,35 @@ funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2) args[2] = arg2; return call_into_lisp(function, args, 3); } + +#ifdef LISP_FEATURE_LINKAGE_TABLE +/* FIXME: It might be cleaner to generate these from the lisp side of + * things. + */ + +void +arch_write_linkage_table_jmp(char * reloc, void * fun) +{ + /* Make JMP to function entry. JMP offset is calculated from next + * instruction. + */ + long offset = (char *)fun - (reloc + 5); + int i; + + *reloc++ = 0xe9; /* opcode for JMP rel32 */ + for (i = 0; i < 4; i++) { + *reloc++ = offset & 0xff; + offset >>= 8; + } + + /* write a nop for good measure. */ + *reloc = 0x90; +} + +void +arch_write_linkage_table_ref(void * reloc, void * data) +{ + *(unsigned long *)reloc = (unsigned long)data; +} + +#endif