Commit e882e360 authored by Michael Büsch's avatar Michael Büsch

b43-asm: Add an option to print the code sizes after assembling.

Signed-off-by: Michael Büsch's avatarMichael Buesch <mb@bu3sch.de>
parent 7300a854
......@@ -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;
......
#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)
......
......@@ -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);
}
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment