From 5ba637383c459c3c89d60e6d66876da11e156595 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sun, 20 Jan 2019 21:36:42 +0000 Subject: [PATCH] Fix read/write_compiled_closure_target. Byte offsets, not object or instruction word offsets. --- src/microcode/cmpintmd/aarch64.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/microcode/cmpintmd/aarch64.c b/src/microcode/cmpintmd/aarch64.c index 01b7889cc..59dcacdec 100644 --- a/src/microcode/cmpintmd/aarch64.c +++ b/src/microcode/cmpintmd/aarch64.c @@ -130,7 +130,9 @@ read_compiled_closure_target (insn_t * start, reloc_ref_t * ref) /* If we're relocating, find where base was in the oldspace. */ if (ref) base += (ref->old_addr - ref->new_addr); - return (base + (((int64_t *) addr)[-1])); + assert (((((int64_t *) addr)[-1]) % (sizeof (insn_t))) == 0); + assert (((((int64_t *) addr)[-1]) % (sizeof (SCHEME_OBJECT))) == 0); + return ((insn_t *) (((char *) base) + (((int64_t *) addr)[-1]))); } /* write_compiled_closure_target(target, start) @@ -144,8 +146,9 @@ void write_compiled_closure_target (insn_t * target, insn_t * start) { insn_t * addr = (start + CC_ENTRY_PADDING_SIZE + CC_ENTRY_HEADER_SIZE); - (((int64_t *) addr)[-1]) = - (target - ((insn_t *) (tospace_to_newspace (addr)))); + char * from_pc = ((char *) (tospace_to_newspace (addr))); + char * to_pc = ((char *) target); + (((int64_t *) addr)[-1]) = ((int64_t) (to_pc - from_pc)); } unsigned long -- 2.25.1