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 11:42:34 -0800 Message-ID: <20181112114234.48ef2e6b@cakuba.netronome.com> References: <20181112185328.125589-1-sdf@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: 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]:34611 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbeKMFhT (ORCPT ); Tue, 13 Nov 2018 00:37:19 -0500 Received: by mail-qk1-f195.google.com with SMTP id a132so15478574qkg.1 for ; Mon, 12 Nov 2018 11:42:39 -0800 (PST) In-Reply-To: <20181112185328.125589-1-sdf@google.com> Sender: netdev-owner@vger.kernel.org List-ID: On Mon, 12 Nov 2018 10:53:28 -0800, Stanislav Fomichev wrote: > Make it possible to build bpftool without libbfd. This excludes support for > disassembling jit-ted code and prints an error if the user tries to use > these features. > > Tested by: > cat > FEATURES_DUMP.bpftool < feature-libbfd=0 > feature-disassembler-four-args=1 > feature-reallocarray=0 > feature-libelf=1 > feature-libelf-mmap=1 > feature-bpf=1 > EOF > FEATURES_DUMP=$PWD/FEATURES_DUMP.bpftool make > ldd bpftool | grep libbfd > > Signed-off-by: Stanislav Fomichev Would you mind spelling out the motivation? > 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? > +static inline void disasm_init(void) {} > +#endif > void print_data_json(uint8_t *data, size_t len); > void print_hex_data_json(uint8_t *data, size_t len); Otherwise LGTM.