Skip to content

bpf: Fix linker optimization removing kfuncs

Tony Ambardar bpf dwarves lkml stable 2 versions – Applied

Status from this message: This series was applied to bpf/bpf.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 9 repliesApplied 2/2
  2. v12 patches 2 repliesSuperseded

Patches in v2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2compiler_types.h: Define __retain for __attribute__((__retain__))include/linux/compiler_types.h+23 -05 repliesApplied
2/2bpf: Harden __bpf_kfunc tag against linker kfunc removalinclude/linux/btf.h+1 -14 repliesApplied

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchJiri Olsa
1/2
2/2T-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH bpf v2 0/2] bpf: Fix linker optimization removing kfuncs

This patch series fixes unwanted stripping of kernel kfuncs during linker optimization, as indicated by build warnings from resolve_btfids e.g. "WARN: resolve_btfids: unresolved symbol ...". This can happen because the __bpf_kfunc macro annotating kfunc declarations is ignored during linking.

Patch 1 adds support for the compiler attribute "__retain__", used to avoid linker garbage cleanup. Patch 2 then updates __bpf_kfunc to use this attribute when LTO builds are enabled.

Build-tested locally against mips64el with gcc 13.3, and run through upstream kernel-patches/bpf CI.

Tony Ambardar (2):
compiler_types.h: Define __retain for __attribute__((__retain__))
bpf: Harden __bpf_kfunc tag against linker kfunc removal

 include/linux/btf.h            |  2 +-
 include/linux/compiler_types.h | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
Signature · 5 lines
v2:
- move __retain macro to compiler_types.h (Miguel Ojeda)

-- 
2.34.1