Skip to content

Commit 0acdd71

Browse files
committed
perf symbol: Prefer non-label symbols with same address
JIRA: https://issues.redhat.com/browse/RHEL-77935 upstream ======== commit 8c2eafb Author: Namhyung Kim <namhyung@kernel.org> Date: Thu Jan 2 12:32:51 2025 -0800 description =========== When there are more than one symbols at the same address, it needs to choose which one is better. In choose_best_symbol() it didn't check the type of symbols. It's possible to have labels in other symbols and in that case, it would be better to pick the actual symbol over the labels. To minimize the possible impact on other symbols, I only check NOTYPE symbols specifically. $ 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 The commit 77b004f tried to do the same by not giving the size to the label symbols but it seems there's some label-only symbols in asm code. Let's restore the original code and choose the right symbol using type of the symbols. Fixes: 77b004f ("perf symbol: Do not fixup end address of labels") Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: Ian Rogers <irogers@google.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Link: http://lore.kernel.org/lkml/Z3b-DqBMnNb4ucEm@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Michael Petlan <mpetlan@redhat.com>
1 parent b1e79e9 commit 0acdd71

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/perf/util/symbol.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ static int choose_best_symbol(struct symbol *syma, struct symbol *symb)
154154
else if ((a == 0) && (b > 0))
155155
return SYMBOL_B;
156156

157+
if (syma->type != symb->type) {
158+
if (syma->type == STT_NOTYPE)
159+
return SYMBOL_B;
160+
if (symb->type == STT_NOTYPE)
161+
return SYMBOL_A;
162+
}
163+
157164
/* Prefer a non weak symbol over a weak one */
158165
a = syma->binding == STB_WEAK;
159166
b = symb->binding == STB_WEAK;
@@ -257,7 +264,7 @@ void symbols__fixup_end(struct rb_root_cached *symbols, bool is_kallsyms)
257264
* like in:
258265
* ffffffffc1937000 T hdmi_driver_init [snd_hda_codec_hdmi]
259266
*/
260-
if (prev->end == prev->start && prev->type != STT_NOTYPE) {
267+
if (prev->end == prev->start) {
261268
const char *prev_mod;
262269
const char *curr_mod;
263270

0 commit comments

Comments
 (0)