Re: [PATCH v6][makedumpfile 02/10] Implement kernel kallsyms resolving

Tao Liu <[email protected]>
Newsgroups org.infradead.lists.kexec
Message-ID <CAO7dBbWUpZDRhKLG7XB7qcMONo-GuwBmhTZxnax+cNdmRYtU8g@mail.gmail.com>
Hi Kazu,

Yes, it is needed for reallocarray() in kallsyms.c. For "man
reallocarray" gives:

       reallocarray():
           Since glibc 2.29:
               _DEFAULT_SOURCE
           glibc 2.28 and earlier:
               _GNU_SOURCE

For glibc <= 2.28, we need to use _GNU_SOURCE in order to use
reallocarray(). E.g I can encounter the compiling warning in rhel8
once removed.

kallsyms.c: In function ‘add_to_arr’:
kallsyms.c:46:9: warning: implicit declaration of function
‘reallocarray’; did you mean ‘realloc’?
[-Wimplicit-function-declaration]
   tmp = reallocarray(*arr, new_cap, sizeof(void *));
         ^~~~~~~~~~~~
         realloc
kallsyms.c:46:7: warning: assignment to ‘void *’ from ‘int’ makes
pointer from integer without a cast [-Wint-conversion]
   tmp = reallocarray(*arr, new_cap, sizeof(void *));
       ^

Thanks,
Tao Liu

On Thu, Jun 18, 2026 at 8:28 PM HAGIO KAZUHITO(萩尾 一仁)
<[email protected]> wrote:
>
> Hi Tao,
>
> On 2026/06/17 14:18, Tao Liu wrote:
> > This patch will parse kernel's kallsyms data. During the parsing
> > process, the .init_ksyms sections of makedumpfile and the
> > extensions will be iterated, so the kallsyms symbols which belongs
> > to vmlinux can be resolved at this moment.
> >
> > Reviewed-by: Stephen Brennan <[email protected]>
> > Signed-off-by: Tao Liu <[email protected]>
> > ---
> >   Makefile       |   2 +-
> >   kallsyms.c     | 392 +++++++++++++++++++++++++++++++++++++++++++++++++
> >   kallsyms.h     |  83 +++++++++++
> >   makedumpfile.c |   3 +
> >   makedumpfile.h |  11 ++
> >   5 files changed, 490 insertions(+), 1 deletion(-)
> >   create mode 100644 kallsyms.c
> >   create mode 100644 kallsyms.h
> >
> > diff --git a/Makefile b/Makefile
> > index 9482332..3cd729f 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -45,7 +45,7 @@ CFLAGS_ARCH += -m32
> >   endif
> >
> >   SRC_BASE = makedumpfile.c makedumpfile.h diskdump_mod.h sadump_mod.h sadump_info.h
> > -SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c printk.c detect_cycle.c
> > +SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c printk.c detect_cycle.c kallsyms.c
> >   OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART))
> >   SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c arch/mips64.c arch/loongarch64.c arch/riscv64.c
> >   OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH))
> > diff --git a/kallsyms.c b/kallsyms.c
> > new file mode 100644
> > index 0000000..a55dcc6
> > --- /dev/null
> > +++ b/kallsyms.c
> > @@ -0,0 +1,392 @@
> > +#define _GNU_SOURCE
>
> Just for confirmation, is this for what?  I can build without this line.
>
> $ git grep _GNU_SOURCE
> kallsyms.c:#define _GNU_SOURCE
>
> If unnecessary, I would not like to add something new for compatibility.
> is it ok to remove this when merging?
>
> Thanks,
> Kazu
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.