* [PATCH dwarves] btf_encoder: ignore zero-sized ELF symbols
@ 2020-10-21 15:52 Andrii Nakryiko
2020-10-22 5:19 ` Jiri Slaby
0 siblings, 1 reply; 3+ messages in thread
From: Andrii Nakryiko @ 2020-10-21 15:52 UTC (permalink / raw)
To: dwarves, acme; +Cc: bpf, Andrii Nakryiko
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH dwarves] btf_encoder: ignore zero-sized ELF symbols
2020-10-21 15:52 [PATCH dwarves] btf_encoder: ignore zero-sized ELF symbols Andrii Nakryiko
@ 2020-10-22 5:19 ` Jiri Slaby
2020-10-23 16:37 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Slaby @ 2020-10-22 5:19 UTC (permalink / raw)
To: Andrii Nakryiko, dwarves, acme; +Cc: bpf
On 21. 10. 20, 17:52, Andrii Nakryiko wrote:
> 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>
Tested-by: Jiri Slaby <jirislaby@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);
>
--
js
suse labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH dwarves] btf_encoder: ignore zero-sized ELF symbols
2020-10-22 5:19 ` Jiri Slaby
@ 2020-10-23 16:37 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-10-23 16:37 UTC (permalink / raw)
To: Jiri Slaby; +Cc: Andrii Nakryiko, dwarves, bpf
Em Thu, Oct 22, 2020 at 07:19:32AM +0200, Jiri Slaby escreveu:
> On 21. 10. 20, 17:52, Andrii Nakryiko wrote:
> > 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>
>
> Tested-by: Jiri Slaby <jirislaby@kernel.org>
thanks applied
> > ---
> > 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);
> >
>
>
> --
> js
> suse labs
--
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-23 16:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21 15:52 [PATCH dwarves] btf_encoder: ignore zero-sized ELF symbols Andrii Nakryiko
2020-10-22 5:19 ` Jiri Slaby
2020-10-23 16:37 ` Arnaldo Carvalho de Melo
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 NNTP newsgroup(s).