diff --git a/userspace/libscap/engine/bpf/scap_bpf.c b/userspace/libscap/engine/bpf/scap_bpf.c index f57ad1b362..82063a491c 100644 --- a/userspace/libscap/engine/bpf/scap_bpf.c +++ b/userspace/libscap/engine/bpf/scap_bpf.c @@ -49,6 +49,11 @@ limitations under the License. #include #include +/* some libelf implementations do not have the ELF_C_READ_MMAP_PRIVATE extension */ +#ifndef ELF_C_READ_MMAP_PRIVATE +#define ELF_C_READ_MMAP_PRIVATE ELF_C_READ +#endif + static const char *const bpf_kernel_counters_stats_names[] = { [BPF_N_EVTS] = N_EVENTS_PREFIX, [BPF_N_DROPS_BUFFER_TOTAL] = "n_drops_buffer_total", @@ -706,7 +711,7 @@ static int32_t load_bpf_file(struct bpf_engine *handle) { handle->m_filepath); } - handle->elf = elf_begin(handle->program_fd, ELF_C_READ, NULL); + handle->elf = elf_begin(handle->program_fd, ELF_C_READ_MMAP_PRIVATE, NULL); if(!handle->elf) { scap_errprintf(handle->m_lasterr, 0, "can't read ELF format"); goto end;