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=-22.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham 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 7B2EFC0044D for ; Mon, 16 Mar 2020 22:25:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4D56120674 for ; Mon, 16 Mar 2020 22:25:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mfudS3gF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732745AbgCPWZW (ORCPT ); Mon, 16 Mar 2020 18:25:22 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:54779 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732652AbgCPWZW (ORCPT ); Mon, 16 Mar 2020 18:25:22 -0400 Received: by mail-pf1-f201.google.com with SMTP id v14so13872125pfm.21 for ; Mon, 16 Mar 2020 15:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=CDSTXSoz8JLvnbI4Rvpwb3UtnFj/UPBOq4cipKiHAa8=; b=mfudS3gFLjCVkxeKqKuIti5kPRwYSFzRUQXaEKSHT2SBuaKTMjz4B2nEV0DChQ09hs jSStQPdDtrxV/y9xuUa4fv0Vqi0LjNFMjlXKBMfWhmZ914PhJowPNwAAZQhvfgjJwVCD 3CuKszPZEhXOVFK+RYTRwlW8lXDHKZsua/wTvL0umNojwdAncQOeQHYO+KT//TjLcilb Y4TsaV1va7HT4Z9CZrCMDxVbXkQdALo30MEPdokZ3wHKdvVu/jWllq2ieItEXavSYc+y PAEyGtKkZyqTAAl+lvSIMbzAOAddDp9Cwq68S8V+ZIfLE8Ks8GSEowoDFHFo75Q3LKEw y2mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=CDSTXSoz8JLvnbI4Rvpwb3UtnFj/UPBOq4cipKiHAa8=; b=H5Ueg8yjWCp3uo8ux5J51265XBanJRtvBWiXNaS6ggjrnjVuuXvIP7x5BSIJ8/TPJc ASpuBuXuIIpCP47PMLPZUVLS14puSrv7u1YWkEOpo6AECejphJL07zsdcN/MEBkleQXl 1i49xeMhWD5gCTXns7ZVDZAalWELP+nCGRJSvk+tPg8RNdLK/YbQFy4DZzXKjAcFLvSi 0LCvtguSpnaM0S6QM4wwkeiEjuL/7ZLnPo3nrY5mESv0VmP/yZihn8ojpPHqnQ6lQBuO waIWbuzKr+WtxCsYxExv1BjCZFG++/l0th3Phk7uHLUBULoRZ3/KUycKqoI/S6H1D8vv OfTw== X-Gm-Message-State: ANhLgQ2i5ZyvFE+bycmbYOGcWmS8o+z3JjRW4Bf6frVVJX2xigP8ROug RqrWJKz1+JmiP8DDao1dmcsoK0Q= X-Google-Smtp-Source: ADFU+vtg+o9KJH/sNGo1ZSxUm97WYU4MunF3koiZCvSAQPSsFPYxKlf2EL51qt/hdH3VSOSoTO5/z+s= X-Received: by 2002:a63:8342:: with SMTP id h63mr2003915pge.141.1584397521541; Mon, 16 Mar 2020 15:25:21 -0700 (PDT) Date: Mon, 16 Mar 2020 15:25:18 -0700 Message-Id: <20200316222518.191601-1-sdf@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.1.481.gfbce0eb801-goog Subject: [PATCH bpf] bpf: Support llvm-objcopy for vmlinux BTF From: Stanislav Fomichev To: netdev@vger.kernel.org, bpf@vger.kernel.org Cc: davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, Stanislav Fomichev , Nick Desaulniers , Nathan Chancellor Content-Type: text/plain; charset="UTF-8" Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org 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