Re: [PATCH bpf-next] libbpf: Match unsigned enum values when dumping data

From: Hungyu Lin

Date: Sun Nov 01 2026 - 03:49:04 EST


> Pls check what clang puts into ld_imm64 for such enumerator.

I checked Clang 14.0.6 and 18.1.3. Both emit 0x0000000080000000
for 0x80000000U, so libbpf's sign-extended orig_val fails the
LDIMM64 check in bpf_core_patch_insn() today.

With Clang 14, -1 is emitted as 0xffffffffffffffff, but the enum
has kflag=0. Using the helper directly in CO-RE fixes the unsigned
case but fails that same check for this signed case.

In my offline relocation tests, with modern local BTF and a legacy
signed target enum with kflag=0, the check passes, but the helper
patches -1 as 0x00000000ffffffff. I'd leave CO-RE unchanged in this
series to avoid those regressions.

> Pls send libbpf, bpftool and the selftest as one series.

Will do. I'll use the shared helper, preserve existing enum name
matches, and add regression tests for legacy BTF.

Thanks,
Hungyu