Merge branch 'bpf-static-linker-fix-linking-duplicate-extern-functions'
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 8 Oct 2024 03:28:53 +0000 (20:28 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 8 Oct 2024 03:28:54 +0000 (20:28 -0700)
Eric Long via says:

====================
BPF static linker: fix linking duplicate extern functions

Currently, if `bpftool gen object` tries to link two objects that
contains the same extern function prototype, libbpf will try to get
their (non-existent) size by calling bpf__resolve_size like extern
variables and fail with:

libbpf: global 'whatever': failed to resolve size of underlying type: -22

This should not be the case, and this series adds conditions to update
size only when the BTF kind is not function.

Fixes: a46349227cd8 ("libbpf: Add linker extern resolution support for functions and global variables")
Signed-off-by: Eric Long <i@hack3r.moe>
---
Changes in v4:
- Remove redundant FUNC_PROTO check.
- Merge tests into linked_funcs.
- Link to v3: https://lore.kernel.org/r/20241001-libbpf-dup-extern-funcs-v3-0-42f7774efbf3@hack3r.moe

Changes in v3:
- Simplifiy changes and shorten subjects, according to reviews.
- Remove unused includes in selftests.
- Link to v2: https://lore.kernel.org/r/20240929-libbpf-dup-extern-funcs-v2-0-0cc81de3f79f@hack3r.moe

Changes in v2:
- Fix compile errors. Oops!
- Link to v1: https://lore.kernel.org/r/20240929-libbpf-dup-extern-funcs-v1-0-df15fbd6525b@hack3r.moe

---
====================

Link: https://lore.kernel.org/r/20241002-libbpf-dup-extern-funcs-v4-0-560eb460ff90@hack3r.moe
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

Trivial merge