Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-23 Thread Andrii Nakryiko
On Sat, Jan 23, 2021 at 1:23 PM Jiri Olsa wrote: > > On Thu, Jan 21, 2021 at 03:32:40PM -0800, Andrii Nakryiko wrote: > > SNIP > > > But the current variant looks broken. Oh, and > > elf_symtab__for_each_symbol() is similarly broken, can you please fix > > that as well? > > we'll have to change it

Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-23 Thread Jiri Olsa
On Thu, Jan 21, 2021 at 03:32:40PM -0800, Andrii Nakryiko wrote: SNIP > But the current variant looks broken. Oh, and > elf_symtab__for_each_symbol() is similarly broken, can you please fix > that as well? we'll have to change its callers a bit, because of hanging 'else' I'll send this separatel

Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-23 Thread Mark Wielaard
Hi, On Sat, 2021-01-23 at 12:07 -0800, Andrii Nakryiko wrote: > > the latest upstream code seems to set it always, > > but I agree we should be careful > > oh, then maybe it's not necessary. I honestly don't even know where > the authoritative source code of libelf is, so I just found some > rand

Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-23 Thread Mark Wielaard
Hi Jiri, On Sat, 2021-01-23 at 19:51 +0100, Jiri Olsa wrote: > On Fri, Jan 22, 2021 at 02:55:51PM -0800, Andrii Nakryiko wrote: > > > > > I don't understand this.. gelf_getsymshndx will return both > > > symbol and proper index, no? also sym_sec_idx is already > > > assigned from previou call >

Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-23 Thread Jiri Olsa
On Sat, Jan 23, 2021 at 09:08:15PM +0100, Mark Wielaard wrote: > Hi Jiri, > > On Sat, 2021-01-23 at 19:51 +0100, Jiri Olsa wrote: > > On Fri, Jan 22, 2021 at 02:55:51PM -0800, Andrii Nakryiko wrote: > > > > > > > I don't understand this.. gelf_getsymshndx will return both > > > > symbol and prop

Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-23 Thread Andrii Nakryiko
On Sat, Jan 23, 2021 at 10:51 AM Jiri Olsa wrote: > > On Fri, Jan 22, 2021 at 02:55:51PM -0800, Andrii Nakryiko wrote: > > On Fri, Jan 22, 2021 at 12:47 PM Jiri Olsa wrote: > > > > > > On Thu, Jan 21, 2021 at 03:32:40PM -0800, Andrii Nakryiko wrote: > > > > > > SNIP > > > > > > > > @@ -598,9 +599

Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-23 Thread Jiri Olsa
On Fri, Jan 22, 2021 at 02:55:51PM -0800, Andrii Nakryiko wrote: > On Fri, Jan 22, 2021 at 12:47 PM Jiri Olsa wrote: > > > > On Thu, Jan 21, 2021 at 03:32:40PM -0800, Andrii Nakryiko wrote: > > > > SNIP > > > > > > @@ -598,9 +599,36 @@ static void collect_symbol(GElf_Sym *sym, struct > > > > func

Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-22 Thread Andrii Nakryiko
On Fri, Jan 22, 2021 at 12:47 PM Jiri Olsa wrote: > > On Thu, Jan 21, 2021 at 03:32:40PM -0800, Andrii Nakryiko wrote: > > SNIP > > > > @@ -598,9 +599,36 @@ static void collect_symbol(GElf_Sym *sym, struct > > > funcs_layout *fl) > > > fl->mcount_stop = sym->st_value; > > > } > >

Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-22 Thread Jiri Olsa
On Thu, Jan 21, 2021 at 03:32:40PM -0800, Andrii Nakryiko wrote: SNIP > > @@ -598,9 +599,36 @@ static void collect_symbol(GElf_Sym *sym, struct > > funcs_layout *fl) > > fl->mcount_stop = sym->st_value; > > } > > > > +static bool elf_sym__get(Elf_Data *syms, Elf_Data *syms_sec_i

Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-22 Thread Jiri Olsa
On Thu, Jan 21, 2021 at 03:32:40PM -0800, Andrii Nakryiko wrote: > On Thu, Jan 21, 2021 at 12:25 PM Jiri Olsa wrote: > > > > For very large ELF objects (with many sections), we could > > get special value SHN_XINDEX (65535) for symbol's st_shndx. > > > > This patch is adding code to detect the opt

Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-21 Thread Andrii Nakryiko
On Thu, Jan 21, 2021 at 12:25 PM Jiri Olsa wrote: > > For very large ELF objects (with many sections), we could > get special value SHN_XINDEX (65535) for symbol's st_shndx. > > This patch is adding code to detect the optional extended > section index table and use it to resolve symbol's section >

[PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-21 Thread Jiri Olsa
For very large ELF objects (with many sections), we could get special value SHN_XINDEX (65535) for symbol's st_shndx. This patch is adding code to detect the optional extended section index table and use it to resolve symbol's section index. Adding elf_symtab__for_each_symbol_index macro that ret

Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-20 Thread Jiri Olsa
On Tue, Jan 19, 2021 at 06:03:28PM -0800, Andrii Nakryiko wrote: > On Tue, Jan 19, 2021 at 2:16 PM Jiri Olsa wrote: > > > > For very large ELF objects (with many sections), we could > > get special value SHN_XINDEX (65535) for symbol's st_shndx. > > > > This patch is adding code to detect the opti

Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-19 Thread Andrii Nakryiko
On Tue, Jan 19, 2021 at 2:16 PM Jiri Olsa wrote: > > For very large ELF objects (with many sections), we could > get special value SHN_XINDEX (65535) for symbol's st_shndx. > > This patch is adding code to detect the optional extended > section index table and use it to resolve symbol's section >

[PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values

2021-01-19 Thread Jiri Olsa
For very large ELF objects (with many sections), we could get special value SHN_XINDEX (65535) for symbol's st_shndx. This patch is adding code to detect the optional extended section index table and use it to resolve symbol's section index id needed. Signed-off-by: Jiri Olsa --- btf_encoder.c