ref: 94fe005722a653158598a8e780ec4f9ebed71647
parent: 5df1214b19e2a69d3aff7a5924c422ff2c0dfa1c
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Jul 17 17:25:27 EDT 2023
libmach: fix RETURN and branch target for CBZ/CBNZ for arm64 (wrong sign extension)
--- a/sys/src/libmach/7db.c
+++ b/sys/src/libmach/7db.c
@@ -736,7 +736,7 @@
jumptarg(Instr *i)
{
ulong m = smask(i->op->p, 'T');
- return i->addr + sext(unshift(i->w, m), m)*4;
+ return i->addr + sext(unshift(i->w, m), nbits(m))*4;
}
static int
@@ -751,9 +751,12 @@
o = i->op->o;
if(strcmp(o, "ERET") == 0)
return -1;
-
if(strcmp(o, "RET") == 0 || strcmp(o, "BR") == 0 || strcmp(o, "BLR") == 0){
foll[0] = readreg(i, rget, 'n');
+ return 1;
+ }
+ if(strcmp(o, "RETURN") == 0){
+ foll[0] = rget(i->map, "R30");
return 1;
}
if(strcmp(o, "B") == 0 || strcmp(o, "BL") == 0){