From f13844b4960f00eeb9d6ea2d73fcdc21035f0e98 Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Fri, 9 Jul 2010 18:11:27 +0430 Subject: [PATCH] gen: don't overwrite pushed ebx, esi and edi --- gen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gen.c b/gen.c index 652845c..07d4d24 100644 --- a/gen.c +++ b/gen.c @@ -523,8 +523,8 @@ long o_func_beg(char *name, int global) os("\x55", 1); /* push %rbp */ os("\x89\xe5", 2); /* mov %rsp, %rbp */ os("\x53\x56\x57", 3); /* push ebx; push esi; push edi */ - sp = 0; - maxsp = 0; + sp = 3 * LONGSZ; + maxsp = sp; ntmp = 0; tmpsp = -1; nret = 0; @@ -668,7 +668,7 @@ void o_func_end(void) o_filljmp(ret[i]); os("\x5f\x5e\x5b", 3); /* pop edi; pop esi; pop ebx */ os("\xc9\xc3", 2); /* leave; ret; */ - putint(buf + spsub_addr, ALIGN(maxsp, LONGSZ), 4); + putint(buf + spsub_addr, ALIGN(maxsp - 3 * LONGSZ, LONGSZ), 4); out_func_end(buf, cur - buf); } -- 2.11.4.GIT