From: Andrii Nakryiko <andrii@kernel.org>
To: <dwarves@vger.kernel.org>, <acme@kernel.org>
Cc: <bpf@vger.kernel.org>, Andrii Nakryiko <andrii@kernel.org>
Subject: [PATCH dwarves] btf_encoder: ignore zero-sized ELF symbols
Date: Wed, 21 Oct 2020 08:52:20 -0700 [thread overview]
Message-ID: <20201021155220.1737964-1-andrii@kernel.org> (raw)
It's legal for ELF symbol to have size 0, if it's size is unknown or
unspecified. Instead of erroring out, just ignore such symbols, as they can't
be a valid per-CPU variable anyways.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
btf_encoder.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/btf_encoder.c b/btf_encoder.c
index 2a6455be4c52..2af1fe447834 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -287,6 +287,10 @@ static int find_all_percpu_vars(struct btf_elf *btfe)
if (!addr)
continue;
+ size = elf_sym__size(&sym);
+ if (!size)
+ continue; /* ignore zero-sized symbols */
+
sym_name = elf_sym__name(&sym, btfe->symtab);
if (!btf_name_valid(sym_name)) {
dump_invalid_symbol("Found symbol of invalid name when encoding btf",
@@ -295,14 +299,6 @@ static int find_all_percpu_vars(struct btf_elf *btfe)
continue;
return -1;
}
- size = elf_sym__size(&sym);
- if (!size) {
- dump_invalid_symbol("Found symbol of zero size when encoding btf",
- sym_name, btf_elf__verbose, btf_elf__force);
- if (btf_elf__force)
- continue;
- return -1;
- }
if (btf_elf__verbose)
printf("Found per-CPU symbol '%s' at address 0x%lx\n", sym_name, addr);
--
2.24.1
next reply other threads:[~2020-10-21 15:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-21 15:52 Andrii Nakryiko [this message]
2020-10-22 5:19 ` [PATCH dwarves] btf_encoder: ignore zero-sized ELF symbols Jiri Slaby
2020-10-23 16:37 ` Arnaldo Carvalho de Melo
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=20201021155220.1737964-1-andrii@kernel.org \
--to=andrii@kernel.org \
--cc=acme@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dwarves@vger.kernel.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).