Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8453405ybl; Thu, 16 Jan 2020 17:10:01 -0800 (PST) X-Google-Smtp-Source: APXvYqwjcENETvMgDqNnuW6HSyR+dZJ98B71TqGYG/i4woQhGohnvQSl1nNe0VfKKS/4Vbull/rg X-Received: by 2002:a9d:5885:: with SMTP id x5mr4306774otg.132.1579223401524; Thu, 16 Jan 2020 17:10:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579223401; cv=none; d=google.com; s=arc-20160816; b=LhEnqkkhDaPoVoo6ZNKGxE2wugVR4v506PCvRwboW2st6mVOnoE0IKZgmlp3EOcM26 LMA30los0k5g78KgXo+AnzLu5It/3/CRNBaQ+zrojgzFzrC1t2hvLn0LItwsqtSaxepk V/5asgXqmp3DoDKMYrGRw+AKGzSjjJU9+0xG06lQVG0qc+I9zqGJ0wvQaV7TfveJlfeu jKg4tsXrvCSvuMEKxsnVPts78ZsMCViQ6SZT6pE0/J9RidWUGNmIGY/7VkaAtBSYl79b 078FvrpO2iBsXhSckDKaeChvn9GTTyiPVq4sLOcBEO2ZfZc4E4pRi719v1l6j9FiNkSa gE+A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jOga3lrKHZYEfQB5DqQ9IfKzIAUjNEw1eNEeIovHzPc=; b=q81YpYAl+MvcJYP1mNZCEd39S6/+w0NzHaeHZb6f5UynRz1s+VYlDPLS5T4aha/qug +cGGkdcnnBM/KPWmfiKPtAh7mC8QHMgRghETwRnWxhHDg8YetdnWm2U6NCmhZnv8mtWR jyOPsUMKXmdoiHtzzAFejowhDqURZRjDVJ5G6bG7TDMbujdjw3kwHxvZ0iBsSpPJZ3+m GDeEcz775PaWa9mbd3WcGw9g3mrRHv09K/p9okDGLoc5A2sT86CQMOPGTVCjU1abWznb ju7mNBNBQ27n1c6EYwUINubkJtBJEz2cNdkI5Glm9voqixPR3PMd140QF234XBe2cYUi O1Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fkNhBNfn; 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 a9si12809718oib.59.2020.01.16.17.09.48; Thu, 16 Jan 2020 17:10:01 -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; dkim=pass header.i=@kernel.org header.s=default header.b=fkNhBNfn; 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 S1731900AbgAPXWZ (ORCPT + 99 others); Thu, 16 Jan 2020 18:22:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:50008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390907AbgAPXWP (ORCPT ); Thu, 16 Jan 2020 18:22:15 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7C8682082F; Thu, 16 Jan 2020 23:22:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579216934; bh=LBIl3KGH8MIU5Exw1WYg3MjvGaf/2BdugHkjvTznKk0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fkNhBNfnzXibjA4v6rcSwoO9pZVmX9JnlsDr5fqQD1WfN6YPmj5ydkZpxbM+36dD1 2Ye0zE5qoG/SP0YxNqGmMOiKHXAz2xeqldh7AKs4NdeSKkHjqr+JDakRuRsXSwXTUW w4PxljrOlcJU08n3/qd18aVNGa9epZoP9W1Aoh7E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stanislav Fomichev , Alexei Starovoitov , Andrii Nakryiko , John Fastabend Subject: [PATCH 5.4 080/203] bpf: Support pre-2.25-binutils objcopy for vmlinux BTF Date: Fri, 17 Jan 2020 00:16:37 +0100 Message-Id: <20200116231751.746152866@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231745.218684830@linuxfoundation.org> References: <20200116231745.218684830@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stanislav Fomichev commit da5fb18225b49b97bb37c51bcbbb2990a507c364 upstream. If vmlinux BTF generation fails, but CONFIG_DEBUG_INFO_BTF is set, .BTF section of vmlinux is empty and kernel will prohibit BPF loading and return "in-kernel BTF is malformed". --dump-section argument to binutils' objcopy was added in version 2.25. When using pre-2.25 binutils, BTF generation silently fails. Convert to --only-section which is present on pre-2.25 binutils. Documentation/process/changes.rst states that binutils 2.21+ is supported, not sure those standards apply to BPF subsystem. v2: * exit and print an error if gen_btf fails (John Fastabend) v3: * resend with Andrii's Acked-by/Tested-by tags Fixes: 341dfcf8d78ea ("btf: expose BTF info through sysfs") Signed-off-by: Stanislav Fomichev Signed-off-by: Alexei Starovoitov Tested-by: Andrii Nakryiko Acked-by: Andrii Nakryiko Cc: John Fastabend Link: https://lore.kernel.org/bpf/20191127161410.57327-1-sdf@google.com Signed-off-by: Greg Kroah-Hartman --- scripts/link-vmlinux.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -127,7 +127,8 @@ gen_btf() cut -d, -f1 | cut -d' ' -f2) bin_format=$(LANG=C ${OBJDUMP} -f ${1} | grep 'file format' | \ awk '{print $4}') - ${OBJCOPY} --dump-section .BTF=.btf.vmlinux.bin ${1} 2>/dev/null + ${OBJCOPY} --set-section-flags .BTF=alloc -O binary \ + --only-section=.BTF ${1} .btf.vmlinux.bin 2>/dev/null ${OBJCOPY} -I binary -O ${bin_format} -B ${bin_arch} \ --rename-section .data=.BTF .btf.vmlinux.bin ${2} } @@ -253,6 +254,10 @@ btf_vmlinux_bin_o="" if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then if gen_btf .tmp_vmlinux.btf .btf.vmlinux.bin.o ; then btf_vmlinux_bin_o=.btf.vmlinux.bin.o + else + echo >&2 "Failed to generate BTF for vmlinux" + echo >&2 "Try to disable CONFIG_DEBUG_INFO_BTF" + exit 1 fi fi