On 2023/07/24 15:51, lijiang wrote:
> How about reading out the linux_banner string to a buffer with readmem()?
No, this is a version check for the namelist (vmlinux).
Ah, you are right, Kazu.
>> If the vmlinux does not have only the ".rodata" symbol, is it possible
>> to use "__start_rodata" symbol or something? i.e. is there no symbol
>> that has the same address as .rodata section?
>>
>>
> I tried the "__start_rodata" symbol, but it does not work.
How did you try? There is no "__start_rodata" symbol?
I mean something like this:
--- a/kernel.c
+++ b/kernel.c
@@ -11893,8 +11893,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");
The ".rodata" is a section, I mistakenly replaced the ".rodata" with the symbol "__start_rodata" in a debug patch, so it does not work. :-)
diff --git a/kernel.c b/kernel.c
index 546eed9..3c50fa4 100644
--- a/kernel.c
+++ b/kernel.c
@@ -11894,7 +11894,7 @@ int get_linux_banner_from_vmlinux(char *buf, size_t size)
struct bfd_section *sect;
long offset;
- if (!kernel_symbol_exists(".rodata"))
+ if (!kernel_symbol_exists("__start_rodata"))
return FALSE;
sect = bfd_get_section_by_name(st->bfd, ".rodata");
@@ -11907,7 +11907,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") - symbol_value("__start_rodata");
if (!bfd_get_section_contents(st->bfd,
sect,
@@ -11916,5 +11916,6 @@ int get_linux_banner_from_vmlinux(char *buf, size_t size)
size))
return FALSE;
+ error(INFO, "%s\n", buf);
return TRUE;
For now, the get_linux_banner_from_vmlinux() works again with the debug patch.
Thanks.
Lianbo