diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2012-03-13 14:50:41 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2012-03-13 14:50:41 +0000 |
commit | 4e5eb94ed9822d5d6051b11ce3bb2c83450cbdce (patch) | |
tree | f018cf1ac332069274f227400525a22ef58adeb8 /byterun/fix_code.c | |
parent | e50091b8e720e76fa7ed9fa0940335b4c9b24ff1 (diff) |
PR#5215: Marshalling of closures now supported if the closures come from dynamically-loaded code.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12229 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/fix_code.c')
-rw-r--r-- | byterun/fix_code.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/byterun/fix_code.c b/byterun/fix_code.c index 7a8f1ffa5..27e715be1 100644 --- a/byterun/fix_code.c +++ b/byterun/fix_code.c @@ -24,6 +24,7 @@ #include "debugger.h" #include "fix_code.h" #include "instruct.h" +#include "intext.h" #include "md5.h" #include "memory.h" #include "misc.h" @@ -40,15 +41,21 @@ unsigned char caml_code_md5[16]; void caml_load_code(int fd, asize_t len) { int i; - struct MD5Context ctx; + struct code_fragment * cf; caml_code_size = len; caml_start_code = (code_t) caml_stat_alloc(caml_code_size); if (read(fd, (char *) caml_start_code, caml_code_size) != caml_code_size) caml_fatal_error("Fatal error: truncated bytecode file.\n"); - caml_MD5Init(&ctx); - caml_MD5Update(&ctx, (unsigned char *) caml_start_code, caml_code_size); - caml_MD5Final(caml_code_md5, &ctx); + /* Register the code in the table of code fragments */ + cf = caml_stat_alloc(sizeof(struct code_fragment)); + cf->code_start = (char *) caml_start_code; + cf->code_end = (char *) caml_start_code + caml_code_size; + caml_md5_block(cf->digest, caml_start_code, caml_code_size); + cf->digest_computed = 1; + caml_ext_table_init(&caml_code_fragments_table, 8); + caml_ext_table_add(&caml_code_fragments_table, cf); + /* Prepare the code for execution */ #ifdef ARCH_BIG_ENDIAN caml_fixup_endianness(caml_start_code, caml_code_size); #endif |