Skip to content

Commit

Permalink
Fix get_linux_banner_from_vmlinux() for vmlinux without ".rodata" symbol
Browse files Browse the repository at this point in the history
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 <k-hagio-ab@nec.com>
  • Loading branch information
k-hagio committed Jul 24, 2023
1 parent aa57638 commit c74f375
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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,
Expand Down

0 comments on commit c74f375

Please sign in to comment.