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