Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp777016ybl; Sun, 1 Dec 2019 12:32:35 -0800 (PST) X-Google-Smtp-Source: APXvYqzI7Yu051fwcMpY+WQ8est5hBwHNahQLx4u+f8oQS3JZyhPfAocoFLdW7Vz+IIsjBLwbTL0 X-Received: by 2002:aa7:dc48:: with SMTP id g8mr3100590edu.208.1575232355812; Sun, 01 Dec 2019 12:32:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575232355; cv=none; d=google.com; s=arc-20160816; b=TzDWCGfUjgZa+KUa4Gya0atFzS51Ss0N9kNUuUJvLG2P8B0r0Ar9qWfVa82EiUAMRf XeMLhN1emr1ZxFCbh4R90GiC85FXqnpsg6e8w/a4jRO25Cob+MAbXmLOvTY3dEImZhY0 TvMC9THd5BC8NYuxC8cFpFHeaqoney8nzYRNAqwvWYsUpXNXGp4uayTddLSsqLzz3O7j vKmCbGHIh/Fz+QKxZfva9kKPvr7QbN5DhyU/CNKcHbEVUkO/igQErOwlmMSmD3L/UtG2 fKhR/Jez1DIA0vKNyNwEgwI7fg61Uxpkjc6OwPiw7aDc4yq4vZoFfuwjFKVnKFeV4GIF O0tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=OznUm9OYU52qS165JO2vLkJY3SCOhz3Pdu8FafYEOZk=; b=mQcgFgrjRhMkVKZKl3xp9hKqhr+CrB+WfyNdWigf5vJ0oRzSSKEPBzahZYFJD5LKY4 Rsr2jEmzIhAu8VUFkbPNKGALPTQs+ey0ivILWi9zRFEP30Zd1VVOLXAA8odH2uFG5Ztv aNGdQM/AcnDbt+Qz7FFtO0cz8rptgZvGUJwFT2ZQYBlojNfb4vHeB8QvcqUOtHa9mW7a 5jpiNMSnjLeQ3RHVzce/KNLIUYKE+y8w6XtFKsv0nhvN7Zzspthu8xz38BNSQRQ3Oki0 shTs3rAjbqKCynMriWc85w7z0WHhQcnZgb8ItLXF0gVU/LbMkgqX9yWR4A04RuU4btcv dIWw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o24si987865ejm.212.2019.12.01.12.32.10; Sun, 01 Dec 2019 12:32:35 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727218AbfLAU2F (ORCPT + 99 others); Sun, 1 Dec 2019 15:28:05 -0500 Received: from hall.aurel32.net ([195.154.113.88]:55868 "EHLO hall.aurel32.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726173AbfLAU2F (ORCPT ); Sun, 1 Dec 2019 15:28:05 -0500 X-Greylist: delayed 1806 seconds by postgrey-1.27 at vger.kernel.org; Sun, 01 Dec 2019 15:28:04 EST Received: from [2a01:e35:2fdd:a4e1:fe91:fc89:bc43:b814] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ibVLh-0005Nk-30; Sun, 01 Dec 2019 20:57:41 +0100 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.92.3) (envelope-from ) id 1ibVLg-00HScO-Hs; Sun, 01 Dec 2019 20:57:40 +0100 From: Aurelien Jarno To: linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, debian-kernel@lists.debian.org, Aurelien Jarno , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , netdev@vger.kernel.org (open list:BPF (Safe dynamic programs and tools)), bpf@vger.kernel.org (open list:BPF (Safe dynamic programs and tools)) Subject: [PATCH] libbpf: fix readelf output parsing on powerpc with recent binutils Date: Sun, 1 Dec 2019 20:57:28 +0100 Message-Id: <20191201195728.4161537-1-aurelien@aurel32.net> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index 99425d0be6ff..333900cf3f4f 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -147,7 +147,7 @@ TAGS_PROG := $(if $(shell which etags 2>/dev/null),etags,ctags) GLOBAL_SYM_COUNT = $(shell readelf -s --wide $(BPF_IN_SHARED) | \ cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \ - awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$8}' | \ + awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}' | \ sort -u | wc -l) VERSIONED_SYM_COUNT = $(shell readelf -s --wide $(OUTPUT)libbpf.so | \ grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | sort -u | wc -l) @@ -216,7 +216,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].*//' | \ - awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$8}'| \ + awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'| \ sort -u > $(OUTPUT)libbpf_global_syms.tmp; \ readelf -s --wide $(OUTPUT)libbpf.so | \ grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | \ -- 2.24.0