# HG changeset patch # User Mychaela Falconia # Date 1445231245 0 # Node ID e9254e0234ab86a8f25e1daa956fd8f4cf414aad # Parent b893ea27e08112f415e3228bb4bd55c706b282f1 dspanal/patchanal: added -v option to dump section content diff -r b893ea27e081 -r e9254e0234ab dspanal/patchanal.c --- 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 #include #include +#include +#include /* 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; } }