# HG changeset patch # User William Astle # Date 1519886112 25200 # Node ID 51bed8c8dc5334c5308f16894043ba2379367638 # Parent 7370a67caf7e7881d1fd5a2d11d78add3dd553e9 Actually check if we resolved a PCR reference before assuming 8 bits You actually need to check if an expression collapsed to an integer before assuming it is one. Otherwise, you end up assuming everything is 8 bit offsets. Oops. diff -r 7370a67caf7e -r 51bed8c8dc53 lwasm/insn_indexed.c --- a/lwasm/insn_indexed.c Wed Feb 28 23:31:17 2018 -0700 +++ b/lwasm/insn_indexed.c Wed Feb 28 23:35:12 2018 -0700 @@ -588,15 +588,18 @@ as -> pretendmax = 1; lwasm_reduce_expr(as, e2); as -> pretendmax = v; - v = lw_expr_intval(e2); - // Actual range is -128 <= offset <= 127; we're allowing a fudge - // factor of 25 or so bytes so that we're less likely to accidentally - // cross into the 16 bit boundary in weird corner cases. - if (v >= -100 || v <= 100) + if (lw_expr_istype(e2, lw_expr_type_int)) { - l -> lint = 1; - l -> pb = (l -> pb & 0x80) ? 0x9C : 0x8C; - return; + v = lw_expr_intval(e2); + // Actual range is -128 <= offset <= 127; we're allowing a fudge + // factor of 25 or so bytes so that we're less likely to accidentally + // cross into the 16 bit boundary in weird corner cases. + if (v >= -100 || v <= 100) + { + l -> lint = 1; + l -> pb = (l -> pb & 0x80) ? 0x9C : 0x8C; + return; + } } } }