Re: [PATCH 5.8 35/99] tools/libbpf: Avoid counting local symbols in ABI check

2020-09-30 Thread Justin Forbes
On Wed, Sep 30, 2020 at 12:02 AM Tony Ambardar  wrote:
>
> [adding Michael Ellerman, linux-ppc maintainer]
>
> Hello Justin,
>
> On Tue, 29 Sep 2020 at 14:54, Justin Forbes  wrote:
> >
> > On Tue, Sep 29, 2020 at 6:53 AM Greg Kroah-Hartman
> >  wrote:
> > >
> > > From: Tony Ambardar 
> > >
> > > [ Upstream commit 746f534a4809e07f427f7d13d10f3a6a9641e5c3 ]
> > >
> > > Encountered the following failure building libbpf from kernel 5.8.5 
> > > sources
> > > with GCC 8.4.0 and binutils 2.34: (long paths shortened)
> > >
> > >   Warning: Num of global symbols in sharedobjs/libbpf-in.o (234) does NOT
> > >   match with num of versioned symbols in libbpf.so (236). Please make sure
> > >   all LIBBPF_API symbols are versioned in libbpf.map.
> > > #  --- libbpf_global_syms.tmp2020-09-02 07:30:58.920084380 +
> > > #  +++ libbpf_versioned_syms.tmp 2020-09-02 07:30:58.924084388 +
> > >   @@ -1,3 +1,5 @@
> > >   +_fini
> > >   +_init
> > >bpf_btf_get_fd_by_id
> > >bpf_btf_get_next_id
> > >bpf_create_map
> > >   make[4]: *** [Makefile:210: check_abi] Error 1
> > >
> > > Investigation shows _fini and _init are actually local symbols counted
> > > amongst global ones:
> > >
> > >   $ readelf --dyn-syms --wide libbpf.so|head -10
> > >
> > >   Symbol table '.dynsym' contains 343 entries:
> > >  Num:Value  Size TypeBind   Vis  Ndx Name
> > >0:  0 NOTYPE  LOCAL  DEFAULT  UND
> > >1: 4098 0 SECTION LOCAL  DEFAULT   11
> > >2: 4098 8 FUNCLOCAL  DEFAULT   11 _init@@LIBBPF_0.0.1
> > >3: 00023040 8 FUNCLOCAL  DEFAULT   14 _fini@@LIBBPF_0.0.1
> > >4:  0 OBJECT  GLOBAL DEFAULT  ABS LIBBPF_0.0.4
> > >5:  0 OBJECT  GLOBAL DEFAULT  ABS LIBBPF_0.0.1
> > >6: ffa4 8 FUNCGLOBAL DEFAULT   12 
> > > bpf_object__find_map_by_offset@@LIBBPF_0.0.1
> > >
> > > A previous commit filtered global symbols in sharedobjs/libbpf-in.o. Do 
> > > the
> > > same with the libbpf.so DSO for consistent comparison.
> > >
> > > Fixes: 306b267cb3c4 ("libbpf: Verify versioned symbols")
> > > Signed-off-by: Tony Ambardar 
> > > Signed-off-by: Alexei Starovoitov 
> > > Acked-by: Andrii Nakryiko 
> > > Link: 
> > > https://lore.kernel.org/bpf/20200905214831.1565465-1-tony.ambar...@gmail.com
> > > Signed-off-by: Sasha Levin 
> >
> > This seems to work everywhere else, but breaks PPC64LE.
> >
>
> I also ran into a PPC build error while working on some bpf problems,
> but it seemed
> like a pre-existing PPC issue. I did submit an upstream fix, which is
> marked for stable
> and being reviewed by Michael. See here for discussion and the patch:
> https://lkml.org/lkml/2020/9/17/668.
>
> Is that the same problem you encountered? Does that patch address your issue?

It is not, the issue I see is:
Warning: Num of global symbols in sharedobjs/libbpf-in.o (259) does
NOT match with num of versioned symbols in libbpf.so (50). Please make
sure all LIBBPF_API symbols are versioned in libbpf.map.

I only see it on ppc64le with this patch, all other arch that Fedora
builds are fine (x86_64, i686, aarch64, armv7, s390).  If I revert
this patch, all builds succeed.  We are using gcc 10.2.1 though.

Justin

>
> Thanks,
> Tony
>
> > Justin
> >
> > > ---
> > >  tools/lib/bpf/Makefile |2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > --- a/tools/lib/bpf/Makefile
> > > +++ b/tools/lib/bpf/Makefile
> > > @@ -152,6 +152,7 @@ GLOBAL_SYM_COUNT = $(shell readelf -s --
> > >awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print 
> > > $$NF}' | \
> > >sort -u | wc -l)
> > >  VERSIONED_SYM_COUNT = $(shell readelf --dyn-syms --wide 
> > > $(OUTPUT)libbpf.so | \
> > > + awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print 
> > > $$NF}' | \
> > >   grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | 
> > > sort -u | wc -l)
> > >
> > >  CMD_TARGETS = $(LIB_TARGET) $(PC_FILE)
> > > @@ -219,6 +220,7 @@ check_abi: $(OUTPUT)libbpf.so
> > > awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'|  \
> > > sort -u > $(OUTPUT)libbpf_global_syms.tmp;   \
> > > readelf --dyn-syms --wide $(OUTPUT)libbpf.so |   \
> > > +   awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'|  \
> > > grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | \
> > > sort -u > $(OUTPUT)libbpf_versioned_syms.tmp;\
> > > diff -u $(OUTPUT)libbpf_global_syms.tmp  \
> > >
> > >


Re: [PATCH 5.8 35/99] tools/libbpf: Avoid counting local symbols in ABI check

2020-09-29 Thread Tony Ambardar
[adding Michael Ellerman, linux-ppc maintainer]

Hello Justin,

On Tue, 29 Sep 2020 at 14:54, Justin Forbes  wrote:
>
> On Tue, Sep 29, 2020 at 6:53 AM Greg Kroah-Hartman
>  wrote:
> >
> > From: Tony Ambardar 
> >
> > [ Upstream commit 746f534a4809e07f427f7d13d10f3a6a9641e5c3 ]
> >
> > Encountered the following failure building libbpf from kernel 5.8.5 sources
> > with GCC 8.4.0 and binutils 2.34: (long paths shortened)
> >
> >   Warning: Num of global symbols in sharedobjs/libbpf-in.o (234) does NOT
> >   match with num of versioned symbols in libbpf.so (236). Please make sure
> >   all LIBBPF_API symbols are versioned in libbpf.map.
> > #  --- libbpf_global_syms.tmp2020-09-02 07:30:58.920084380 +
> > #  +++ libbpf_versioned_syms.tmp 2020-09-02 07:30:58.924084388 +
> >   @@ -1,3 +1,5 @@
> >   +_fini
> >   +_init
> >bpf_btf_get_fd_by_id
> >bpf_btf_get_next_id
> >bpf_create_map
> >   make[4]: *** [Makefile:210: check_abi] Error 1
> >
> > Investigation shows _fini and _init are actually local symbols counted
> > amongst global ones:
> >
> >   $ readelf --dyn-syms --wide libbpf.so|head -10
> >
> >   Symbol table '.dynsym' contains 343 entries:
> >  Num:Value  Size TypeBind   Vis  Ndx Name
> >0:  0 NOTYPE  LOCAL  DEFAULT  UND
> >1: 4098 0 SECTION LOCAL  DEFAULT   11
> >2: 4098 8 FUNCLOCAL  DEFAULT   11 _init@@LIBBPF_0.0.1
> >3: 00023040 8 FUNCLOCAL  DEFAULT   14 _fini@@LIBBPF_0.0.1
> >4:  0 OBJECT  GLOBAL DEFAULT  ABS LIBBPF_0.0.4
> >5:  0 OBJECT  GLOBAL DEFAULT  ABS LIBBPF_0.0.1
> >6: ffa4 8 FUNCGLOBAL DEFAULT   12 
> > bpf_object__find_map_by_offset@@LIBBPF_0.0.1
> >
> > A previous commit filtered global symbols in sharedobjs/libbpf-in.o. Do the
> > same with the libbpf.so DSO for consistent comparison.
> >
> > Fixes: 306b267cb3c4 ("libbpf: Verify versioned symbols")
> > Signed-off-by: Tony Ambardar 
> > Signed-off-by: Alexei Starovoitov 
> > Acked-by: Andrii Nakryiko 
> > Link: 
> > https://lore.kernel.org/bpf/20200905214831.1565465-1-tony.ambar...@gmail.com
> > Signed-off-by: Sasha Levin 
>
> This seems to work everywhere else, but breaks PPC64LE.
>

I also ran into a PPC build error while working on some bpf problems,
but it seemed
like a pre-existing PPC issue. I did submit an upstream fix, which is
marked for stable
and being reviewed by Michael. See here for discussion and the patch:
https://lkml.org/lkml/2020/9/17/668.

Is that the same problem you encountered? Does that patch address your issue?

Thanks,
Tony

> Justin
>
> > ---
> >  tools/lib/bpf/Makefile |2 ++
> >  1 file changed, 2 insertions(+)
> >
> > --- a/tools/lib/bpf/Makefile
> > +++ b/tools/lib/bpf/Makefile
> > @@ -152,6 +152,7 @@ GLOBAL_SYM_COUNT = $(shell readelf -s --
> >awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print 
> > $$NF}' | \
> >sort -u | wc -l)
> >  VERSIONED_SYM_COUNT = $(shell readelf --dyn-syms --wide $(OUTPUT)libbpf.so 
> > | \
> > + awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print 
> > $$NF}' | \
> >   grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | sort 
> > -u | wc -l)
> >
> >  CMD_TARGETS = $(LIB_TARGET) $(PC_FILE)
> > @@ -219,6 +220,7 @@ check_abi: $(OUTPUT)libbpf.so
> > awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'|  \
> > sort -u > $(OUTPUT)libbpf_global_syms.tmp;   \
> > readelf --dyn-syms --wide $(OUTPUT)libbpf.so |   \
> > +   awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'|  \
> > grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | \
> > sort -u > $(OUTPUT)libbpf_versioned_syms.tmp;\
> > diff -u $(OUTPUT)libbpf_global_syms.tmp  \
> >
> >


Re: [PATCH 5.8 35/99] tools/libbpf: Avoid counting local symbols in ABI check

2020-09-29 Thread Justin Forbes
On Tue, Sep 29, 2020 at 6:53 AM Greg Kroah-Hartman
 wrote:
>
> From: Tony Ambardar 
>
> [ Upstream commit 746f534a4809e07f427f7d13d10f3a6a9641e5c3 ]
>
> Encountered the following failure building libbpf from kernel 5.8.5 sources
> with GCC 8.4.0 and binutils 2.34: (long paths shortened)
>
>   Warning: Num of global symbols in sharedobjs/libbpf-in.o (234) does NOT
>   match with num of versioned symbols in libbpf.so (236). Please make sure
>   all LIBBPF_API symbols are versioned in libbpf.map.
> #  --- libbpf_global_syms.tmp2020-09-02 07:30:58.920084380 +
> #  +++ libbpf_versioned_syms.tmp 2020-09-02 07:30:58.924084388 +
>   @@ -1,3 +1,5 @@
>   +_fini
>   +_init
>bpf_btf_get_fd_by_id
>bpf_btf_get_next_id
>bpf_create_map
>   make[4]: *** [Makefile:210: check_abi] Error 1
>
> Investigation shows _fini and _init are actually local symbols counted
> amongst global ones:
>
>   $ readelf --dyn-syms --wide libbpf.so|head -10
>
>   Symbol table '.dynsym' contains 343 entries:
>  Num:Value  Size TypeBind   Vis  Ndx Name
>0:  0 NOTYPE  LOCAL  DEFAULT  UND
>1: 4098 0 SECTION LOCAL  DEFAULT   11
>2: 4098 8 FUNCLOCAL  DEFAULT   11 _init@@LIBBPF_0.0.1
>3: 00023040 8 FUNCLOCAL  DEFAULT   14 _fini@@LIBBPF_0.0.1
>4:  0 OBJECT  GLOBAL DEFAULT  ABS LIBBPF_0.0.4
>5:  0 OBJECT  GLOBAL DEFAULT  ABS LIBBPF_0.0.1
>6: ffa4 8 FUNCGLOBAL DEFAULT   12 
> bpf_object__find_map_by_offset@@LIBBPF_0.0.1
>
> A previous commit filtered global symbols in sharedobjs/libbpf-in.o. Do the
> same with the libbpf.so DSO for consistent comparison.
>
> Fixes: 306b267cb3c4 ("libbpf: Verify versioned symbols")
> Signed-off-by: Tony Ambardar 
> Signed-off-by: Alexei Starovoitov 
> Acked-by: Andrii Nakryiko 
> Link: 
> https://lore.kernel.org/bpf/20200905214831.1565465-1-tony.ambar...@gmail.com
> Signed-off-by: Sasha Levin 

This seems to work everywhere else, but breaks PPC64LE.

Justin

> ---
>  tools/lib/bpf/Makefile |2 ++
>  1 file changed, 2 insertions(+)
>
> --- a/tools/lib/bpf/Makefile
> +++ b/tools/lib/bpf/Makefile
> @@ -152,6 +152,7 @@ GLOBAL_SYM_COUNT = $(shell readelf -s --
>awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}' 
> | \
>sort -u | wc -l)
>  VERSIONED_SYM_COUNT = $(shell readelf --dyn-syms --wide $(OUTPUT)libbpf.so | 
> \
> + awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print 
> $$NF}' | \
>   grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | sort 
> -u | wc -l)
>
>  CMD_TARGETS = $(LIB_TARGET) $(PC_FILE)
> @@ -219,6 +220,7 @@ check_abi: $(OUTPUT)libbpf.so
> awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'|  \
> sort -u > $(OUTPUT)libbpf_global_syms.tmp;   \
> readelf --dyn-syms --wide $(OUTPUT)libbpf.so |   \
> +   awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'|  \
> grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | \
> sort -u > $(OUTPUT)libbpf_versioned_syms.tmp;\
> diff -u $(OUTPUT)libbpf_global_syms.tmp  \
>
>


[PATCH 5.8 35/99] tools/libbpf: Avoid counting local symbols in ABI check

2020-09-29 Thread Greg Kroah-Hartman
From: Tony Ambardar 

[ Upstream commit 746f534a4809e07f427f7d13d10f3a6a9641e5c3 ]

Encountered the following failure building libbpf from kernel 5.8.5 sources
with GCC 8.4.0 and binutils 2.34: (long paths shortened)

  Warning: Num of global symbols in sharedobjs/libbpf-in.o (234) does NOT
  match with num of versioned symbols in libbpf.so (236). Please make sure
  all LIBBPF_API symbols are versioned in libbpf.map.
#  --- libbpf_global_syms.tmp2020-09-02 07:30:58.920084380 +
#  +++ libbpf_versioned_syms.tmp 2020-09-02 07:30:58.924084388 +
  @@ -1,3 +1,5 @@
  +_fini
  +_init
   bpf_btf_get_fd_by_id
   bpf_btf_get_next_id
   bpf_create_map
  make[4]: *** [Makefile:210: check_abi] Error 1

Investigation shows _fini and _init are actually local symbols counted
amongst global ones:

  $ readelf --dyn-syms --wide libbpf.so|head -10

  Symbol table '.dynsym' contains 343 entries:
 Num:Value  Size TypeBind   Vis  Ndx Name
   0:  0 NOTYPE  LOCAL  DEFAULT  UND
   1: 4098 0 SECTION LOCAL  DEFAULT   11
   2: 4098 8 FUNCLOCAL  DEFAULT   11 _init@@LIBBPF_0.0.1
   3: 00023040 8 FUNCLOCAL  DEFAULT   14 _fini@@LIBBPF_0.0.1
   4:  0 OBJECT  GLOBAL DEFAULT  ABS LIBBPF_0.0.4
   5:  0 OBJECT  GLOBAL DEFAULT  ABS LIBBPF_0.0.1
   6: ffa4 8 FUNCGLOBAL DEFAULT   12 
bpf_object__find_map_by_offset@@LIBBPF_0.0.1

A previous commit filtered global symbols in sharedobjs/libbpf-in.o. Do the
same with the libbpf.so DSO for consistent comparison.

Fixes: 306b267cb3c4 ("libbpf: Verify versioned symbols")
Signed-off-by: Tony Ambardar 
Signed-off-by: Alexei Starovoitov 
Acked-by: Andrii Nakryiko 
Link: 
https://lore.kernel.org/bpf/20200905214831.1565465-1-tony.ambar...@gmail.com
Signed-off-by: Sasha Levin 
---
 tools/lib/bpf/Makefile |2 ++
 1 file changed, 2 insertions(+)

--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -152,6 +152,7 @@ GLOBAL_SYM_COUNT = $(shell readelf -s --
   awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}' | 
\
   sort -u | wc -l)
 VERSIONED_SYM_COUNT = $(shell readelf --dyn-syms --wide $(OUTPUT)libbpf.so | \
+ awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print 
$$NF}' | \
  grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | sort -u 
| wc -l)
 
 CMD_TARGETS = $(LIB_TARGET) $(PC_FILE)
@@ -219,6 +220,7 @@ check_abi: $(OUTPUT)libbpf.so
awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'|  \
sort -u > $(OUTPUT)libbpf_global_syms.tmp;   \
readelf --dyn-syms --wide $(OUTPUT)libbpf.so |   \
+   awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'|  \
grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | \
sort -u > $(OUTPUT)libbpf_versioned_syms.tmp;\
diff -u $(OUTPUT)libbpf_global_syms.tmp  \