diff options
author | Peter Zijlstra <peterz@infradead.org> | 2020-03-12 09:26:29 +0100 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2020-03-25 18:28:28 +0100 |
commit | 1e11f3fdc326d7466e43185ea943b6156143387c (patch) | |
tree | 5a4ee402d9becc5691eef8b30cde9aff8fc31d0b /tools/objtool/elf.c | |
parent | 65fb11a7f6aeae678043738d06248a4e21f4e4e4 (diff) |
objtool: Add a statistics mode
Have it print a few numbers which can be used to size the hashtables.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20200324160924.321381240@infradead.org
Diffstat (limited to 'tools/objtool/elf.c')
-rw-r--r-- | tools/objtool/elf.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index b188b3e075be..ff293064b469 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -15,6 +15,7 @@ #include <string.h> #include <unistd.h> #include <errno.h> +#include "builtin.h" #include "elf.h" #include "warn.h" @@ -202,6 +203,9 @@ static int read_sections(struct elf *elf) sec->len = sec->sh.sh_size; } + if (stats) + printf("nr_sections: %lu\n", (unsigned long)sections_nr); + /* sanity check, one more call to elf_nextscn() should return NULL */ if (elf_nextscn(elf->elf, s)) { WARN("section entry mismatch"); @@ -299,6 +303,9 @@ static int read_symbols(struct elf *elf) hash_add(elf->symbol_hash, &sym->hash, sym->idx); } + if (stats) + printf("nr_symbols: %lu\n", (unsigned long)symbols_nr); + /* Create parent/child links for any cold subfunctions */ list_for_each_entry(sec, &elf->sections, list) { list_for_each_entry(sym, &sec->symbol_list, list) { @@ -360,6 +367,7 @@ static int read_relas(struct elf *elf) struct rela *rela; int i; unsigned int symndx; + unsigned long nr_rela, max_rela = 0, tot_rela = 0; list_for_each_entry(sec, &elf->sections, list) { if (sec->sh.sh_type != SHT_RELA) @@ -374,6 +382,7 @@ static int read_relas(struct elf *elf) sec->base->rela = sec; + nr_rela = 0; for (i = 0; i < sec->sh.sh_size / sec->sh.sh_entsize; i++) { rela = malloc(sizeof(*rela)); if (!rela) { @@ -401,8 +410,15 @@ static int read_relas(struct elf *elf) list_add_tail(&rela->list, &sec->rela_list); hash_add(sec->rela_hash, &rela->hash, rela->offset); - + nr_rela++; } + max_rela = max(max_rela, nr_rela); + tot_rela += nr_rela; + } + + if (stats) { + printf("max_rela: %lu\n", max_rela); + printf("tot_rela: %lu\n", tot_rela); } return 0; |