selftests/bpf: Pass all BPF .o's through BPF static linker
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 18 Mar 2021 19:40:35 +0000 (12:40 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 18 Mar 2021 23:14:23 +0000 (16:14 -0700)
commit14137f3c62186799b01eea8a338f90c9cbc57f00
treed59d47aec376206418dae46347c49d8fcbb7c666
parentcab62c37be057379a2a17b1b2eacd9dcba1e14dc
selftests/bpf: Pass all BPF .o's through BPF static linker

Pass all individual BPF object files (generated from progs/*.c) through
`bpftool gen object` command to validate that BPF static linker doesn't
corrupt them.

As an additional sanity checks, validate that passing resulting object files
through linker again results in identical ELF files. Exact same ELF contents
can be guaranteed only after two passes, as after the first pass ELF sections
order changes, and thus .BTF.ext data sections order changes. That, in turn,
means that strings are added into the final BTF string sections in different
order, so .BTF strings data might not be exactly the same. But doing another
round of linking afterwards should result in the identical ELF file, which is
checked with additional `diff` command.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210318194036.3521577-12-andrii@kernel.org
tools/testing/selftests/bpf/Makefile