All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Michael Ellerman <mpe@ellerman.id.au>,
	Fangrui Song <maskray@google.com>,
	bpf@vger.kernel.org, netdev@vger.kernel.org
Cc: Nathan Chancellor <natechancellor@gmail.com>,
	Stanislav Fomichev <sdf@google.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	Kees Cook <keescook@chromium.org>,
	"Naveen N . Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	clang-built-linux@googlegroups.com
Subject: Re: [PATCH bpf-next v6] bpf: Support llvm-objcopy for vmlinux BTF
Date: Thu, 19 Mar 2020 13:04:43 +0100	[thread overview]
Message-ID: <b5d153ad-23fe-a367-100b-ea9f19ae6958@iogearbox.net> (raw)
In-Reply-To: <87tv2kd4hn.fsf@mpe.ellerman.id.au>

On 3/19/20 11:27 AM, Michael Ellerman wrote:
> Fangrui Song <maskray@google.com> 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 <maskray@google.com>
>> Reported-by: Nathan Chancellor <natechancellor@gmail.com>
>> Reviewed-by: Stanislav Fomichev <sdf@google.com>
>> Tested-by: Stanislav Fomichev <sdf@google.com>
>> Cc: Alexei Starovoitov <ast@kernel.org>
>> Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
>> Cc: Daniel Borkmann <daniel@iogearbox.net>
>> Cc: David S. Miller <davem@davemloft.net>
>> Cc: Kees Cook <keescook@chromium.org>
>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>> Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
>> Cc: Nick Desaulniers <ndesaulniers@google.com>
>> Cc: clang-built-linux@googlegroups.com

Applied, thanks everyone!

      reply	other threads:[~2020-03-19 12:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18 22:27 [PATCH bpf-next v6] bpf: Support llvm-objcopy for vmlinux BTF Fangrui Song
2020-03-19  5:10 ` Andrii Nakryiko
2020-03-19  5:45 ` Kees Cook
2020-03-19 10:27 ` Michael Ellerman
2020-03-19 12:04   ` Daniel Borkmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b5d153ad-23fe-a367-100b-ea9f19ae6958@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=davem@davemloft.net \
    --cc=keescook@chromium.org \
    --cc=maskray@google.com \
    --cc=mpe@ellerman.id.au \
    --cc=natechancellor@gmail.com \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=sdf@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.