[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4Bzb9rYHTVkuxxSuoW=0P84M7UPkBr-4991KiMnFsv10hjA@mail.gmail.com>
Date: Mon, 24 Feb 2025 10:51:38 -0800
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Masahiro Yamada <masahiroy@...nel.org>
Cc: Stephen Brennan <stephen.s.brennan@...cle.com>, Arnd Bergmann <arnd@...db.de>,
Andrii Nakryiko <andrii@...nel.org>, Nicolas Schier <nicolas@...sle.eu>, Kees Cook <kees@...nel.org>,
KP Singh <kpsingh@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>,
Sami Tolvanen <samitolvanen@...gle.com>, Eduard Zingerman <eddyz87@...il.com>, linux-arch@...r.kernel.org,
Stanislav Fomichev <sdf@...ichev.me>, Kent Overstreet <kent.overstreet@...ux.dev>,
Pasha Tatashin <pasha.tatashin@...een.com>, Jiri Olsa <jolsa@...nel.org>,
John Fastabend <john.fastabend@...il.com>, Jann Horn <jannh@...gle.com>,
Ard Biesheuvel <ardb@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>, Hao Luo <haoluo@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>, linux-kbuild@...r.kernel.org,
Daniel Borkmann <daniel@...earbox.net>, Nathan Chancellor <nathan@...nel.org>,
linux-debuggers@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
Song Liu <song@...nel.org>, linux-kernel@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH 1/2] kallsyms: output rodata to ".kallsyms_rodata"
On Sat, Feb 15, 2025 at 6:21 AM Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> On Fri, Feb 7, 2025 at 10:21 AM Stephen Brennan
> <stephen.s.brennan@...cle.com> wrote:
> >
> > When vmlinux is linked, the rodata from kallsyms is placed arbitrarily
> > within the .rodata section. The linking process is repeated several
> > times, since the kallsyms data size changes, which shifts symbols,
> > requiring re-generating the data and re-linking.
> >
> > BTF is generated during the first link only. For variables, BTF includes
> > a BTF_K_DATASEC for each data section that may contain a variable, which
> > includes the variable's name, type, and offset within the data section.
> > Because the size of kallsyms data changes during later links, the
> > offsets of variables placed after it in .rodata will change. This means
> > that BTF_K_DATASEC information for those variables becomes inaccurate.
> >
> > This is not currently a problem, because BTF currently only generates
> > variable data for percpu variables. However, the next commit will add
> > support for generating BTF for all global variables, including for the
> > .rodata section.
> >
> > We could re-generate BTF each time vmlinux is linked, but this is quite
> > expensive, and should be avoided at all costs. Further as each chunk of
> > data (BTF and kallsyms) are re-generated, there's no guarantee that
> > their sizes will converge anyway.
> >
> > Instead, we can take advantage of the fact that BTF only cares to store
> > the offset of variables from the start of their section. Therefore, so
> > long as the kallsyms data is stored last in the .rodata section, no
> > offsets will be affected. Adjust kallsyms to output to .rodata.kallsyms,
> > and update the linker script to include this at the end of .rodata.
> >
> > Signed-off-by: Stephen Brennan <stephen.s.brennan@...cle.com>
> > ---
>
> I am fine if this is helpful for BTF.
This seems like a useful change all by itself even while the main
feature of this patch set is still being developed and reviewed.
Should we land just this .kallsyms_rodata change?
>
>
>
> --
> Best Regards
> Masahiro Yamada
Powered by blists - more mailing lists