OSDN Git Service

libbpf: Accommodate DWARF/compiler bug with duplicated structs
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 17 Nov 2021 19:41:13 +0000 (11:41 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 19 Nov 2021 15:59:16 +0000 (16:59 +0100)
commitefdd3eb8015e7447095f02a26eaabd164cd18004
tree5d52ee72104bf80f3d4125983ee191216936940f
parent7615209f42a1976894cd0df97a380a034911656a
libbpf: Accommodate DWARF/compiler bug with duplicated structs

According to [0], compilers sometimes might produce duplicate DWARF
definitions for exactly the same struct/union within the same
compilation unit (CU). We've had similar issues with identical arrays
and handled them with a similar workaround in 6b6e6b1d09aa ("libbpf:
Accomodate DWARF/compiler bug with duplicated identical arrays"). Do the
same for struct/union by ensuring that two structs/unions are exactly
the same, down to the integer values of field referenced type IDs.

Solving this more generically (allowing referenced types to be
equivalent, but using different type IDs, all within a single CU)
requires a huge complexity increase to handle many-to-many mappings
between canonidal and candidate type graphs. Before we invest in that,
let's see if this approach handles all the instances of this issue in
practice. Thankfully it's pretty rare, it seems.

  [0] https://lore.kernel.org/bpf/YXr2NFlJTAhHdZqq@krava/

Reported-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20211117194114.347675-1-andrii@kernel.org
tools/lib/bpf/btf.c