unsigned int is_fastcall:1;
unsigned int is_vararg:1; // vararg func
unsigned int is_fptr:1;
+ unsigned int is_import:1; // data import
unsigned int is_noreturn:1;
unsigned int is_unresolved:1;
+ unsigned int is_guessed:1; // for extra checking
unsigned int is_userstack:1;
unsigned int is_include:1; // not from top-level header
unsigned int is_osinc:1; // OS/system library func
if (ret < 0)
return -1;
+ if (IS_START(arg->pp->name, "guess"))
+ arg->pp->is_guessed = 1;
+
// we don't use actual names right now...
snprintf(arg->pp->name, sizeof(arg->pp->name), "a%d", xarg);
p = sskip(p + l + 1);
}
+ if (IS_START(p, "DECL_IMPORT ")) {
+ pp->is_import = 1;
+ p = sskip(p + 12);
+ }
+
ret = check_type(p, &pp->ret_type);
if (ret <= 0) {
printf("%s:%d:%zd: unhandled return in '%s'\n",
}
static const char *check_label_read_ref(struct parsed_op *po,
- const char *name)
+ const char *name, int *is_import)
{
const struct parsed_proto *pp;
if (pp->is_func)
check_func_pp(po, pp, "ref");
+ if (is_import != NULL)
+ *is_import = pp->is_import;
+
return pp->name;
}
char tmp1[256], tmp2[256];
char expr[256];
const char *name;
+ int is_import = 0;
char *p;
int ret;
break;
case OPT_LABEL:
- name = check_label_read_ref(po, popr->name);
+ name = check_label_read_ref(po, popr->name, &is_import);
+ if (is_import)
+ // for imported data, asm is loading the offset
+ goto do_offset;
+
if (cast[0] == 0 && popr->is_ptr)
cast = "(u32)";
break;
case OPT_OFFSET:
- name = check_label_read_ref(po, popr->name);
+ do_offset:
+ name = check_label_read_ref(po, popr->name, NULL);
if (cast[0] == 0)
cast = "(u32)";
if (is_lea)
if (pp->is_fptr && !(pp->name[0] != 0 && pp->is_arg)) {
if (pp->name[0] != 0) {
+ if (IS_START(pp->name, "guess"))
+ pp->is_guessed = 1;
+
memmove(pp->name + 2, pp->name, strlen(pp->name) + 1);
memcpy(pp->name, "i_", 2);
fprintf(fout, "%s%s = %s;\n", buf3, pp->name,
out_src_opr(buf1, sizeof(buf1), po, &po->operand[0],
"(void *)", 0));
- if (pp->is_unresolved || IS_START(pp->name, "i_guess"))
- fprintf(fout, "%sunresolved_call(\"%s:%d\", %s);\n",
- buf3, asmfn, po->asmln, pp->name);
+ }
+ if (pp->is_fptr && (pp->is_unresolved || pp->is_guessed)) {
+ fprintf(fout, "%sunresolved_call(\"%s:%d\", %s);\n",
+ buf3, asmfn, po->asmln, pp->name);
}
fprintf(fout, "%s", buf3);