diff options
author | Alexei Starovoitov <ast@kernel.org> | 2019-10-09 15:38:37 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-10-09 15:38:45 -0700 |
commit | f1177102454e1832b9814051f2b071a8285581ea (patch) | |
tree | f57b2f1c024d8461b12d43dc66fc0e7e1de13af2 /tools/lib/bpf/btf_dump.c | |
parent | f05c2001ecc98629cecd47728e4db11e5a17e58d (diff) | |
parent | 76790c7c66ccc8695afc75e73f54c0ca86267ed2 (diff) |
Merge branch 'btf2c-padding'
Andrii Nakryiko says:
====================
Fix BTF-to-C logic of handling padding at the end of a struct. Fix existing
test that should have captured this. Also move test_btf_dump into a test_progs
test to leverage common infrastructure.
====================
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/lib/bpf/btf_dump.c')
-rw-r--r-- | tools/lib/bpf/btf_dump.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c index ede55fec3618..87f27e2664c5 100644 --- a/tools/lib/bpf/btf_dump.c +++ b/tools/lib/bpf/btf_dump.c @@ -876,7 +876,6 @@ static void btf_dump_emit_struct_def(struct btf_dump *d, __u16 vlen = btf_vlen(t); packed = is_struct ? btf_is_struct_packed(d->btf, id, t) : 0; - align = packed ? 1 : btf_align_of(d->btf, id); btf_dump_printf(d, "%s%s%s {", is_struct ? "struct" : "union", @@ -906,6 +905,13 @@ static void btf_dump_emit_struct_def(struct btf_dump *d, btf_dump_printf(d, ";"); } + /* pad at the end, if necessary */ + if (is_struct) { + align = packed ? 1 : btf_align_of(d->btf, id); + btf_dump_emit_bit_padding(d, off, t->size * 8, 0, align, + lvl + 1); + } + if (vlen) btf_dump_printf(d, "\n"); btf_dump_printf(d, "%s}", pfx(lvl)); |