On Mon, Feb 26, 2018 at 08:12:49PM -0800, Jakub Kicinski wrote: > From: Jiong Wang <jiong.w...@netronome.com> > > This patch detect all sub-programs from the eBPF sequence and keep the > information in the new CFG data structure. > > The detection algorithm is basically the same as the one in verifier except > we need to use insn->off instead of insn->imm to get the pc-relative call > offset. Because verifier has modified insn->off/insn->imm during finishing > the verification. > > Also, we don't need to do some sanity checks as verifier has done them. > > Signed-off-by: Jiong Wang <jiong.w...@netronome.com> > Acked-by: Jakub Kicinski <jakub.kicin...@netronome.com>
overall idea looks good to me. One step towards proper decompiler ;) > diff --git a/tools/bpf/bpftool/cfg.c b/tools/bpf/bpftool/cfg.c > new file mode 100644 > index 000000000000..42a0d4c4271c > --- /dev/null > +++ b/tools/bpf/bpftool/cfg.c > @@ -0,0 +1,143 @@ > +/* > + * Copyright (C) 2018 Netronome Systems, Inc. > + * > + * This software is dual licensed under the GNU General License Version 2, > + * June 1991 as shown in the file COPYING in the top-level directory of this > + * source tree or the BSD 2-Clause License provided below. You have the > + * option to license this software under the complete terms of either > license. please use SPDX instead.