From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [PATCH bpf-next] bpftool: make libbfd optional Date: Mon, 12 Nov 2018 12:35:33 -0800 Message-ID: <20181112123533.19da3b36@cakuba.netronome.com> References: <20181112185328.125589-1-sdf@google.com> <20181112114234.48ef2e6b@cakuba.netronome.com> <20181112195827.l5xz5qko7l6leqhp@mini-arch> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Stanislav Fomichev , netdev@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, quentin.monnet@netronome.com To: Stanislav Fomichev Return-path: Received: from mail-qk1-f195.google.com ([209.85.222.195]:33701 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbeKMGab (ORCPT ); Tue, 13 Nov 2018 01:30:31 -0500 Received: by mail-qk1-f195.google.com with SMTP id o89so15737974qko.0 for ; Mon, 12 Nov 2018 12:35:38 -0800 (PST) In-Reply-To: <20181112195827.l5xz5qko7l6leqhp@mini-arch> Sender: netdev-owner@vger.kernel.org List-ID: On Mon, 12 Nov 2018 11:58:27 -0800, Stanislav Fomichev wrote: > On 11/12, Jakub Kicinski wrote: > > On Mon, 12 Nov 2018 10:53:28 -0800, Stanislav Fomichev wrote: > > > diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h > > > index 61d82020af58..ec1bc2ae3c71 100644 > > > --- a/tools/bpf/bpftool/main.h > > > +++ b/tools/bpf/bpftool/main.h > > > @@ -147,8 +147,19 @@ int prog_parse_fd(int *argc, char ***argv); > > > int map_parse_fd(int *argc, char ***argv); > > > int map_parse_fd_and_info(int *argc, char ***argv, void *info, __u32 *info_len); > > > > > > +#ifdef HAVE_LIBBFD_SUPPORT > > > void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes, > > > const char *arch, const char *disassembler_options); > > > +void disasm_init(void); > > > +#else > > > +static inline > > > +void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes, > > > + const char *arch, const char *disassembler_options) > > > +{ > > > + p_err("No libbfd support"); > > > +} > > > > I think an error per instruction is a bit much, could we make sure we > > error out earlier? > > I can return int from disasm_print_insn as an indication to > stop/continue. Let me know if you have better ideas, will post v2 later > today. Why not simply: diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index 5302ee282409..44edf6705ad2 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -466,6 +466,10 @@ static int do_dump(int argc, char **argv) int fd; if (is_prefix(*argv, "jited")) { +#ifndef HAVE_LIBBFD_SUPPORT + p_err("No libbfd support"); + return -1; +#endif member_len = &info.jited_prog_len; member_ptr = &info.jited_prog_insns; } else if (is_prefix(*argv, "xlated")) { Perhaps wrapped into some helper in the header to avoid the yuckiness.