We are using ELFXX_sym->st_info directly as the 'type' of symbol,
which is wrong, because st_info contains numeric value which needs
to be mapped to appropriate type character. Sections headers are
also required to correctly map st_info to symbol type which are
missing here (lm->mod_section_data is NULL). Use '?' for now. This
fixes 'trace' extension which segfaults internally while parsing
module kallsyms:
Before patch:
crash> trace show
crash>
After patch:
crash> trace show
cpus=4
<idle>-0 [002] 4350.912553: function: __hrtimer_get_next_event <-- hrtime
<idle>-0 [002] 4350.912553: function: __hrtimer_next_event_base <-- __hrt
Signed-off-by: Ravi Bangoria <ravi.bangoria(a)linux.ibm.com>
---
symbols.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/symbols.c b/symbols.c
index e73e735..4456cd3 100644
--- a/symbols.c
+++ b/symbols.c
@@ -2188,7 +2188,12 @@ Elf32_Sym_to_common(Elf32_Sym *e32, struct elf_common *ec)
ec->st_name = (ulong)e32->st_name;
ec->st_value = (ulong)e32->st_value;
ec->st_shndx = (ulong)e32->st_shndx;
- ec->st_info = e32->st_info;
+ /*
+ * Section headers are required to correctly map st_info
+ * to symbol type, which are missing here. Let's use '?'
+ * for all kernel module symbols type.
+ */
+ ec->st_info = '?';
ec->st_size = (ulong)e32->st_size;
}
@@ -2198,7 +2203,12 @@ Elf64_Sym_to_common(Elf64_Sym *e64, struct elf_common *ec)
ec->st_name = (ulong)e64->st_name;
ec->st_value = (ulong)e64->st_value;
ec->st_shndx = (ulong)e64->st_shndx;
- ec->st_info = e64->st_info;
+ /*
+ * Section headers are required to correctly map st_info
+ * to symbol type, which are missing here. Let's use '?'
+ * for all kernel module symbols type.
+ */
+ ec->st_info = '?';
ec->st_size = (ulong)e64->st_size;
}
--
1.8.3.1