Re: [PATCH] bpftool: Try to read btf as raw data if elf read fails

Jiri Olsa
2019-10-21T13:54:37Z

On Fri, Oct 18, 2019 at 04:48:25PM +0000, Andrii Nakryiko wrote:
> On 10/18/19 3:34 AM, Jiri Olsa wrote:
> > The bpftool interface stays the same, but now it's possible
> > to run it over BTF raw data, like:
>
> Oh, great, I had similar patch laying around for a while, never got to
> cleaning it up, though, so thanks for picking this up!
>
> >
> > $ bpftool btf dump file /sys/kernel/btf/vmlinux
> > libbpf: failed to get EHDR from /sys/kernel/btf/vmlinux
>
> We should implement this so that we don't get an extra log output with
> errors. I've been thinking about checking first few bytes of the file.
> If that matches BTF_MAGIC, then try to parse it as raw BTF, otherwise
> parse as ELF w/ BTF. Does it make sense?

ok, sounds good

jirka