From cdc3df949b0c2273f46b8455ccedd5cf14910695 Mon Sep 17 00:00:00 2001 From: grischka Date: Fri, 25 Sep 2020 18:03:23 +0200 Subject: [PATCH] tcc -bench: show text/data/bss binary output sizes --- libtcc.c | 2 ++ tcc.h | 1 + tccelf.c | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/libtcc.c b/libtcc.c index c3d96d43..ffd0f376 100644 --- a/libtcc.c +++ b/libtcc.c @@ -2115,6 +2115,8 @@ PUB_FUNC void tcc_print_stats(TCCState *s1, unsigned total_time) (double)total_time/1000, (unsigned)total_lines*1000/total_time, (double)total_bytes/1000/total_time); + fprintf(stderr, "* text %d, data %d, bss %d bytes\n", + s1->total_output[0], s1->total_output[1], s1->total_output[2]); #ifdef MEM_DEBUG fprintf(stderr, "* %d bytes memory used\n", mem_max_size); #endif diff --git a/tcc.h b/tcc.h index ee919efc..410d3e67 100644 --- a/tcc.h +++ b/tcc.h @@ -918,6 +918,7 @@ struct TCCState { int total_idents; int total_lines; int total_bytes; + int total_output[3]; /* option -dnum (for general development purposes) */ int g_debug; diff --git a/tccelf.c b/tccelf.c index c8745aa6..a3ceb0e5 100644 --- a/tccelf.c +++ b/tccelf.c @@ -202,6 +202,12 @@ ST_FUNC void tccelf_end_file(TCCState *s1) } } tcc_free(tr); + + /* record text/data/bss output for -bench info */ + for (i = 0; i < 3; ++i) { + s = s1->sections[i + 1]; + s1->total_output[i] += s->data_offset - s->sh_offset; + } } ST_FUNC Section *new_section(TCCState *s1, const char *name, int sh_type, int sh_flags) -- 2.11.4.GIT