From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A6B8C2BB1D for ; Tue, 17 Mar 2020 00:01:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 22D6C205ED for ; Tue, 17 Mar 2020 00:01:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=fomichev-me.20150623.gappssmtp.com header.i=@fomichev-me.20150623.gappssmtp.com header.b="BoyKGv7I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732996AbgCQABj (ORCPT ); Mon, 16 Mar 2020 20:01:39 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33413 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732932AbgCQABj (ORCPT ); Mon, 16 Mar 2020 20:01:39 -0400 Received: by mail-pg1-f193.google.com with SMTP id m5so10682460pgg.0 for ; Mon, 16 Mar 2020 17:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fomichev-me.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=VdSp5SmhE7XqZw+dnWWnNJFiQVXpqITbQV0ebAQiP7I=; b=BoyKGv7Igni30S/FCKVFiurpLK2iu4pmjMNZdA8xDib0LQwhisvj8E2N+zwspH/lll fPQgsE2ZY3hxsXQ9LswLTCzrXUGK98rY7/38OdVWgRIiM/7OH/59Z31XuCq8ALRl9hkV l0o/SLFIvA32YMjZo26+7eB6RxUjtFSipZI0GRA5/Y9fKFOO7I6SNJwUgnbOn+p2Xw74 rsmG+NiZS0ZaKaI9xFRxzzXjOYk24/UqbUPb/Rf+dXebS8HzUkwqN8+5cFQ1+Lc4URv5 Bq+p5bA/ps3IfjtBqFrad7CVQ9NL7UruWI+/DtX9jHsEdbuHR+QajVwaS2RlKO+kUPLh aUzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=VdSp5SmhE7XqZw+dnWWnNJFiQVXpqITbQV0ebAQiP7I=; b=V4zQ/Vw+KMQt7dJ+O9JvijVFmhb9QJuMeToJWQfevMd7guH1tPWneIXM6fw3RgmSso aSafFoiExfwlAkmg6LCP+AuIue9Wd29CAJtZi1Wc8LBFjmR/seVgiPflAuK6CAe4NdIT 0r3ys2P3WhMWDO8JAa8001ZQzajwmEtLIJs0HjsRDQhpr0uoGJFXVaXIZpuJNnAWWLVz jgnP3oDwwVmfqSRioUYEnBpVKPXuhTeV3OKlh8/awQkCj62afa81lzmmUBGOp2wr71FK c6LIatRCrfGguKt1W7urxTWYKb/HsUEDbLGRwCux+SBBo3KzQpVGa5bfhGhc+iRS7+DP cYSQ== X-Gm-Message-State: ANhLgQ23glLFAnpxM65YdbV8omfAtvkHyO2Fp2RXSheCn/SJx7nJObiE Dj2sAwTq3SLObvIvO29NHzLIxg== X-Google-Smtp-Source: ADFU+vvx2rWuTfSay06flokPDiVFR1lQKgnX07KLrwgMFkYXDfZPdu1+py7ifawFmMPEfx2AY/Erkg== X-Received: by 2002:aa7:848b:: with SMTP id u11mr2189605pfn.76.1584403296885; Mon, 16 Mar 2020 17:01:36 -0700 (PDT) Received: from localhost ([2601:646:8f00:18d9:d0fa:7a4b:764f:de48]) by smtp.gmail.com with ESMTPSA id e187sm958824pfe.50.2020.03.16.17.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 17:01:36 -0700 (PDT) Date: Mon, 16 Mar 2020 17:01:35 -0700 From: Stanislav Fomichev To: Nathan Chancellor Cc: Stanislav Fomichev , netdev@vger.kernel.org, bpf@vger.kernel.org, davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, Nick Desaulniers Subject: Re: [PATCH bpf] bpf: Support llvm-objcopy for vmlinux BTF Message-ID: <20200317000135.GD2179110@mini-arch.hsd1.ca.comcast.net> References: <20200316222518.191601-1-sdf@google.com> <20200316235725.GA43392@ubuntu-m2-xlarge-x86> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200316235725.GA43392@ubuntu-m2-xlarge-x86> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 03/16, Nathan Chancellor wrote: > On Mon, Mar 16, 2020 at 03:25:18PM -0700, Stanislav Fomichev wrote: > > Commit da5fb18225b4 ("bpf: Support pre-2.25-binutils objcopy for vmlinux > > BTF") switched from --dump-section to > > --only-section/--change-section-address for BTF export assuming > > those ("legacy") options should cover all objcopy versions. > > > > Turns out llvm-objcopy doesn't implement --change-section-address [1], > > but it does support --dump-section. Let's partially roll back and > > try to use --dump-section first and fall back to > > --only-section/--change-section-address for the older binutils. > > > > 1. https://bugs.llvm.org/show_bug.cgi?id=45217 > > > > Fixes: df786c9b9476 ("bpf: Force .BTF section start to zero when dumping from vmlinux") > > Tested-by: Nick Desaulniers > > Reported-by: Nathan Chancellor > > Link: https://github.com/ClangBuiltLinux/linux/issues/871 > > Signed-off-by: Stanislav Fomichev > > --- > > scripts/link-vmlinux.sh | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh > > index dd484e92752e..8ddf57cbc439 100755 > > --- a/scripts/link-vmlinux.sh > > +++ b/scripts/link-vmlinux.sh > > @@ -127,6 +127,16 @@ gen_btf() > > cut -d, -f1 | cut -d' ' -f2) > > bin_format=$(LANG=C ${OBJDUMP} -f ${1} | grep 'file format' | \ > > awk '{print $4}') > > + > > + # Compatibility issues: > > + # - pre-2.25 binutils objcopy doesn't support --dump-section > > + # - llvm-objcopy doesn't support --change-section-address, but > > + # does support --dump-section > > + # > > + # Try to use --dump-section which should cover both recent > > + # binutils and llvm-objcopy and fall back to --only-section > > + # for pre-2.25 binutils. > > + ${OBJCOPY} --dump-section .BTF=$bin_file ${1} 2>/dev/null || \ > > ${OBJCOPY} --change-section-address .BTF=0 \ > > --set-section-flags .BTF=alloc -O binary \ > > --only-section=.BTF ${1} .btf.vmlinux.bin > > -- > > 2.25.1.481.gfbce0eb801-goog > > > > Hi Stanislav, > > Thank you for the patch! This is targeting the bpf tree but it uses the > bin_file variable that comes from commit af73d78bd384 ("kbuild: Remove > debug info from kallsyms linking") in the bpf-next tree. In this form, > when applied to mainline, the first command fails because $bin_file > doesn't exist and falls back to the second command, which results in no > net change for llvm-objcopy. > > When manually applied to next-20200316 or applied to mainline with > $bin_file replaced with .btf.vmlinux.bin, x86_64 and aarch64 successfully > generate BTF with tip of tree llvm-objcopy. > > Tested-by: Nathan Chancellor Oops, sorry, I did it on top of bpf-next, but then blindly cherry-picked on top of bpf tree. In this case, should we put in only in bpf-next? Do we need a stable backport for the older versions?