From 9d80b13932ac474de492b96fcffcf2a509d074af Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 22 Oct 2007 03:49:19 -0400 Subject: [PATCH] Add sanity check --- vm/code_heap.c | 5 +++++ vm/debug.c | 1 + 2 files changed, 6 insertions(+) diff --git a/vm/code_heap.c b/vm/code_heap.c index fd910ef9d4..9487c7a47a 100644 --- a/vm/code_heap.c +++ b/vm/code_heap.c @@ -70,6 +70,11 @@ INLINE void reloc_set_2_2(CELL cell, CELL value) /* Store a value into a bitfield of a PowerPC instruction */ INLINE void reloc_set_masked(CELL cell, F_FIXNUM value, CELL mask, F_FIXNUM shift) { + /* This is unaccurate but good enough */ + F_FIXNUM test = (F_FIXNUM)mask >> 1; + if(value <= -test || value >= test) + critical_error("Value does not fit inside relocation",0); + u32 original = *(u32*)cell; original &= ~mask; *(u32*)cell = (original | ((value >> shift) & mask)); diff --git a/vm/debug.c b/vm/debug.c index f0d74233d1..d8cfd1c599 100755 --- a/vm/debug.c +++ b/vm/debug.c @@ -111,6 +111,7 @@ void print_stack_frame(F_STACK_FRAME *frame) printf("\n"); print_obj(frame_scan(frame)); printf("\n"); + printf("%lx\n",(CELL)frame->xt); } void print_callstack(void)