vfasl: repairs for fcallables

A 0 relocation is used by fcallable code as a recognizable cookie, and
its relocations must be preserved.

original commit: 38fb3fdf75cf6540d6bd2568f015af6272d22995
This commit is contained in:
Matthew Flatt 2020-02-20 13:08:26 -07:00
parent aa0c555c70
commit 745482e3e4

View File

@ -1410,7 +1410,8 @@ static uptr sweep_code_object(vfasl_info *vfi, ptr co) {
} else if (IMMEDIATE(obj)) {
/* as-is */
if (Sfixnump(obj))
S_error("vfasl", "unexpected fixnum in relocation");
if (obj != FIX(0)) /* allow 0 for fcallable cookie */
S_error("vfasl", "unexpected fixnum in relocation");
} else {
obj = vfasl_relocate_help(vfi, obj);
obj = (ptr)ptr_diff(obj, vfi->base_addr);
@ -1432,7 +1433,8 @@ static void relink_code(ptr co, ptr sym_base, ptr *vspaces, uptr *vspace_offsets
t = CODERELOC(co);
t = ptr_add(vspaces[vspace_reloc], (uptr)t - vspace_offsets[vspace_reloc]);
if (to_static && !S_G.retain_static_relocation)
if (to_static && !S_G.retain_static_relocation
&& ((CODETYPE(co) & (code_flag_template << code_flags_offset)) == 0))
CODERELOC(co) = (ptr)0;
else {
CODERELOC(co) = t;
@ -1474,6 +1476,8 @@ static void relink_code(ptr co, ptr sym_base, ptr *vspaces, uptr *vspace_offsets
obj = TYPE(ptr_add(sym_base, symbol_pos_to_offset(pos)), type_symbol);
if ((val = SYMVAL(obj)) != sunbound)
obj = val;
} else if (obj == FIX(0)) {
/* leave as-is */
} else {
S_error_abort("vfasl: bad relocation tag");
}