#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
master
Alain Frisch 2012-07-16 10:36:00 +00:00
parent e17f1f82f2
commit 95107f7bae
3 changed files with 14 additions and 8 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);