From 070bf6f223b6cc6f3d7a6c28c1afce8c0bc8a72e Mon Sep 17 00:00:00 2001 From: lemon Date: Wed, 12 Nov 2025 17:57:54 +0100 Subject: amd64: fix positive RBP off (stack params); address encoding errata --- amd64/emit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'amd64') diff --git a/amd64/emit.c b/amd64/emit.c index 946f396..e098a81 100644 --- a/amd64/emit.c +++ b/amd64/emit.c @@ -360,7 +360,7 @@ encode(uchar **pcode, const struct desc *tab, int ntab, enum irclass k, struct o * access thru RSP (function arguments in the stack) */ mem.base = RSP; mem.disp -= 8; - } else { + } else if (mem.disp < 0) { mem.disp += rbpoff; } } @@ -387,7 +387,7 @@ encode(uchar **pcode, const struct desc *tab, int ntab, enum irclass k, struct o B(mem.shift << 6 | (mem.index & 7) << 3 | (mem.base & 7)); } if (mod == 1) B(mem.disp); - else if (mod == 2 || (mod == 0 && mem.base == RBP/*RIP-rel*/) || (mod == 0 && sib && mem.base == RSP/*absolute*/)) { + else if (mod == 2 || (mod == 0 && mem.base == RBP/*RIP-rel*/) || (mod == 0 && sib && mem.base == RBP/*absolute*/)) { I32(mem.disp); } } -- cgit v1.2.3