From caad3a07a1d56b9f455667fef9e63e3be62454f7 Mon Sep 17 00:00:00 2001 From: Mike Pavone Date: Thu, 17 Jan 2013 20:00:07 -0800 Subject: Add instruction address logging to translator and support for reading an address log to the disassembler --- dis.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'dis.c') diff --git a/dis.c b/dis.c index 109d24d..99355eb 100644 --- a/dis.c +++ b/dis.c @@ -82,6 +82,7 @@ int main(int argc, char ** argv) deferred *def = NULL, *tmpd; for(uint8_t opt = 2; opt < argc; ++opt) { if (argv[opt][0] == '-') { + FILE * address_log; switch (argv[opt][1]) { case 'l': @@ -93,6 +94,26 @@ int main(int argc, char ** argv) case 'o': only = 1; break; + case 'f': + opt++; + if (opt >= argc) { + fputs("-f must be followed by a filename\n", stderr); + exit(1); + } + address_log = fopen(argv[opt], "r"); + if (!address_log) { + fprintf(stderr, "Failed to open %s for reading\n", argv[opt]); + exit(1); + } + while (fgets(disbuf, sizeof(disbuf), address_log)) { + if (disbuf[0]) { + uint32_t address = strtol(disbuf, NULL, 16); + if (address) { + def = defer(address, def); + reference(address); + } + } + } } } else { uint32_t address = strtol(argv[opt], NULL, 16); -- cgit v1.2.3