perf symbol: Do not fixup end address of labels
Namhyung Kim
maintainerPATCH 1/1 perf symbol: Do not fixup end address of labels
When it loads symbols from an ELF file, it loads label symbols which is 0 size. Sometimes it has the same address with other symbols and might shadow the original symbols because it fixes up the size of the symbol.
For example, in my system __do_softirq is shadowed and only accepts the __softirqentry_text_start instead. But it should accept __do_softirq.
$ readelf -sW vmlinux | grep -e __do_softirq -e __softirqentry_text_start 105089: ffffffff82000000 814 FUNC GLOBAL DEFAULT 1 __do_softirq 111954: ffffffff82000000 0 NOTYPE GLOBAL DEFAULT 1 __softirqentry_text_start
$ perf annotate --stdio __do_softirq Error: The perf.data data has no samples!
$ perf annotate --stdio __softirqentry_text_start | head
Percent | Source code & Disassembly of vmlinux for cycles (26 samples, percent: local period)
---------------------------------------------------------------------------------------------------
: 0 0xffffffff82000000 <__softirqentry_text_start>:
0.00 : ffffffff82000000: nopl (%rax,%rax)
30.77 : ffffffff82000005: pushq %rbp
3.85 : ffffffff82000006: movq %rsp, %rbp
0.00 : ffffffff82000009: pushq %r15
3.85 : ffffffff8200000b: pushq %r14
3.85 : ffffffff8200000d: pushq %r13
0.00 : ffffffff8200000f: pushq %r12We can ignore NOTYPE symbols in the symbols__fixup_end() so that it can pick the __do_softirq() in choose_best_symbol(). This should be fine since most symbols have either STT_FUNC or STT_OBJECT.
--- tools/perf/util/symbol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/symbol.c +1 -1
@@ -262,7 +262,7 @@ void symbols__fixup_end(struct rb_root_cached *symbols, bool is_kallsyms)* like in: * ffffffffc1937000 T hdmi_driver_init [snd_hda_codec_hdmi] */ -if (prev->end == prev->start) { +if (prev->end == prev->start && prev->type !=STT_NOTYPE ) {const char *prev_mod;const char *curr_mod;
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
Quoted 8 lines · Namhyung Kim
When it loads symbols from an ELF file, it loads label symbols which is 0 size. Sometimes it has the same address with other symbols and might shadow the original symbols because it fixes up the size of the symbol.
For example, in my system
__do_softirqis shadowed and only accepts the__softirqentry_text_startinstead. But it should accept__do_softirq.[...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung