From 3cfe907181bb616b8baeda273a5b2ea59fc8a390 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sun, 20 Jan 2019 00:19:13 +0000 Subject: [PATCH] Fix PC-relative calculations to work entirely in newspace. --- src/microcode/cmpintmd/aarch64.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/microcode/cmpintmd/aarch64.c b/src/microcode/cmpintmd/aarch64.c index 4ec526ede..01b7889cc 100644 --- a/src/microcode/cmpintmd/aarch64.c +++ b/src/microcode/cmpintmd/aarch64.c @@ -241,7 +241,9 @@ write_uuo_insns (insn_t * target, insn_t * iaddr, int pcrel) we don't know where the PC will be in the newspace. */ if ((((const int64_t *) (newspace_to_tospace (target)))[-1]) == 0) { - ptrdiff_t offset = (((uintptr_t) target) - ((uintptr_t) (&iaddr[1]))); + char * from_pc = (tospace_to_newspace ((char *) (&iaddr[1]))); + char * to_pc = ((char *) target); + ptrdiff_t offset = (to_pc - from_pc); assert ((offset & 3) == 0); if ((-0x10000000 <= offset) && (offset <= 0xfffffff)) { -- 2.25.1