*
* 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: <p> - replace current asm line with <p>
+ * sctproto: <p> - 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
*extra_offs = 0;
namelen = strlen(name);
- p = strchr(name, '+');
+ p = strpbrk(name, "+-");
if (p != NULL) {
namelen = p - name;
if (namelen <= 0)
ferr(po, "equ parse failed for '%s'\n", name);
- if (IS_START(p, "0x"))
- p += 2;
*extra_offs = strtol(p, &endp, 16);
if (*endp != 0)
ferr(po, "equ parse failed for '%s'\n", name);
int offset = 0;
int retval = -1;
int sf_ofs;
- int lim;
if (po->flags & OPF_EBP_S)
ferr(po, "stack_frame_access while ebp is scratch\n");
g_stack_frame_used = 1;
sf_ofs = g_stack_fsz + offset;
- lim = (ofs_reg[0] != 0) ? -4 : 0;
- if (offset > 0 || sf_ofs < lim)
+ if (ofs_reg[0] == 0 && (offset > 0 || sf_ofs < 0))
ferr(po, "bp_stack offset %d/%d\n", offset, g_stack_fsz);
if (is_lea)
// 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");
}
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);
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;
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];
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;
}