summaryrefslogtreecommitdiffstats
path: root/byterun/fix_code.c
diff options
context:
space:
mode:
Diffstat (limited to 'byterun/fix_code.c')
-rw-r--r--byterun/fix_code.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/byterun/fix_code.c b/byterun/fix_code.c
index ac519f715..67f9e96ae 100644
--- a/byterun/fix_code.c
+++ b/byterun/fix_code.c
@@ -37,15 +37,8 @@ unsigned char * caml_saved_code;
/* Read the main bytecode block from a file */
-void caml_load_code(int fd, asize_t len)
-{
- int i;
+void caml_init_code_fragments() {
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");
/* Register the code in the table of code fragments */
cf = caml_stat_alloc(sizeof(struct code_fragment));
cf->code_start = (char *) caml_start_code;
@@ -54,6 +47,17 @@ void caml_load_code(int fd, asize_t len)
cf->digest_computed = 1;
caml_ext_table_init(&caml_code_fragments_table, 8);
caml_ext_table_add(&caml_code_fragments_table, cf);
+}
+
+void caml_load_code(int fd, asize_t len)
+{
+ int i;
+
+ 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_init_code_fragments();
/* Prepare the code for execution */
#ifdef ARCH_BIG_ENDIAN
caml_fixup_endianness(caml_start_code, caml_code_size);