Skip to content

Commit 454ef16

Browse files
authored
flambda-backend: (dynlink) port #753 #784 (#2041)
1 parent c9a88c7 commit 454ef16

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

runtime/dynlink_nat.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static value Val_handle(void* handle) {
4747
}
4848

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

111111
for (i = 0; i < nsymbols; i++) {
112112
const char* unit = String_val(Field(symbols, i));
113-
table[i] = getsym(handle, unit, "frametable");
113+
table[i] = getsym(handle, unit, "gc_roots");
114114
if (table[i] == NULL) {
115115
caml_stat_free(table);
116116
caml_invalid_argument_value(
117-
caml_alloc_sprintf("Dynlink: Missing frametable for %s", unit));
117+
caml_alloc_sprintf("Dynlink: Missing gc_roots for %s", unit));
118118
}
119119
}
120-
caml_register_frametables(table, nsymbols);
120+
caml_register_dyn_globals(table, nsymbols);
121+
/* [caml_register_dyn_global] can raise, so do it prior to registering
122+
frametables etc. */
121123

122124
for (i = 0; i < nsymbols; i++) {
123125
const char* unit = String_val(Field(symbols, i));
124-
table[i] = getsym(handle, unit, "gc_roots");
126+
table[i] = getsym(handle, unit, "frametable");
125127
if (table[i] == NULL) {
126128
caml_stat_free(table);
127129
caml_invalid_argument_value(
128-
caml_alloc_sprintf("Dynlink: Missing gc_roots for %s", unit));
130+
caml_alloc_sprintf("Dynlink: Missing frametable for %s", unit));
129131
}
130132
}
131-
caml_register_dyn_globals(table, nsymbols);
133+
caml_register_frametables(table, nsymbols);
132134

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

0 commit comments

Comments
 (0)