aboutsummaryrefslogtreecommitdiffhomepage
path: root/amd64
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-11-12 17:57:54 +0100
committerlemon <lsof@mailbox.org>2025-11-12 17:57:54 +0100
commit070bf6f223b6cc6f3d7a6c28c1afce8c0bc8a72e (patch)
tree85a28c0c651f1f193495311449ad356f4188f25a /amd64
parenta592e99e7abab7978008ae13cc501d7f54d75de7 (diff)
amd64: fix positive RBP off (stack params); address encoding errata
Diffstat (limited to 'amd64')
-rw-r--r--amd64/emit.c4
1 files changed, 2 insertions, 2 deletions
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);
}
}