OSDN Git Service

libbpf: Handle non-standardly sized enums better in BTF-to-C dumper
authorAndrii Nakryiko <andrii@kernel.org>
Mon, 12 Dec 2022 21:15:01 +0000 (13:15 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 14 Dec 2022 23:05:12 +0000 (00:05 +0100)
commit21a9a1bcccaa4f0337a24d666fe55944abcb171e
tree9637adaf711405a85ba15ef57412bd9bdce56c86
parent872aec4b5f635d94111d48ec3c57fbe078d64e7d
libbpf: Handle non-standardly sized enums better in BTF-to-C dumper

Turns out C allows to force enum to be 1-byte or 8-byte explicitly using
mode(byte) or mode(word), respecticely. Linux sources are using this in
some cases. This is imporant to handle correctly, as enum size
determines corresponding fields in a struct that use that enum type. And
if enum size is incorrect, this will lead to invalid struct layout. So
add mode(byte) and mode(word) attribute support to btf_dump APIs.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20221212211505.558851-3-andrii@kernel.org
tools/lib/bpf/btf_dump.c