mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-05 08:09:07 +08:00
tools: Remove feature-libelf-mmap feature detection
It's trivial to handle missing ELF_C_MMAP_READ support in libelf the way that
objtool has solved it in
("774bec3fddcc objtool: Add fallback from ELF_C_READ_MMAP to ELF_C_READ").
So instead of having an entire feature detector for that, just do what objtool
does for perf and libbpf. And keep their Makefiles a bit simpler.
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200819013607.3607269-5-andriin@fb.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
3c4954d5a6
commit
a734ef0803
14
src/libbpf.c
14
src/libbpf.c
@@ -150,12 +150,6 @@ static void pr_perm_msg(int err)
|
|||||||
___err; })
|
___err; })
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LIBELF_MMAP_SUPPORT
|
|
||||||
# define LIBBPF_ELF_C_READ_MMAP ELF_C_READ_MMAP
|
|
||||||
#else
|
|
||||||
# define LIBBPF_ELF_C_READ_MMAP ELF_C_READ
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline __u64 ptr_to_u64(const void *ptr)
|
static inline __u64 ptr_to_u64(const void *ptr)
|
||||||
{
|
{
|
||||||
return (__u64) (unsigned long) ptr;
|
return (__u64) (unsigned long) ptr;
|
||||||
@@ -1064,6 +1058,11 @@ static void bpf_object__elf_finish(struct bpf_object *obj)
|
|||||||
obj->efile.obj_buf_sz = 0;
|
obj->efile.obj_buf_sz = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if libelf is old and doesn't support mmap(), fall back to read() */
|
||||||
|
#ifndef ELF_C_READ_MMAP
|
||||||
|
#define ELF_C_READ_MMAP ELF_C_READ
|
||||||
|
#endif
|
||||||
|
|
||||||
static int bpf_object__elf_init(struct bpf_object *obj)
|
static int bpf_object__elf_init(struct bpf_object *obj)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
@@ -1092,8 +1091,7 @@ static int bpf_object__elf_init(struct bpf_object *obj)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj->efile.elf = elf_begin(obj->efile.fd,
|
obj->efile.elf = elf_begin(obj->efile.fd, ELF_C_READ_MMAP, NULL);
|
||||||
LIBBPF_ELF_C_READ_MMAP, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!obj->efile.elf) {
|
if (!obj->efile.elf) {
|
||||||
|
|||||||
Reference in New Issue
Block a user