From: Michael Buesch Date: Sun, 18 May 2008 22:32:46 +0000 (+0200) Subject: b43-asm: Add an option to print the code sizes after assembling. X-Git-Tag: b43-fwcutter-013~53 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=e882e360ba16d2eed103adffdd1809076ee98017;p=b43-tools.git b43-asm: Add an option to print the code sizes after assembling. Signed-off-by: Michael Buesch --- diff --git a/assembler/args.c b/assembler/args.c index ffb90f4..cf49460 100644 --- a/assembler/args.c +++ b/assembler/args.c @@ -23,6 +23,7 @@ int _debug; +bool arg_print_sizes; #define ARG_MATCH 0 #define ARG_NOMATCH 1 @@ -96,6 +97,7 @@ static void usage(int argc, char **argv) fprintf(stderr, " -h|--help Print this help\n"); fprintf(stderr, " -d|--debug Print verbose debugging info\n"); fprintf(stderr, " Repeat for more verbose debugging\n"); + fprintf(stderr, " -s|--psize Print the size of the code after assembling\n"); } int parse_args(int argc, char **argv) @@ -114,6 +116,8 @@ int parse_args(int argc, char **argv) return 1; } else if ((res = cmp_arg(argv, &i, "--debug", "-d", 0)) == ARG_MATCH) { _debug++; + } else if ((res = cmp_arg(argv, &i, "--psize", "-s", 0)) == ARG_MATCH) { + arg_print_sizes = 1; } else { fprintf(stderr, "Unrecognized argument: %s\n", argv[i]); goto out_usage; diff --git a/assembler/args.h b/assembler/args.h index 8bebeac..15fcb51 100644 --- a/assembler/args.h +++ b/assembler/args.h @@ -1,11 +1,15 @@ #ifndef BCM43xx_ASM_ARGS_H_ #define BCM43xx_ASM_ARGS_H_ +#include "util.h" + + int parse_args(int argc, char **argv); int open_input_file(void); void close_input_file(void); extern int _debug; +extern bool arg_print_sizes; #define IS_DEBUG (_debug > 0) #define IS_VERBOSE_DEBUG (_debug > 1) diff --git a/assembler/initvals.c b/assembler/initvals.c index eb2634d..eb39d73 100644 --- a/assembler/initvals.c +++ b/assembler/initvals.c @@ -276,6 +276,7 @@ static void emit_ival_section(struct ivals_context *ctx) struct initval_raw raw; struct fw_header hdr; unsigned int size; + unsigned int filesize = 0; memset(&hdr, 0, sizeof(hdr)); hdr.type = FW_TYPE_IV; @@ -284,7 +285,7 @@ static void emit_ival_section(struct ivals_context *ctx) fn_len = strlen(outfile_name) + 512; fn = xmalloc(fn_len); - snprintf(fn, fn_len, "%s.%s.initval", outfile_name, ctx->sect->name); + snprintf(fn, fn_len, "%s.%s.initvals", outfile_name, ctx->sect->name); fd = fopen(fn, "w+"); if (!fd) { fprintf(stderr, "Could not open initval output file \"%s\"\n", fn); @@ -311,7 +312,14 @@ static void emit_ival_section(struct ivals_context *ctx) fprintf(stderr, "Could not write initvals outfile\n"); exit(1); } + filesize += size; } + + if (arg_print_sizes) { + printf("%s: %d values (%u bytes)\n", + fn, ctx->ivals_count, filesize); + } + fclose(fd); free(fn); } diff --git a/assembler/main.c b/assembler/main.c index 3562a04..255cabc 100644 --- a/assembler/main.c +++ b/assembler/main.c @@ -1125,6 +1125,12 @@ static void emit_code(struct assembler_context *ctx) break; } } + + if (arg_print_sizes) { + printf("%s: text = %u instructions (%u bytes)\n", + fn, insn_count, insn_count * sizeof(uint64_t)); + } + fclose(fd); free(fn); }