From c74f375e0ef7cd9b593fa1d73c47505822c8f2a0 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Mon, 24 Jul 2023 17:25:12 +0900 Subject: [PATCH 22/30] Fix get_linux_banner_from_vmlinux() for vmlinux without ".rodata" symbol As written in the previous patch, some recent kernels do not have the ".rodata" symbol. As a result, the get_linux_banner_from_vmlinux() returns FALSE and the slower fallback routine is used. Use "__start_rodata" symbol if the ".rodata" symbol is not available. Signed-off-by: Kazuhito Hagio Signed-off-by: Lianbo Jiang --- kernel.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel.c b/kernel.c index 9801812387bd..2114700eecc8 100644 --- a/kernel.c +++ b/kernel.c @@ -11891,8 +11891,13 @@ int get_linux_banner_from_vmlinux(char *buf, size_t size) { struct bfd_section *sect; long offset; + ulong start_rodata; - if (!kernel_symbol_exists(".rodata")) + if (kernel_symbol_exists(".rodata")) + start_rodata = symbol_value(".rodata"); + else if (kernel_symbol_exists("__start_rodata")) + start_rodata = symbol_value("__start_rodata"); + else return FALSE; sect = bfd_get_section_by_name(st->bfd, ".rodata"); @@ -11905,7 +11910,7 @@ int get_linux_banner_from_vmlinux(char *buf, size_t size) * value in vmlinux file, but relative offset to linux_banner * object in .rodata section is idential. */ - offset = symbol_value("linux_banner") - symbol_value(".rodata"); + offset = symbol_value("linux_banner") - start_rodata; if (!bfd_get_section_contents(st->bfd, sect, -- 2.37.1