]> git.baikalelectronics.ru Git - kernel.git/commit
tools: libbpf: restore the ability to load programs from .text section
authorJakub Kicinski <jakub.kicinski@netronome.com>
Thu, 28 Jun 2018 21:41:38 +0000 (14:41 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Sat, 30 Jun 2018 23:01:50 +0000 (01:01 +0200)
commit08d3b8a14e8029d73a5c22a708fef615294b6aa4
tree967999fb046e005b1026f0280f8be0b7f6190f6a
parent586ca1820ef4a8c33401a8871d3a9686dbc7f5e3
tools: libbpf: restore the ability to load programs from .text section

libbpf used to be able to load programs from the default section
called '.text'.  It's not very common to leave sections unnamed,
but if it happens libbpf will fail to load the programs reporting
-EINVAL from the kernel.  The -EINVAL comes from bpf_obj_name_cpy()
because since 6d6e54b4ef74 ("libbpf: add support for bpf_call")
libbpf does not resolve program names for programs in '.text',
defaulting to '.text'.  '.text', however, does not pass the
(isalnum(*src) || *src == '_') check in bpf_obj_name_cpy().

With few extra lines of code we can limit the pseudo call
assumptions only to objects which actually contain code relocations.

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>
tools/lib/bpf/libbpf.c