[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNAQokoST0FnByeWywaghTMP2aG7hQaV1T=TcQ=1v4ZLQrg@mail.gmail.com>
Date: Sat, 15 Feb 2025 23:21:12 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Stephen Brennan <stephen.s.brennan@...cle.com>
Cc: 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 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.
--
Best Regards
Masahiro Yamada
Powered by blists - more mailing lists