diff options
author | Jakub Kicinski <jakub.kicinski@netronome.com> | 2018-06-28 17:41:39 -0400 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-06-30 19:01:50 -0400 |
commit | eac7d84519a35fc9fc8071b7d93803b2b075e2a7 (patch) | |
tree | a2ec02eaf7ad4a704a9c6fa78535a8b8a9e5e19a /tools/lib/bpf | |
parent | 9a94f277c4fb84815f450418d37bfc568d57b5cc (diff) |
tools: libbpf: don't return '.text' as a program for multi-function programs
Make bpf_program__next() skip over '.text' section if object file
has pseudo calls. The '.text' section is hardly a program in that
case, it's more of a storage for code of functions other than main.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/lib/bpf')
-rw-r--r-- | tools/lib/bpf/libbpf.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index e2401b95f08d..38ed3e92e393 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c | |||
@@ -1865,8 +1865,8 @@ void *bpf_object__priv(struct bpf_object *obj) | |||
1865 | return obj ? obj->priv : ERR_PTR(-EINVAL); | 1865 | return obj ? obj->priv : ERR_PTR(-EINVAL); |
1866 | } | 1866 | } |
1867 | 1867 | ||
1868 | struct bpf_program * | 1868 | static struct bpf_program * |
1869 | bpf_program__next(struct bpf_program *prev, struct bpf_object *obj) | 1869 | __bpf_program__next(struct bpf_program *prev, struct bpf_object *obj) |
1870 | { | 1870 | { |
1871 | size_t idx; | 1871 | size_t idx; |
1872 | 1872 | ||
@@ -1887,6 +1887,18 @@ bpf_program__next(struct bpf_program *prev, struct bpf_object *obj) | |||
1887 | return &obj->programs[idx]; | 1887 | return &obj->programs[idx]; |
1888 | } | 1888 | } |
1889 | 1889 | ||
1890 | struct bpf_program * | ||
1891 | bpf_program__next(struct bpf_program *prev, struct bpf_object *obj) | ||
1892 | { | ||
1893 | struct bpf_program *prog = prev; | ||
1894 | |||
1895 | do { | ||
1896 | prog = __bpf_program__next(prog, obj); | ||
1897 | } while (prog && bpf_program__is_function_storage(prog, obj)); | ||
1898 | |||
1899 | return prog; | ||
1900 | } | ||
1901 | |||
1890 | int bpf_program__set_priv(struct bpf_program *prog, void *priv, | 1902 | int bpf_program__set_priv(struct bpf_program *prog, void *priv, |
1891 | bpf_program_clear_priv_t clear_priv) | 1903 | bpf_program_clear_priv_t clear_priv) |
1892 | { | 1904 | { |