X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tools%2Ftranslate.c;h=de2da473ede18d721756b1cfa52d1c7d6766e146;hb=e627c4d0268fe9237839e68463382c2919ed59fd;hp=f85d5befbba1b86931b8d1fcce121fd9c7803b3c;hpb=c8fb3694c071ffe819509e01292b2a1520a70017;p=ia32rtools.git diff --git a/tools/translate.c b/tools/translate.c index f85d5be..de2da47 100644 --- a/tools/translate.c +++ b/tools/translate.c @@ -4,6 +4,15 @@ * * This work is licensed under the terms of 3-clause BSD license. * See COPYING file in the top-level directory. + * + * recognized asm hint comments: + * sctattr - function attributes (see code) + * sctend - force end of function/chunk + * sctpatch:

- replace current asm line with

+ * sctproto:

- prototype of ref'd function or struct + * sctref - variable is referenced, make global + * sctskip_start - start of skipped code chunk (inclusive) + * sctskip_end - end of skipped code chunk (inclusive) */ #define _GNU_SOURCE @@ -6946,7 +6955,7 @@ static void gen_func(FILE *fout, FILE *fhdr, const char *funcn, int opcnt) if (pp->arg[arg].type.is_retreg) fprintf(fout, "&%s", pp->arg[arg].reg); else if (IS(pp->arg[arg].reg, "ebp") - && !(po->flags & OPF_EBP_S)) + && g_bp_frame && !(po->flags & OPF_EBP_S)) { // rare special case fprintf(fout, "%s(u32)&sf.b[sizeof(sf)]", cast); @@ -7738,8 +7747,11 @@ static void gen_hdr_dep_pass(int i, int opcnt, unsigned char *cbits, po->regmask_dst |= 1 << xAX; dep = hg_fp_find_dep(fp, po->operand[0].name); - if (dep != NULL) + if (dep != NULL) { dep->regmask_live = regmask_save | regmask_dst; + if (g_bp_frame && !(po->flags & OPF_EBP_S)) + dep->regmask_live |= 1 << xBP; + } } else if (po->op == OP_RET) { if (po->operand_cnt > 0) { @@ -7958,7 +7970,7 @@ static void gen_hdr(const char *funcn, int opcnt) // noreturn OS functions break; } - if (ops[i].op != OP_NOP) + if (ops[i].op != OP_NOP && ops[i].op != OPP_ABORT) ferr(&ops[i], "unreachable code\n"); } @@ -8286,10 +8298,14 @@ static int ida_xrefs_show_need(FILE *fasm, char *p, long pos; p = strrchr(p, ';'); - if (p != NULL && *p == ';' && IS_START(p + 2, "DATA XREF: ")) { - p += 13; - if (is_xref_needed(p, rlist, rlist_len)) + if (p != NULL && *p == ';') { + if (IS_START(p + 2, "sctref")) return 1; + if (IS_START(p + 2, "DATA XREF: ")) { + p += 13; + if (is_xref_needed(p, rlist, rlist_len)) + return 1; + } } pos = ftell(fasm); @@ -8308,6 +8324,12 @@ static int ida_xrefs_show_need(FILE *fasm, char *p, p = strrchr(p, ';'); p += 2; + + if (IS_START(p, "sctref")) { + found_need = 1; + break; + } + // it's printed once, but no harm to check again if (IS_START(p, "DATA XREF: ")) p += 11; @@ -8501,7 +8523,7 @@ static int cmp_chunks(const void *p1, const void *p2) return strcmp(c1->name, c2->name); } -static void scan_ahead(FILE *fasm) +static void scan_ahead_for_chunks(FILE *fasm) { char words[2][256]; char line[256]; @@ -8842,7 +8864,7 @@ int main(int argc, char *argv[]) if (addr > f_addr && !scanned_ahead) { //anote("scan_ahead caused by '%s', addr %lx\n", // g_func, addr); - scan_ahead(fasm); + scan_ahead_for_chunks(fasm); scanned_ahead = 1; func_chunks_sorted = 0; }