public inbox for dwarves@vger.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Ihor Solodrai <ihor.solodrai@linux.dev>,
	Alexei Starovoitov <ast@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	 Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend	 <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev	 <sdf@fomichev.me>,
	Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>,
	 Nathan Chancellor	 <nathan@kernel.org>,
	Nicolas Schier <nicolas.schier@linux.dev>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt	 <justinstitt@google.com>,
	Alan Maguire <alan.maguire@oracle.com>,
	Donglin Peng	 <dolinux.peng@gmail.com>
Cc: bpf@vger.kernel.org, dwarves@vger.kernel.org,
	linux-kernel@vger.kernel.org, 	linux-kbuild@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 4/4] resolve_btfids: change in-place update with raw binary output
Date: Thu, 04 Dec 2025 11:14:01 -0800	[thread overview]
Message-ID: <6cdae76c99bb74c3389a05e39c34732c2ca172c6.camel@gmail.com> (raw)
In-Reply-To: <131b4190-9c49-4f79-a99d-c00fac97fa44@linux.dev>

On Thu, 2025-12-04 at 11:04 -0800, Ihor Solodrai wrote:
> On 12/4/25 10:06 AM, Eduard Zingerman wrote:
> > On Thu, 2025-12-04 at 09:29 -0800, Ihor Solodrai wrote:
> > 
> > [...]
> > 
> > > Ok, it seems you're conflating two separate issues.
> > > 
> > > There is a requirement to *link* .BTF section into vmlinux, because it
> > > must have a SHF_ALLOC flag, which makes objcopying the section data
> > > insufficient: linker has to do some magic under the hood.
> > > 
> > > The patch doesn't change this behavior, and this was (and is) covered
> > > in the script comments.
> > > 
> > > A separate issue is what resolve_btfids does: updates ELF in-place
> > > (before the patch) or outputs detached section data (after patch).
> > > 
> > > The paragraph in the commit message attempted to explain the decision
> > > to output raw section data. And apparently I did a bad job of
> > > that. I'll rewrite this part it in the next revision.
> > > 
> > > And I feel I should clarify that I didn't claim that libelf is buggy.
> > > I meant that using it is complicated, which makes resolve_btfids buggy.
> > 
> > So, pahole does the following:
> > - elf_begin(fildes: fd, cmd: ELF_C_RDWR, ref: NULL);
> > - selects a section to modify and modifies it
> > - elf_flagdata(data: btf_data, cmd: ELF_C_SET, flags: ELF_F_DIRTY);
> > - elf_update(elf, cmd: ELF_C_WRITE)
> > - elf_end(elf)
> > 
> > What exactly is complicated about that?
> 
> Take a look at the resolve_btfids code that is removed in this patch,
> as a consequence of switching to read-only ELF.
> 
> Also consider that before these changes resolve_btfids had a simple
> job: update data buffer of a single section, importantly, without
> changing its size.
> 
> Now let's say we keep "update in-place" approach (which I tried to do,
> btw). In addition to previous .BTF_ids data update, resolve_btfids may
> need to either add or update .BTF section changing its size (triggering
> reorg of sections in ELF, depending on the flags) and add .BTF.base
> section. There is also a question of how to do it: do we elf_update()
> multiple times or try to "batch" the updates?
> 
> All of this is possible, but the alternative is much simpler:
> 
>     ${OBJCOPY} --add-section .BTF=${ELF_FILE}.btf ${ELF_FILE}
> 
> Why re-implement our own incomplete version of objcopy if we can just
> use it to deal with the details of the ELF update?
> 
> Note also that even in pahole "add .BTF section" is implemented via
> llvm-objcopy call. My guess is: to avoid the headache of figuring out
> correct libelf usage.

Please put this motivation in the commit message.

  reply	other threads:[~2025-12-04 19:14 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27 18:52 [PATCH bpf-next v2 0/4] resolve_btfids: Support for BTF modifications Ihor Solodrai
2025-11-27 18:52 ` [PATCH bpf-next v2 1/4] resolve_btfids: rename object btf field to btf_path Ihor Solodrai
2025-11-27 18:52 ` [PATCH bpf-next v2 2/4] resolve_btfids: factor out load_btf() Ihor Solodrai
2025-11-27 18:52 ` [PATCH bpf-next v2 3/4] resolve_btfids: introduce enum btf_id_kind Ihor Solodrai
2025-12-01 17:27   ` Andrii Nakryiko
2025-12-02 19:08     ` Ihor Solodrai
2025-12-04  0:42       ` Andrii Nakryiko
2025-12-04  4:35         ` Ihor Solodrai
2025-12-01 18:27   ` Eduard Zingerman
2025-11-27 18:52 ` [PATCH bpf-next v2 4/4] resolve_btfids: change in-place update with raw binary output Ihor Solodrai
2025-11-28  3:20   ` Donglin Peng
2025-11-28  5:52     ` Ihor Solodrai
2025-12-01 19:46       ` Ihor Solodrai
2025-12-02  2:01         ` Donglin Peng
2025-12-02 19:00           ` Ihor Solodrai
2025-12-03  9:14             ` Donglin Peng
2025-12-03 10:42               ` Donglin Peng
2025-12-04  0:46             ` Andrii Nakryiko
2025-12-04  3:28               ` Donglin Peng
2025-12-01 19:55   ` Eduard Zingerman
2025-12-04  5:13     ` Ihor Solodrai
2025-12-04 16:57       ` Eduard Zingerman
2025-12-04 17:29         ` Ihor Solodrai
2025-12-04 18:06           ` Eduard Zingerman
2025-12-04 19:04             ` Ihor Solodrai
2025-12-04 19:14               ` Eduard Zingerman [this message]
2025-12-01 22:16   ` Andrii Nakryiko
2025-12-03 18:48     ` Alan Maguire
2025-12-04  4:42       ` Ihor Solodrai
2025-12-06  5:08   ` kernel test robot
2025-12-16 20:41     ` Ihor Solodrai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6cdae76c99bb74c3389a05e39c34732c2ca172c6.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dolinux.peng@gmail.com \
    --cc=dwarves@vger.kernel.org \
    --cc=haoluo@google.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=nicolas.schier@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox