Skip to content

Commit

Permalink
selftests/bpf: Test btf dump for struct with padding only fields
Browse files Browse the repository at this point in the history
[ Upstream commit d503f11 ]

Structures with zero regular fields but some padding constitute a
special case in btf_dump.c:btf_dump_emit_struct_def with regards to
newline before closing '}'.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20221001104425.415768-2-eddyz87@gmail.com
Stable-dep-of: ea2ce1b ("libbpf: Fix BTF-to-C converter's padding logic")
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Eduard Zingerman authored and Greg Kroah-Hartman committed Apr 5, 2023
1 parent f1c1747 commit b9f7422
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,21 @@ struct zone {
struct zone_padding __pad__;
};

/* ----- START-EXPECTED-OUTPUT ----- */
struct padding_wo_named_members {
long: 64;
long: 64;
};

/* ------ END-EXPECTED-OUTPUT ------ */

int f(struct {
struct padded_implicitly _1;
struct padded_explicitly _2;
struct padded_a_lot _3;
struct padded_cache_line _4;
struct zone _5;
struct padding_wo_named_members _6;
} *_)
{
return 0;
Expand Down

0 comments on commit b9f7422

Please sign in to comment.