btf_dump_get_enum_value() zero-extends unsigned 32-bit enum data, but btf_dump_enum_data() compares it with the signed enumerator field. Known values with bit 31 set therefore fail to match and are printed numerically. For example, HIGH = 0x80000000U is dumped as "(enum flags)2147483648" instead of "(enum flags)HIGH". Extend the enumerator according to the enum's signedness before comparing it with the data value. Keep the signed arm at 64 bits so negative enumerators are not converted to unsigned by the conditional operator. Fixes: d90ec262b35b ("libbpf: Add enum64 support for btf_dump") Signed-off-by: Hungyu Lin --- tools/lib/bpf/btf_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c index ea9a34db4c00..7608179aa0f0 100644 --- a/tools/lib/bpf/btf_dump.c +++ b/tools/lib/bpf/btf_dump.c @@ -2373,7 +2373,7 @@ static int btf_dump_enum_data(struct btf_dump *d, const struct btf_enum *e; for (i = 0, e = btf_enum(t); i < btf_vlen(t); i++, e++) { - if (value != e->val) + if (value != (is_signed ? (__s64)e->val : (__u32)e->val)) continue; btf_dump_type_values(d, "%s", btf_name_of(d, e->name_off)); return 0; base-commit: eaae576c34d7e001767b6845a5950b0b8db3e68a -- 2.43.0