lkml.org 
[lkml]   [2022]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRE: [PATCH 1/1 module-next] kallsyms: enhance %pS/s/b printing when KALLSYSMS is disabled
From
Date
Hi Sergey,
 
> > +                if (add_offset) {
> > +                        base = mod->core_layout.base;
> > +                        offset = value - (unsigned long)base;
> > +                }

> What if address is in module init? Shouldn't this be something like

>         if (within_module_init(value, mod))
>                 offset = value - (unsigned long)mod->init_layout.base;
>         else
>                 offset = value - (unsigned long)mod->core_layout.base;
 
Yes, this can be done, but I think then we need to handle it with some more info.
 
In module allocation first we load core_layout and then init_layout w.r.t address range
as below (ARM64):
 
ffff800000eb0000 -> core_layout
ffff800000eb4000 -> init_layout
 
 
So if we write only offset(w.r.t core_layout), then user can get a hint if it going beyond normal text
then it means it is init text.
 
But if we take offset from init and core separately, and we only print the offset (not function name),
we need to write alongwith offset that it is init or core area.
Otherwise user will get confused which offset it is, whether to check init or core text area.
 
And also while printing modules, kernel also uses core_layout as base address only:
 
static int m_show(struct seq_file *m, void *p)
{
..
        /* Used by oprofile and other similar tools. */
        value = m->private ? NULL : mod->core_layout.base;
        seq_printf(m, " 0x%px", value);
..
}
 
and also normal %ps prints like below:
 
ps 0xffff800000eb4004
load address of module is 0xffff800000eb0000
so normal offset is 4004 for init text section.
 
and same thing is printed with current patch:
pS 0xffff800000eb0000+0x4004 [crash]
 
Still if we need to handle separately, then please suggest only offset is ok or we need to
add string for init or core also like below:
 
   init_text start + offset
pS 0xffff800000eb4000+0x4 [crash init_text]
 
And also then there will be discrepancy for rodata or other sections, which offset to take.
If we are taking it from core_layout then init section can also be taken with same.
As of now it is unique offset calculation for all sections.
 
Thanks,
Maninder Singh

\
 
 \ /
  Last update: 2022-03-22 07:29    [W:0.024 / U:3.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site