X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tools%2Ftranslate.c;h=eec360f8efaa48c60512b4b5b2cd5f495f08f03e;hb=3084511901606db82741bffafc8582ab9b7591cc;hp=2587d0688962dcfacf745c541305ed9aa0284056;hpb=56b4935896ac3b34a515016027c495c4987fce11;p=ia32rtools.git diff --git a/tools/translate.c b/tools/translate.c index 2587d06..eec360f 100644 --- a/tools/translate.c +++ b/tools/translate.c @@ -25,10 +25,6 @@ #include "my_str.h" #include "common.h" -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#define IS(w, y) !strcmp(w, y) -#define IS_START(w, y) !strncmp(w, y, strlen(y)) - #include "protoparse.h" static const char *asmfn; @@ -4066,8 +4062,7 @@ static void scan_prologue_epilogue(int opcnt) if (esp_sub) { if (ops[j].op != OP_ADD || !IS(opr_name(&ops[j], 0), "esp") - || ops[j].operand[1].type != OPT_CONST - || ops[j].operand[1].val != g_stack_fsz) + || ops[j].operand[1].type != OPT_CONST) { if (i < opcnt && ops[i].op == OP_CALL && ops[i].pp != NULL && ops[i].pp->is_noreturn) @@ -4080,8 +4075,12 @@ static void scan_prologue_epilogue(int opcnt) ferr(&ops[j], "'add esp' expected\n"); } - ops[j].flags |= OPF_RMD | OPF_DONE | OPF_NOREGS; - ops[j].operand[1].val = 0; // hack for stack arg scanner + if (ops[j].operand[1].val < g_stack_fsz) + ferr(&ops[j], "esp adj is too low (need %d)\n", g_stack_fsz); + + ops[j].operand[1].val -= g_stack_fsz; // for stack arg scanner + if (ops[j].operand[1].val == 0) + ops[j].flags |= OPF_RMD | OPF_DONE | OPF_NOREGS; found = 1; } @@ -4719,8 +4718,10 @@ static int collect_call_args_no_push(int i, struct parsed_proto *pp, ret = parse_stack_esp_offset(po, po->operand[0].name, &offset); if (ret != 0) continue; - if (offset < 0 || offset >= pp->argc_stack * 4 || (offset & 3)) - ferr(po, "bad offset %d (%d args)\n", offset, pp->argc_stack); + if (offset < 0 || offset >= pp->argc_stack * 4 || (offset & 3)) { + //ferr(po, "offset %d, %d args\n", offset, pp->argc_stack); + continue; + } arg = base_arg + offset / 4; po->p_argnext = -1;