BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v4 0/2] BPF static linker: fix linking duplicate extern functions
@ 2024-10-02  6:25 Eric Long via B4 Relay
  2024-10-02  6:25 ` [PATCH bpf-next v4 1/2] libbpf: do not resolve size on duplicate FUNCs Eric Long via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Long via B4 Relay @ 2024-10-02  6:25 UTC (permalink / raw)
  To: bpf; +Cc: Andrii Nakryiko, Alexei Starovoitov, netdev, Eric Long

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

---
Eric Long (2):
      libbpf: do not resolve size on duplicate FUNCs
      selftests/bpf: test linking with duplicate extern functions

 tools/lib/bpf/linker.c                            | 4 ++++
 tools/testing/selftests/bpf/progs/linked_funcs1.c | 8 ++++++++
 tools/testing/selftests/bpf/progs/linked_funcs2.c | 8 ++++++++
 3 files changed, 20 insertions(+)
---
base-commit: 93eeaab4563cc7fc0309bc1c4d301139762bbd60
change-id: 20240929-libbpf-dup-extern-funcs-871f4bad2122

Best regards,
-- 
Eric Long <i@hack3r.moe>



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-08  3:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-02  6:25 [PATCH bpf-next v4 0/2] BPF static linker: fix linking duplicate extern functions Eric Long via B4 Relay
2024-10-02  6:25 ` [PATCH bpf-next v4 1/2] libbpf: do not resolve size on duplicate FUNCs Eric Long via B4 Relay
2024-10-02  6:25 ` [PATCH bpf-next v4 2/2] selftests/bpf: test linking with duplicate extern functions Eric Long via B4 Relay
2024-10-08  3:30 ` [PATCH bpf-next v4 0/2] BPF static linker: fix linking " patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox