[Question] for duplicate symbols, kallsyms and vmlinux may retain different symbol

From: Songshan Gong
Date: Tue Jul 19 2016 - 07:15:21 EST


I try to fix the failure of testcase 'test__vmlinux_matches_kallsyms', and meet a kind of failure because of duplicate symbols.

For example,two functions:
kretprobe_trampoline_holder and kretprobe_trampoline

(1)They all start from the same addr,0x011b180;

(2)kretprobe_trampoline_holder is STB_LOCAL,
kretprobe_trampoline is STB_GLOBAL;

(3) for kallsyms, because we cann't get the correct size of each symbol from /proc/kallsyms, before symbols__fixup_duplicate(), perf assumes each symbol's size is zero, so when choose_best_symbol(), we get kretprobe_trampoline because perf prefers 'a global symbol over a non-global one';

(4) for vmlinux, by readelf, I found that:
size of kretprobe_trampoline_holder is 4, not zero;
size of kretprobe_trampoline is zero;
So when choose_best_symbol(), we get pretprobe_trampoline_holder instead because perf prefers 'A symbol with non-zero length' and this condition is judged before 'prefer a global symbol';

I have a idea to fix this problem, but may be inappropriate:
Could we move the judge of symbol size to the bottom of the judge whether a symbol is global?

Anyone else have good idea?

Song Shan Gong