From: Mark Wielaard <mark@klomp.org>
To: Yonghong Song <yhs@fb.com>,
elfutils-devel@sourceware.org, ast@fb.com, kafai@fb.com
Cc: Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH] backends,bpf: add proper relocation support
Date: Sat, 16 Jun 2018 14:04:00 -0000 [thread overview]
Message-ID: <1529157849.12946.113.camel@klomp.org> (raw)
In-Reply-To: <20180615224030.2430236-1-yhs@fb.com>
Hi,
I added Richard to the CC, who added the original BPF support.
Who might remember where the R_BPF_MAP_FD comes from (see at the end).
On Fri, 2018-06-15 at 15:40 -0700, Yonghong Song wrote:
> Due to libdw does not have proper BPF relocation support,
> the pahole cannot display filenames correctly for objects
> with default llvm options. So we have to invent
> a special option "llc -march=bpf -mattr=dwarfris" to
> prevent llvm from generating cross-section dwarf relocation
> records (https://reviews.llvm.org/rL326505).
> The pahole related discussion is in linux netdev
> mailing list (http://lists.openwall.net/netdev/2018/06/15/38, etc.)
>
> We would like to add proper BPF relocation support
> to libdw so eventually we could retire the special llc bpf
> flag "-mattr=dwarfris".
Yes. elfutils/libdwfl only does "simple relocations", but that is all
you need anyway.
Do you have a test file (binary for something simple/trivial generated
by llc -march=bpf that contains at least one reloc). I looked at your
implementation and I am sure it works correctly. But having a small
testfile is always a plus.
> The bpf relocations are defined in
> llvm_repo:include/llvm/BinaryFormat/ELFRelocs/BPF.def:
> ELF_RELOC(R_BPF_NONE, 0)
> ELF_RELOC(R_BPF_64_64, 1)
> ELF_RELOC(R_BPF_64_32, 10)
>
> Removed the relocation type R_BPF_MAP_FD whoes name does not
> confirm to llvm definition and replaced it with R_BPF_64_64.
> The BPF object is just a relocatible object, not an executable or
> a shared library, so assign ELF type to REL only in bpf_reloc.def.
>
> Tested locally with building pahole with this patch and
> pahole is able to display structures in bpf object file properly.
Patch looks good. Thanks. I'll add a ChangeLog entry because that is
what we still do.
> Signed-off-by: Yonghong Song <yhs@fb.com>
> ---
> backends/Makefile.am | 2 +-
> backends/bpf_init.c | 1 +
> backends/bpf_reloc.def | 3 ++-
> backends/bpf_symbol.c | 54
> ++++++++++++++++++++++++++++++++++++++++++++++++++
> libelf/elf.h | 3 ++-
> 5 files changed, 60 insertions(+), 3 deletions(-)
> create mode 100644 backends/bpf_symbol.c
> [...]
> diff --git a/libelf/elf.h b/libelf/elf.h
> index f7748983..940e88dd 100644
> --- a/libelf/elf.h
> +++ b/libelf/elf.h
> @@ -3848,7 +3848,8 @@ enum
> /* BPF specific declarations. */
>
> #define R_BPF_NONE 0 /* No reloc */
> -#define R_BPF_MAP_FD 1 /* Map fd to pointer */
> +#define R_BPF_64_64 1
> +#define R_BPF_64_32 10
We should sync this with glibc. This file really is a copy of elf/elf.h
in glibc, which we periodically sync. It would be good if all projects
agree on the constants.
I would like to understand where the R_BPF_MAP_FD comes from. But I
assume it was a typo for BPF_PSEUDO_MAP_FD from bpf.h (which has the
same constant number 1).
I'll sent a patch to libc-alpha@sourceware.org unless you beat me to
it.
Thanks,
Mark
next prev parent reply other threads:[~2018-06-16 14:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-15 22:40 Yonghong Song
2018-06-16 14:04 ` Mark Wielaard [this message]
2018-06-16 17:58 ` Yonghong Song
2018-06-16 18:33 ` Richard Henderson
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=1529157849.12946.113.camel@klomp.org \
--to=mark@klomp.org \
--cc=ast@fb.com \
--cc=elfutils-devel@sourceware.org \
--cc=kafai@fb.com \
--cc=rth@twiddle.net \
--cc=yhs@fb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).