changeset 204:e9254e0234ab

dspanal/patchanal: added -v option to dump section content
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Mon, 19 Oct 2015 05:07:25 +0000
parents b893ea27e081
children 8bdc87c0fc03
files dspanal/patchanal.c
diffstat 1 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/dspanal/patchanal.c	Fri Oct 16 17:00:22 2015 +0000
+++ b/dspanal/patchanal.c	Mon Oct 19 05:07:25 2015 +0000
@@ -8,6 +8,8 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
+#include <string.h>
+#include <strings.h>
 
 /* char array extracted from COFF object */
 const unsigned char patch_array[11294] = {
@@ -719,12 +721,37 @@
 0x84,0x76,0x05,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x5C,0x01,0x00,0x00,
 };
 
+dump_section(bytes, dspaddr, size)
+	const u_char *bytes;
+	uint32_t dspaddr, size;
+{
+	uint32_t off;
+	const u_char *p = bytes;
+	int i;
+
+	for (off = 0; off < size; ) {
+		printf("%05X:", (unsigned)(dspaddr + off));
+		for (i = 0; i < 8; i++) {
+			if (off >= size)
+				break;
+			printf(" %02X%02X", p[1], p[0]);
+			off++;
+			p += 2;
+		}
+		putchar('\n');
+	}
+	putchar('\n');
+}
+
 main(argc, argv)
 	char **argv;
 {
 	const u_char *ptr, *endp;
 	uint32_t dspaddr, size;
+	int verbose = 0;
 
+	if (argc >= 2 && !strcmp(argv[1], "-v"))
+		verbose = 1;
 	ptr = patch_array + 8;
 	endp = patch_array + sizeof(patch_array);
 	for (;;) {
@@ -745,6 +772,8 @@
 			printf("Error: endmarker != end of array!\n");
 			exit(1);
 		}
+		if (verbose)
+			dump_section(ptr, dspaddr, size);
 		ptr += size * 2;
 	}
 }