const char *s1 = p1->name, *s2 = p2->name;
int i;
+ if (*s1 == '_')
+ s1++;
+ if (*s2 == '_')
+ s2++;
+
for (i = 0; ; i++) {
if ((s1[i] | s2[i]) == 0)
break;
*cnt = c;
}
-const char *sym_use(const struct sl_item *sym)
+const char *sym_use(const struct sl_item *sym, int is_rm)
{
static char buf[256+3];
int ret;
- ret = snprintf(buf, sizeof(buf), "rm_%s", sym->name);
+ ret = snprintf(buf, sizeof(buf), "%s%s",
+ is_rm ? "rm_" : "", sym->name);
if (ret >= sizeof(buf)) {
printf("truncation detected: '%s'\n", buf);
exit(1);
sizeof(symlist[0]), cmp_sym);
if (sym != NULL) {
sym->found = 1;
- fprintf(fout, "rm_%s\t%s%s", word, word2, p);
+ fprintf(fout, "%s\t%s%s", sym_use(sym, 1), word2, p);
continue;
}
}
ssym.name = word2;
sym = bsearch(&ssym, symlist, symlist_cnt,
sizeof(symlist[0]), cmp_sym);
- if (sym != NULL
- && (sym->callsites || IS(word2, func)))
- {
+ if (sym != NULL) {
fprintf(fout, "\t\t%s\t%s%s", word,
- sym_use(sym), p);
+ sym_use(sym, sym->callsites || IS(word2, func)), p);
continue;
}
}
sym = bsearch(&ssym, symlist, symlist_cnt,
sizeof(symlist[0]), cmp_sym);
if (sym != NULL) {
- fprintf(fout, "\t\tpublic %s%s", sym_use(sym), p);
+ fprintf(fout, "\t\tpublic %s%s", sym_use(sym, 1), p);
continue;
}
}
// push offset <sym>
// jcc short <sym>
if ( (IS(word, "push") && IS(word2, "offset"))
- || (word[0] == 'j' && IS(word2, "short")) ) {
+ || (word[0] == 'j' && IS(word2, "short") && !IS(word3, "exit")) ) {
ssym.name = word3;
sym = bsearch(&ssym, symlist, symlist_cnt,
sizeof(symlist[0]), cmp_sym);
- if (sym != NULL
- && (sym->callsites || IS(word3, func)))
- {
- fprintf(fout, "\t\t%s %s %s%s",
- word, word2, sym_use(sym), p);
+ if (sym != NULL) {
+ fprintf(fout, "\t\t%s %s %s%s", word, word2,
+ sym_use(sym, sym->callsites || IS(word3, func)), p);
continue;
}
}
ssym.name = word4;
sym = bsearch(&ssym, symlist, symlist_cnt,
sizeof(symlist[0]), cmp_sym);
- if (sym != NULL && sym->callsites) {
+ if (sym != NULL) {
fprintf(fout, "\t\t%s\t%s %s %s%s",
word, word2, word3,
- sym_use(sym), p);
+ sym_use(sym, sym->callsites), p);
continue;
}
}
ssym.name = word6;
sym = bsearch(&ssym, symlist, symlist_cnt,
sizeof(symlist[0]), cmp_sym);
- if (sym != NULL && sym->callsites) {
+ if (sym != NULL) {
fprintf(fout, "\t\t%s\tdword ptr %s offset %s%s",
- word, word4, sym_use(sym), p);
+ word, word4, sym_use(sym, sym->callsites), p);
continue;
}
}
sym = bsearch(&ssym, symlist, symlist_cnt,
sizeof(symlist[0]), cmp_sym);
fprintf(fout, " offset %s%s",
- (sym != NULL && sym->callsites) ? sym_use(sym) : word,
+ (sym != NULL) ? sym_use(sym, sym->callsites) : word,
p2 ? "," : "");
}
fprintf(fout, "%s", p);
}
}
-static void check_label_read_ref(struct parsed_op *po, const char *name)
+static const char *check_label_read_ref(struct parsed_op *po,
+ const char *name)
{
const struct parsed_proto *pp;
if (pp->is_func)
check_func_pp(po, pp, "ref");
+
+ return pp->name;
}
static char *out_src_opr(char *buf, size_t buf_size,
{
char tmp1[256], tmp2[256];
char expr[256];
+ const char *name;
char *p;
int ret;
break;
case OPT_LABEL:
- check_label_read_ref(po, popr->name);
+ name = check_label_read_ref(po, popr->name);
if (cast[0] == 0 && popr->is_ptr)
cast = "(u32)";
if (is_lea)
- snprintf(buf, buf_size, "(u32)&%s", popr->name);
+ snprintf(buf, buf_size, "(u32)&%s", name);
else if (popr->size_lt)
snprintf(buf, buf_size, "%s%s%s%s", cast,
lmod_cast_u_ptr(po, popr->lmod),
- popr->is_array ? "" : "&",
- popr->name);
+ popr->is_array ? "" : "&", name);
else
- snprintf(buf, buf_size, "%s%s%s", cast, popr->name,
+ snprintf(buf, buf_size, "%s%s%s", cast, name,
popr->is_array ? "[0]" : "");
break;
case OPT_OFFSET:
- check_label_read_ref(po, popr->name);
+ name = check_label_read_ref(po, popr->name);
if (cast[0] == 0)
cast = "(u32)";
if (is_lea)
ferr(po, "lea an offset?\n");
- snprintf(buf, buf_size, "%s&%s", cast, popr->name);
+ snprintf(buf, buf_size, "%s&%s", cast, name);
break;
case OPT_CONST: