Skip to content

Commit

Permalink
update(libscap): use ELF_C_READ_MMAP_PRIVATE if available
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Guerra <[email protected]>
  • Loading branch information
LucaGuerra committed Dec 10, 2024
1 parent 4ec3c74 commit 611c803
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion userspace/libscap/engine/bpf/scap_bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ limitations under the License.
#include <libscap/strl.h>
#include <libscap/strerror.h>

/* 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",
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 611c803

Please sign in to comment.