Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp822784ybl; Wed, 11 Dec 2019 08:03:23 -0800 (PST) X-Google-Smtp-Source: APXvYqwKrpHyAIdfoHdlNOz4dW/x1mi0NJW5QplmJk02oI9dkt9VinDBaFFjOfBTsnaesuVeapr0 X-Received: by 2002:aca:520b:: with SMTP id g11mr3453039oib.167.1576080202971; Wed, 11 Dec 2019 08:03:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576080202; cv=none; d=google.com; s=arc-20160816; b=CekqobuYMUM4ml73C7LaD1YRaAR1GdYEueJKCKpgVb1Wvga/44sKGoAwU658WadolZ /cu/4cG2duCSs3Kuw4N22jtm2/FXAXmy9qpouyA3vt0BOK2QPchA8pnW4x0U4mucb2rO T9GzVa9exNugscl8ULlo7MGbiMn8W2Ysxj/XztynxjnfqrAZvfA87nhIJAl7xCDwjyGC r+BYrHXQbjt3JvIiMzefIslqQJmPTnXJ2PxVTy+OJ9enSftwQZBQRQDNFrNLDWRsIUDp lQQx280lnN6lMcQOv3agXK/cD0mAaMrc9l1y7siArYeEXYRzhOrf45irrbowkBMnCkNU /P9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=WLVxOoD5eDxv4TKbuLmKsZj8TLV5ERD8Pg0e055rx+I=; b=DnVeUxsO9U+17PURJtH5zLQJWCyr/g7PO5bGJqkIyxKMY8GK/CteDLA3au2LLaTKBf Mrly58/MkEd2M6Z51wTjn3lodPfPTvCDS+N70uo9celTDvQ5vfbdhw016FTt2lH9MQYw 3t2aDRhVuxFrY+lR7xA1W3vhFJ0K98SaKxLubLL8D6AkzX78GfPWsDJkoUDOl0uMqntg RNWDZT6Pvfi812Aq8uzjE28XYLKq0vmWPKSH/esxpIlz2Ur5RPHXeQCgZFItKTD4hDlp wYnh7sobFp24LB+0GXgViQlB2JnBCAlUr0KU/fj2+kA6soxqibAfY6P/rWKuCOEva0BU N/nQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a20si1442223otf.271.2019.12.11.08.03.05; Wed, 11 Dec 2019 08:03:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388429AbfLKQBw (ORCPT + 99 others); Wed, 11 Dec 2019 11:01:52 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:45809 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731411AbfLKQBt (ORCPT ); Wed, 11 Dec 2019 11:01:49 -0500 Received: from 1.general.cascardo.us.vpn ([10.172.70.58] helo=calabresa) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1if4Ql-00025a-M4; Wed, 11 Dec 2019 16:01:40 +0000 Date: Wed, 11 Dec 2019 13:01:33 -0300 From: Thadeu Lima de Souza Cascardo To: Justin Forbes Cc: Daniel Borkmann , Song Liu , Andrii Nakryiko , Alexei Starovoitov , LKML , "open list:BPF (Safe dynamic programs and tools)" , Yonghong Song , "open list:BPF (Safe dynamic programs and tools)" , linuxppc-dev@lists.ozlabs.org, Martin KaFai Lau , Aurelien Jarno , debian-kernel@lists.debian.org Subject: Re: [PATCH] libbpf: fix readelf output parsing on powerpc with recent binutils Message-ID: <20191211160133.GB4580@calabresa> References: <20191201195728.4161537-1-aurelien@aurel32.net> <87zhgbe0ix.fsf@mpe.ellerman.id.au> <20191202093752.GA1535@localhost.localdomain> <20191210222553.GA4580@calabresa> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 11, 2019 at 09:33:53AM -0600, Justin Forbes wrote: > On Tue, Dec 10, 2019 at 4:26 PM Thadeu Lima de Souza Cascardo > wrote: > > > > On Tue, Dec 10, 2019 at 12:58:33PM -0600, Justin Forbes wrote: > > > On Mon, Dec 2, 2019 at 3:37 AM Daniel Borkmann wrote: > > > > > > > > On Mon, Dec 02, 2019 at 04:53:26PM +1100, Michael Ellerman wrote: > > > > > Aurelien Jarno writes: > > > > > > On powerpc with recent versions of binutils, readelf outputs an extra > > > > > > field when dumping the symbols of an object file. For example: > > > > > > > > > > > > 35: 0000000000000838 96 FUNC LOCAL DEFAULT [: 8] 1 btf_is_struct > > > > > > > > > > > > The extra "[: 8]" prevents the GLOBAL_SYM_COUNT variable to > > > > > > be computed correctly and causes the checkabi target to fail. > > > > > > > > > > > > Fix that by looking for the symbol name in the last field instead of the > > > > > > 8th one. This way it should also cope with future extra fields. > > > > > > > > > > > > Signed-off-by: Aurelien Jarno > > > > > > --- > > > > > > tools/lib/bpf/Makefile | 4 ++-- > > > > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > > > > > Thanks for fixing that, it's been on my very long list of test failures > > > > > for a while. > > > > > > > > > > Tested-by: Michael Ellerman > > > > > > > > Looks good & also continues to work on x86. Applied, thanks! > > > > > > This actually seems to break horribly on PPC64le with binutils 2.33.1 > > > resulting in: > > > Warning: Num of global symbols in sharedobjs/libbpf-in.o (32) does NOT > > > match with num of versioned symbols in libbpf.so (184). Please make > > > sure all LIBBPF_API symbols are versioned in libbpf.map. > > > > > > This is the only arch that fails, with x86/arm/aarch64/s390 all > > > building fine. Reverting this patch allows successful build across > > > all arches. > > > > > > Justin > > > > Well, I ended up debugging this same issue and had the same fix as Jarno's when > > I noticed his fix was already applied. > > > > I just installed a system with the latest binutils, 2.33.1, and it still breaks > > without such fix. Can you tell what is the output of the following command on > > your system? > > > > readelf -s --wide tools/lib/bpf/sharedobjs/libbpf-in.o | cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $0}' > > > > readelf -s --wide tools/lib/bpf/sharedobjs/libbpf-in.o | cut -d "@" > -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | awk '/GLOBAL/ && /DEFAULT/ && > !/UND/ {print $0}' > 373: 00000000000141bc 1376 FUNC GLOBAL DEFAULT 1 > libbpf_num_possible_cpus [: 8] > 375: 000000000001869c 176 FUNC GLOBAL DEFAULT 1 btf__free > [: 8] [...] This is a patch on binutils carried by Fedora: https://src.fedoraproject.org/rpms/binutils/c/b8265c46f7ddae23a792ee8306fbaaeacba83bf8 " b8265c Have readelf display extra symbol information at the end of the line. " It has the following comment: # FIXME: The proper fix would be to update the scripts that are expecting # a fixed output from readelf. But it seems that some of them are # no longer being maintained. This commit is from 2017, had it been on binutils upstream, maybe the situation right now would be different. Honestly, it seems the best way out is to filter the other information in the libbpf Makefile. Does the following patch work for you? diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index 56ce6292071b..e6f99484d7d5 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -145,6 +145,7 @@ PC_FILE := $(addprefix $(OUTPUT),$(PC_FILE)) GLOBAL_SYM_COUNT = $(shell readelf -s --wide $(BPF_IN_SHARED) | \ cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \ + sed 's/\[.*\]//' | \ awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$8}' | \ sort -u | wc -l) VERSIONED_SYM_COUNT = $(shell readelf -s --wide $(OUTPUT)libbpf.so | \ @@ -217,6 +218,7 @@ check_abi: $(OUTPUT)libbpf.so "versioned in $(VERSION_SCRIPT)." >&2; \ readelf -s --wide $(OUTPUT)libbpf-in.o | \ cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \ + sed 's/\[.*\]//' | \ awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$8}'| \ sort -u > $(OUTPUT)libbpf_global_syms.tmp; \ readelf -s --wide $(OUTPUT)libbpf.so | \