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

Tao Liu ltao at redhat.com
Thu Jun 18 01:50:03 PDT 2026


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(萩尾 一仁)
<k-hagio-ab at nec.com> 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 <stephen.s.brennan at oracle.com>
> > Signed-off-by: Tao Liu <ltao at redhat.com>
> > ---
> >   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




More information about the kexec mailing list