The st->symtable might be unsorted after store_symbols(), which is
unexpected. According to the code comment of store_symbols(), the st->
symtable should be increasing numerical order sorted, which should be
done by gnu_qsort(). The reason for unsuccessful sort is unclear, because
I didn't figure out the details of (non_)numeric_forward/gnu_sort. Anyway
this can be fixed by given another sort at the end of store_symbols().
Without the patch:
crash> sym schedule
ffffffff973ffb30 (T) schedule /root/linux-6.14-rc3/kernel/sched/core.c: 6848
crash> sym 0xffffffff973ffb30
sym: invalid address: 0xffffffff973ffb30
With the patch:
crash> sym schedule
ffffffff973ffb30 (T) schedule /root/linux-6.14-rc3/kernel/sched/core.c: 6848
crash> sym 0xffffffff973ffb30
ffffffff973ffb30 (T) schedule /root/linux-6.14-rc3/kernel/sched/core.c: 6848
The root cause for the above error, is crash fail to determine
if 0xffffffff973ffb30 is within kernel range by in_ksymbol_range(),
since the st->symtable is not sorted and the kernel start/end addrs
are incorrect.
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
symbols.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/symbols.c b/symbols.c
index 6385d02..4e58fc2 100644
--- a/symbols.c
+++ b/symbols.c
@@ -833,6 +833,9 @@ store_symbols(bfd *abfd, int dynamic, void *minisyms, long symcount,
namespace_ctl(NAMESPACE_COMPLETE, &st->kernel_namespace,
st->symtable, st->symend);
+
+ qsort(st->symtable, st->symcnt, sizeof(struct syment),
+ compare_syms);
}
/*
--
2.47.0