Skip to content

Commit

Permalink
flambda-backend: (dynlink) port #753 #784 (#2041)
Browse files Browse the repository at this point in the history
  • Loading branch information
riaqn authored Nov 17, 2023
1 parent c9a88c7 commit 454ef16
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions runtime/dynlink_nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static value Val_handle(void* handle) {
}

static void *getsym(void *handle, const char *module, const char *name){
char *fullname = caml_stat_strconcat(4, "caml", module, ".", name);
char *fullname = caml_stat_strconcat(3, module, ".", name);
void *sym;
sym = caml_dlsym (handle, fullname);
/* printf("%s => %lx\n", fullname, (uintnat) sym); */
Expand Down Expand Up @@ -110,25 +110,27 @@ CAMLprim value caml_natdynlink_register(value handle_v, value symbols) {

for (i = 0; i < nsymbols; i++) {
const char* unit = String_val(Field(symbols, i));
table[i] = getsym(handle, unit, "frametable");
table[i] = getsym(handle, unit, "gc_roots");
if (table[i] == NULL) {
caml_stat_free(table);
caml_invalid_argument_value(
caml_alloc_sprintf("Dynlink: Missing frametable for %s", unit));
caml_alloc_sprintf("Dynlink: Missing gc_roots for %s", unit));
}
}
caml_register_frametables(table, nsymbols);
caml_register_dyn_globals(table, nsymbols);
/* [caml_register_dyn_global] can raise, so do it prior to registering
frametables etc. */

for (i = 0; i < nsymbols; i++) {
const char* unit = String_val(Field(symbols, i));
table[i] = getsym(handle, unit, "gc_roots");
table[i] = getsym(handle, unit, "frametable");
if (table[i] == NULL) {
caml_stat_free(table);
caml_invalid_argument_value(
caml_alloc_sprintf("Dynlink: Missing gc_roots for %s", unit));
caml_alloc_sprintf("Dynlink: Missing frametable for %s", unit));
}
}
caml_register_dyn_globals(table, nsymbols);
caml_register_frametables(table, nsymbols);

for (i = 0; i < nsymbols; i++) {
const char* unit = String_val(Field(symbols, i));
Expand Down

0 comments on commit 454ef16

Please sign in to comment.