FreeCalypso > hg > freecalypso-reveng
changeset 175:928ed52930aa
objgrep-fe: works after fixing a buglet
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 04 Jul 2014 16:37:51 +0000 |
parents | 10c0cdc18208 |
children | 10a9a0ca9d07 |
files | objgrep/frontend.c |
diffstat | 1 files changed, 35 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/objgrep/frontend.c Fri Jul 04 08:46:32 2014 +0000 +++ b/objgrep/frontend.c Fri Jul 04 16:37:51 2014 +0000 @@ -30,6 +30,7 @@ struct symbol *flash_symbols, *ram_symbols; unsigned num_flash_symbols, num_ram_symbols; char *binfilename; +int verbose; enter_symbol(name, valstr, symsrc) char *name, *valstr; @@ -68,6 +69,8 @@ "This module's symbols deduced from section relocs:"; sprintf(cmdline, "objgrep -rs %s %s %s", objfile, secname, binfilename); + if (verbose) + printf("Running %s\n", cmdline); f = popen(cmdline, "r"); if (!f) { perror("popen"); @@ -192,7 +195,7 @@ p = buf; for (sym = head; sym; sym = sym->next) - *p = sym; + *p++ = sym; } unsigned @@ -251,20 +254,32 @@ struct symbol **input, **output; unsigned final_count; + if (verbose) + printf("Total symbols to process: %u\n", total); input = malloc(sizeof(void *) * total); if (!input) { perror("malloc"); exit(1); } + if (verbose) + printf("Turning linked list into linear array\n"); fill_input_array(head, input); + if (verbose) + printf("Sorting by name\n"); qsort(input, total, sizeof(void *), sort_by_name); + if (verbose) + printf("Allocating output array\n"); output = malloc(sizeof(void *) * total); if (!output) { perror("malloc"); exit(1); } + if (verbose) + printf("Processing duplicates\n"); final_count = dedup_symbols(input, output, total); free(input); + if (verbose) + printf("%u symbols left, sorting by value\n", final_count); qsort(output, final_count, sizeof(void *), sort_by_value); emit_final_symbols(output, final_count); free(output); @@ -274,12 +289,25 @@ main(argc, argv) char **argv; { - if (argc != 3) { - fprintf(stderr, "usage: %s listfile binfile\n", argv[0]); - exit(1); - } - binfilename = argv[2]; - process_list_file(argv[1]); + int c; + extern int optind; + + while ((c = getopt(argc, argv, "v")) != EOF) + switch (c) { + case 'v': + verbose++; + continue; + default: + usage: + fprintf(stderr, "usage: %s [-v] listfile binfile\n", + argv[0]); + exit(1); + } + if (argc - optind != 2) + goto usage; + + binfilename = argv[optind+1]; + process_list_file(argv[optind]); if (flash_symbols) { printf("Flash symbols:\n\n"); sort_and_emit_symbols(flash_symbols, num_flash_symbols);