]> www.infradead.org Git - users/dwmw2/linux.git/commit
libbpf: Make btf_parse_elf process .BTF.base transparently
authorEduard Zingerman <eddyz87@gmail.com>
Thu, 13 Jun 2024 09:50:10 +0000 (10:50 +0100)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 17 Jun 2024 21:38:31 +0000 (14:38 -0700)
commitc86f180ffc993975fed5907a869fc9b1555d0cfb
tree1c5545c9dc0b385fc326588e4f247f6ba830cc8f
parentaffdeb50616b190c3236cc2bf116e1b931a43be2
libbpf: Make btf_parse_elf process .BTF.base transparently

Update btf_parse_elf() to check if .BTF.base section is present.
The logic is as follows:

  if .BTF.base section exists:
     distilled_base := btf_new(.BTF.base)
  if distilled_base:
     btf := btf_new(.BTF, .base_btf=distilled_base)
     if base_btf:
        btf_relocate(btf, base_btf)
  else:
     btf := btf_new(.BTF)
  return btf

In other words:
- if .BTF.base section exists, load BTF from it and use it as a base
  for .BTF load;
- if base_btf is specified and .BTF.base section exist, relocate newly
  loaded .BTF against base_btf.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240613095014.357981-6-alan.maguire@oracle.com
tools/lib/bpf/btf.c
tools/lib/bpf/btf.h