mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-06 05:45:29 +02:00

[ Upstream commit 56ac7bd2c58a4e93d19f0ccb181035d075b315d3 ] This reverts commitc02904f05f
. Such commit assumed that only two symbols are relevant for the symbol size calculation. However, this can lead to an incorrect symbol size calculation when there are mapping symbols emitted by readelf. For instance, when feeding 'update_irq_load_avg+0x1c/0x1c4', faddr2line might need to process the following readelf lines: 784284: ffffffc0081cca30 428 FUNC GLOBAL DEFAULT 2 update_irq_load_avg 87319: ffffffc0081ccb0c 0 NOTYPE LOCAL DEFAULT 2 $x.62522 87321: ffffffc0081ccbdc 0 NOTYPE LOCAL DEFAULT 2 $x.62524 87323: ffffffc0081ccbe0 0 NOTYPE LOCAL DEFAULT 2 $x.62526 87325: ffffffc0081ccbe4 0 NOTYPE LOCAL DEFAULT 2 $x.62528 87327: ffffffc0081ccbe8 0 NOTYPE LOCAL DEFAULT 2 $x.62530 87329: ffffffc0081ccbec 0 NOTYPE LOCAL DEFAULT 2 $x.62532 87331: ffffffc0081ccbf0 0 NOTYPE LOCAL DEFAULT 2 $x.62534 87332: ffffffc0081ccbf4 0 NOTYPE LOCAL DEFAULT 2 $x.62535 783403: ffffffc0081ccbf4 424 FUNC GLOBAL DEFAULT 2 sched_pelt_multiplier The symbol size of 'update_irq_load_avg' should be calculated with the address of 'sched_pelt_multiplier', after skipping the mapping symbols seen in between. However, the offending commit cuts the list short and faddr2line incorrectly assumes 'update_irq_load_avg' is the last symbol in the section, resulting in: $ scripts/faddr2line vmlinux update_irq_load_avg+0x1c/0x1c4 skipping update_irq_load_avg address at 0xffffffc0081cca4c due to size mismatch (0x1c4 != 0x3ff9a59988) no match for update_irq_load_avg+0x1c/0x1c4 After reverting the commit the issue is resolved: $ scripts/faddr2line vmlinux update_irq_load_avg+0x1c/0x1c4 update_irq_load_avg+0x1c/0x1c4: cpu_of at kernel/sched/sched.h:1109 (inlined by) update_irq_load_avg at kernel/sched/pelt.c:481 Fixes:c02904f05f
("scripts/faddr2line: Check only two symbols when calculating symbol size") Signed-off-by: Carlos Llamas <cmllamas@google.com> Acked-by: Will Deacon <will@kernel.org> Acked-by: Brian Johannesmeyer <bjohannesmeyer@gmail.com> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
11 KiB
Executable File
11 KiB
Executable File
#!/bin/bash
SPDX-License-Identifier: GPL-2.0
Translate stack dump function offsets.
addr2line doesn't work with KASLR addresses. This works similarly to
addr2line, but instead takes the 'func+0x123' format as input:
$ ./scripts/faddr2line ~/k/vmlinux meminfo_proc_show+0x5/0x568
meminfo_proc_show+0x5/0x568:
meminfo_proc_show at fs/proc/meminfo.c:27
If the address is part of an inlined function, the full inline call chain is
printed:
$ ./scripts/faddr2line ~/k/vmlinux native_write_msr+0x6/0x27
native_write_msr+0x6/0x27:
arch_static_branch at arch/x86/include/asm/msr.h:121
(inlined by) static_key_false at include/linux/jump_label.h:125
(inlined by) native_write_msr at arch/x86/include/asm/msr.h:125
The function size after the '/' in the input is optional, but recommended.
It's used to help disambiguate any duplicate symbol names, which can occur
rarely. If the size is omitted for a duplicate symbol then it's possible for
multiple code sites to be printed:
$ ./scripts/faddr2line ~/k/vmlinux raw_ioctl+0x5
raw_ioctl+0x5/0x20:
raw_ioctl at drivers/char/raw.c:122
raw_ioctl+0x5/0xb1:
raw_ioctl at net/ipv4/raw.c:876
Multiple addresses can be specified on a single command line:
$ ./scripts/faddr2line ~/k/vmlinux type_show+0x10/45 free_reserved_area+0x90
type_show+0x10/0x2d:
type_show at drivers/video/backlight/backlight.c:213
free_reserved_area+0x90/0x123:
free_reserved_area at mm/page_alloc.c:6429 (discriminator 2)
set -o errexit set -o nounset
usage() { echo "usage: faddr2line [--list]