]> git.samba.org - sfrench/cifs-2.6.git/commitdiff
objtool: Provide stats for jump_labels
authorPeter Zijlstra <peterz@infradead.org>
Thu, 6 May 2021 19:34:04 +0000 (21:34 +0200)
committerIngo Molnar <mingo@kernel.org>
Wed, 12 May 2021 12:54:56 +0000 (14:54 +0200)
Add objtool --stats to count the jump_label sites it encounters.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210506194158.153101906@infradead.org
tools/objtool/check.c
tools/objtool/include/objtool/objtool.h

index 98cf87f2c5019da32d724e2859ae90acc7f11eab..2c6a93edf27ece3878aba73844af2eea8e8c87df 100644 (file)
@@ -1225,8 +1225,15 @@ static int handle_jump_alt(struct objtool_file *file,
                           struct instruction *orig_insn,
                           struct instruction **new_insn)
 {
-       if (orig_insn->type == INSN_NOP)
+       if (orig_insn->type == INSN_NOP) {
+do_nop:
+               if (orig_insn->len == 2)
+                       file->jl_nop_short++;
+               else
+                       file->jl_nop_long++;
+
                return 0;
+       }
 
        if (orig_insn->type != INSN_JUMP_UNCONDITIONAL) {
                WARN_FUNC("unsupported instruction at jump label",
@@ -1245,9 +1252,14 @@ static int handle_jump_alt(struct objtool_file *file,
                               orig_insn->offset, orig_insn->len,
                               arch_nop_insn(orig_insn->len));
                orig_insn->type = INSN_NOP;
-               return 0;
+               goto do_nop;
        }
 
+       if (orig_insn->len == 2)
+               file->jl_short++;
+       else
+               file->jl_long++;
+
        *new_insn = list_next_entry(orig_insn, list);
        return 0;
 }
@@ -1328,6 +1340,12 @@ static int add_special_section_alts(struct objtool_file *file)
                free(special_alt);
        }
 
+       if (stats) {
+               printf("jl\\\tNOP\tJMP\n");
+               printf("short:\t%ld\t%ld\n", file->jl_nop_short, file->jl_short);
+               printf("long:\t%ld\t%ld\n", file->jl_nop_long, file->jl_long);
+       }
+
 out:
        return ret;
 }
index e4084afb2304b1e60261e9c48e8a73225d5878cb..24fa83634de4d7aa6f43735d19852d632e222b96 100644 (file)
@@ -22,6 +22,9 @@ struct objtool_file {
        struct list_head static_call_list;
        struct list_head mcount_loc_list;
        bool ignore_unreachables, c_file, hints, rodata;
+
+       unsigned long jl_short, jl_long;
+       unsigned long jl_nop_short, jl_nop_long;
 };
 
 struct objtool_file *objtool_open_read(const char *_objname);