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=-10.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 13B3FC4332D for ; Thu, 19 Mar 2020 12:04:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E4B6A20739 for ; Thu, 19 Mar 2020 12:04:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727027AbgCSMEv (ORCPT ); Thu, 19 Mar 2020 08:04:51 -0400 Received: from www62.your-server.de ([213.133.104.62]:47298 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbgCSMEv (ORCPT ); Thu, 19 Mar 2020 08:04:51 -0400 Received: from sslproxy06.your-server.de ([78.46.172.3]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1jEtum-0005Mt-Qx; Thu, 19 Mar 2020 13:04:44 +0100 Received: from [85.7.42.192] (helo=pc-9.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jEtum-0004Xo-D4; Thu, 19 Mar 2020 13:04:44 +0100 Subject: Re: [PATCH bpf-next v6] bpf: Support llvm-objcopy for vmlinux BTF To: Michael Ellerman , Fangrui Song , bpf@vger.kernel.org, netdev@vger.kernel.org Cc: Nathan Chancellor , Stanislav Fomichev , Alexei Starovoitov , Andrii Nakryiko , "David S . Miller" , Kees Cook , "Naveen N . Rao" , Nick Desaulniers , clang-built-linux@googlegroups.com References: <20200318222746.173648-1-maskray@google.com> <87tv2kd4hn.fsf@mpe.ellerman.id.au> From: Daniel Borkmann Message-ID: Date: Thu, 19 Mar 2020 13:04:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <87tv2kd4hn.fsf@mpe.ellerman.id.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.2/25755/Wed Mar 18 14:14:00 2020) Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 3/19/20 11:27 AM, Michael Ellerman wrote: > Fangrui Song writes: >> Simplify gen_btf logic to make it work with llvm-objcopy. The existing >> 'file format' and 'architecture' parsing logic is brittle and does not >> work with llvm-objcopy/llvm-objdump. >> 'file format' output of llvm-objdump>=11 will match GNU objdump, but >> 'architecture' (bfdarch) may not. >> >> .BTF in .tmp_vmlinux.btf is non-SHF_ALLOC. Add the SHF_ALLOC flag >> because it is part of vmlinux image used for introspection. C code can >> reference the section via linker script defined __start_BTF and >> __stop_BTF. This fixes a small problem that previous .BTF had the >> SHF_WRITE flag (objcopy -I binary -O elf* synthesized .data). >> >> Additionally, `objcopy -I binary` synthesized symbols >> _binary__btf_vmlinux_bin_start and _binary__btf_vmlinux_bin_stop (not >> used elsewhere) are replaced with more commonplace __start_BTF and >> __stop_BTF. >> >> Add 2>/dev/null because GNU objcopy (but not llvm-objcopy) warns >> "empty loadable segment detected at vaddr=0xffffffff81000000, is this intentional?" >> >> We use a dd command to change the e_type field in the ELF header from >> ET_EXEC to ET_REL so that lld will accept .btf.vmlinux.bin.o. Accepting >> ET_EXEC as an input file is an extremely rare GNU ld feature that lld >> does not intend to support, because this is error-prone. >> >> The output section description .BTF in include/asm-generic/vmlinux.lds.h >> avoids potential subtle orphan section placement issues and suppresses >> --orphan-handling=warn warnings. >> >> v6: >> - drop llvm-objdump from the title. We don't run objdump now >> - delete unused local variables: bin_arch, bin_format and bin_file >> - mention in the comment that lld does not allow an ET_EXEC input >> - rename BTF back to .BTF . The section name is assumed by bpftool >> - add output section description to include/asm-generic/vmlinux.lds.h >> - mention cb0cc635c7a9 ("powerpc: Include .BTF section") >> >> v5: >> - rebase on top of bpf-next/master >> - rename .BTF to BTF >> >> Fixes: df786c9b9476 ("bpf: Force .BTF section start to zero when dumping from vmlinux") >> Fixes: cb0cc635c7a9 ("powerpc: Include .BTF section") >> Link: https://github.com/ClangBuiltLinux/linux/issues/871 >> Signed-off-by: Fangrui Song >> Reported-by: Nathan Chancellor >> Reviewed-by: Stanislav Fomichev >> Tested-by: Stanislav Fomichev >> Cc: Alexei Starovoitov >> Cc: Andrii Nakryiko >> Cc: Daniel Borkmann >> Cc: David S. Miller >> Cc: Kees Cook >> Cc: Michael Ellerman >> Cc: Naveen N. Rao >> Cc: Nick Desaulniers >> Cc: clang-built-linux@googlegroups.com Applied, thanks everyone!