Re: [PATCH bpf-next 3/8] tools: bpftool: detect sub-programs from the eBPF sequence
flat view
From: Alexei Starovoitov <hidden>
Date: 2018-02-27 04:25:30
On Mon, Feb 26, 2018 at 08:12:49PM -0800, Jakub Kicinski wrote:
From: Jiong Wang <redacted> 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 <redacted> Acked-by: Jakub Kicinski <redacted>
overall idea looks good to me. One step towards proper decompiler ;)
quoted hunk ↗ jump to hunk
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.