diff options
author | Alain Frisch <alain@frisch.fr> | 2012-07-16 10:36:00 +0000 |
---|---|---|
committer | Alain Frisch <alain@frisch.fr> | 2012-07-16 10:36:00 +0000 |
commit | 95107f7baecf20457f8b8ef40fcd40dec57a7e31 (patch) | |
tree | f2ee30f0a232851a4068974dd26bca1960175966 | |
parent | e17f1f82f251d0bf645f440d3c78ba8811902b04 (diff) | |
download | ocaml-95107f7baecf20457f8b8ef40fcd40dec57a7e31.tar.gz |
#5687: Fix dynlink when used from output-obj'ed main bytecode program.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12714 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | byterun/fix_code.c | 20 | ||||
-rw-r--r-- | byterun/fix_code.h | 1 | ||||
-rw-r--r-- | byterun/startup.c | 1 |
3 files changed, 14 insertions, 8 deletions
diff --git a/byterun/fix_code.c b/byterun/fix_code.c index ac519f7156..67f9e96ae2 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); diff --git a/byterun/fix_code.h b/byterun/fix_code.h index d0887c0385..05f9ae060b 100644 --- a/byterun/fix_code.h +++ b/byterun/fix_code.h @@ -27,6 +27,7 @@ extern code_t caml_start_code; extern asize_t caml_code_size; extern unsigned char * caml_saved_code; +void caml_init_code_fragments(); void caml_load_code (int fd, asize_t len); void caml_fixup_endianness (code_t code, asize_t len); void caml_set_instruction (code_t pos, opcode_t instr); diff --git a/byterun/startup.c b/byterun/startup.c index 6fdba1617c..8298fe83ff 100644 --- a/byterun/startup.c +++ b/byterun/startup.c @@ -477,6 +477,7 @@ CAMLexport void caml_startup_code( /* Load the code */ caml_start_code = code; caml_code_size = code_size; + caml_init_code_fragments(); if (caml_debugger_in_use) { int len, i; len = code_size / sizeof(opcode_t); |