All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v2] libbpf: ignore .eh_frame sections when parsing elf files
@ 2021-08-26 12:09 Toke Høiland-Jørgensen
  2021-08-30 21:49 ` Andrii Nakryiko
  0 siblings, 1 reply; 12+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-08-26 12:09 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Toke Høiland-Jørgensen, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, bpf

When .eh_frame and .rel.eh_frame sections are present in BPF object files,
libbpf produces errors like this when loading the file:

libbpf: elf: skipping unrecognized data section(32) .eh_frame
libbpf: elf: skipping relo section(33) .rel.eh_frame for section(32) .eh_frame

It is possible to get rid of the .eh_frame section by adding
-fno-asynchronous-unwind-tables to the compilation, but we have seen
multiple examples of these sections appearing in BPF files in the wild,
most recently in samples/bpf, fixed by:
5a0ae9872d5c ("bpf, samples: Add -fno-asynchronous-unwind-tables to BPF Clang invocation")

While the errors are technically harmless, they look odd and confuse users.
So let's make libbpf filter out those sections, by adding .eh_frame to the
filter check in is_sec_name_dwarf().

v2:
- Expand explanation in the commit message

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 tools/lib/bpf/libbpf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 88d8825fc6f6..b1dc97b95965 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -2909,7 +2909,8 @@ static Elf_Data *elf_sec_data(const struct bpf_object *obj, Elf_Scn *scn)
 static bool is_sec_name_dwarf(const char *name)
 {
 	/* approximation, but the actual list is too long */
-	return strncmp(name, ".debug_", sizeof(".debug_") - 1) == 0;
+	return (strncmp(name, ".debug_", sizeof(".debug_") - 1) == 0 ||
+		strncmp(name, ".eh_frame", sizeof(".eh_frame") - 1) == 0);
 }
 
 static bool ignore_elf_section(GElf_Shdr *hdr, const char *name)
-- 
2.33.0


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

end of thread, other threads:[~2021-09-07 22:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26 12:09 [PATCH bpf-next v2] libbpf: ignore .eh_frame sections when parsing elf files Toke Høiland-Jørgensen
2021-08-30 21:49 ` Andrii Nakryiko
2021-08-31 10:28   ` Toke Høiland-Jørgensen
2021-08-31 23:11     ` Andrii Nakryiko
2021-09-02  2:48     ` Yonghong Song
2021-09-02 17:08       ` Toke Høiland-Jørgensen
2021-09-02 19:32         ` Alexei Starovoitov
2021-09-02 21:54           ` Yonghong Song
2021-09-02 22:08             ` Toke Høiland-Jørgensen
2021-09-07 19:15               ` Yonghong Song
2021-09-07 19:36                 ` Toke Høiland-Jørgensen
2021-09-07 22:24                   ` Yonghong Song

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.