From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>
Cc: "Toke Høiland-Jørgensen" <toke@redhat.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <kafai@fb.com>,
"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"KP Singh" <kpsingh@kernel.org>,
"Stanislav Fomichev" <sdf@google.com>,
bpf@vger.kernel.org
Subject: [PATCH bpf-next v2] libbpf: ignore .eh_frame sections when parsing elf files
Date: Thu, 26 Aug 2021 14:09:53 +0200 [thread overview]
Message-ID: <20210826120953.11041-1-toke@redhat.com> (raw)
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
next reply other threads:[~2021-08-26 12:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-26 12:09 Toke Høiland-Jørgensen [this message]
2021-08-30 21:49 ` [PATCH bpf-next v2] libbpf: ignore .eh_frame sections when parsing elf files 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210826120953.11041-1-toke@redhat.com \
--to=toke@redhat.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=sdf@google.com \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox