lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 27 Aug 2021 12:35:33 +0200
From:   Michal Suchánek <msuchanek@...e.de>
To:     bpf@...r.kernel.org
Cc:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>,
        Björn Töpel <bjorn@...nel.org>,
        Magnus Karlsson <magnus.karlsson@...el.com>,
        Jonathan Lemon <jonathan.lemon@...il.com>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        Patrick McCarty <patrick.mccarty@...el.com>
Subject: Re: [PATCH] libbpf: Fix build with latest gcc/binutils with LTO

Hello,

this is a duplicate of

https://patchwork.kernel.org/project/netdevbpf/patch/20210827072539.3399-1-msuchanek@suse.de/

Sorry aboit the noise.

On Fri, Aug 27, 2021 at 09:28:55AM +0200, Michal Suchanek wrote:
> From: Patrick McCarty <patrick.mccarty@...el.com>
> 
> After updating to binutils 2.35, the build began to fail with an
> assembler error. A bug was opened on the Red Hat Bugzilla a few days
> later for the same issue.
> 
> Work around the problem by using the new `symver` attribute (introduced
> in GCC 10) as needed, instead of the `COMPAT_VERSION` and
> `DEFAULT_VERSION` macros, which expand to assembler directives.
> 
> Fixes: https://github.com/libbpf/libbpf/issues/338
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1863059
> Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1188749
> Signed-off-by: Patrick McCarty <patrick.mccarty@...el.com>
> Make the change conditional on GCC version
> Signed-off-by: Michal Suchanek <msuchanek@...e.de>
> ---
>  tools/lib/bpf/libbpf_internal.h | 23 +++++++++++++++++------
>  tools/lib/bpf/xsk.c             |  4 ++--
>  2 files changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
> index 016ca7cb4f8a..af0f3fb102c0 100644
> --- a/tools/lib/bpf/libbpf_internal.h
> +++ b/tools/lib/bpf/libbpf_internal.h
> @@ -86,20 +86,31 @@
>  	(offsetof(TYPE, FIELD) + sizeof(((TYPE *)0)->FIELD))
>  #endif
>  
> +#ifdef __GNUC__
> +# if __GNUC__ >= 10
> +#  define DEFAULT_VERSION(internal_name, api_name, version) \
> +__attribute__((__symver__(#api_name "@@" #version)))
> +#  define COMPAT_VERSION(internal_name, api_name, version) \
> +__attribute__((__symver__(#api_name "@" #version)))
> +# endif
> +#endif
> +
> +#if !defined(COMPAT_VERSION) || !defined(DEFAULT_VERSION)
>  /* Symbol versioning is different between static and shared library.
>   * Properly versioned symbols are needed for shared library, but
>   * only the symbol of the new version is needed for static library.
>   */
> -#ifdef SHARED
> -# define COMPAT_VERSION(internal_name, api_name, version) \
> +# ifdef SHARED
> +#  define COMPAT_VERSION(internal_name, api_name, version) \
>  	asm(".symver " #internal_name "," #api_name "@" #version);
> -# define DEFAULT_VERSION(internal_name, api_name, version) \
> +#  define DEFAULT_VERSION(internal_name, api_name, version) \
>  	asm(".symver " #internal_name "," #api_name "@@" #version);
> -#else
> -# define COMPAT_VERSION(internal_name, api_name, version)
> -# define DEFAULT_VERSION(internal_name, api_name, version) \
> +# else
> +#  define COMPAT_VERSION(internal_name, api_name, version)
> +#  define DEFAULT_VERSION(internal_name, api_name, version) \
>  	extern typeof(internal_name) api_name \
>  	__attribute__((alias(#internal_name)));
> +# endif
>  #endif
>  
>  extern void libbpf_print(enum libbpf_print_level level,
> diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
> index e9b619aa0cdf..a2111696ba91 100644
> --- a/tools/lib/bpf/xsk.c
> +++ b/tools/lib/bpf/xsk.c
> @@ -281,6 +281,7 @@ static int xsk_create_umem_rings(struct xsk_umem *umem, int fd,
>  	return err;
>  }
>  
> +DEFAULT_VERSION(xsk_umem__create_v0_0_4, xsk_umem__create, LIBBPF_0.0.4)
>  int xsk_umem__create_v0_0_4(struct xsk_umem **umem_ptr, void *umem_area,
>  			    __u64 size, struct xsk_ring_prod *fill,
>  			    struct xsk_ring_cons *comp,
> @@ -345,6 +346,7 @@ struct xsk_umem_config_v1 {
>  	__u32 frame_headroom;
>  };
>  
> +COMPAT_VERSION(xsk_umem__create_v0_0_2, xsk_umem__create, LIBBPF_0.0.2)
>  int xsk_umem__create_v0_0_2(struct xsk_umem **umem_ptr, void *umem_area,
>  			    __u64 size, struct xsk_ring_prod *fill,
>  			    struct xsk_ring_cons *comp,
> @@ -358,8 +360,6 @@ int xsk_umem__create_v0_0_2(struct xsk_umem **umem_ptr, void *umem_area,
>  	return xsk_umem__create_v0_0_4(umem_ptr, umem_area, size, fill, comp,
>  					&config);
>  }
> -COMPAT_VERSION(xsk_umem__create_v0_0_2, xsk_umem__create, LIBBPF_0.0.2)
> -DEFAULT_VERSION(xsk_umem__create_v0_0_4, xsk_umem__create, LIBBPF_0.0.4)
>  
>  static enum xsk_prog get_xsk_prog(void)
>  {
> -- 
> 2.31.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ