]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
ebpf: compile with clang -target bpf
authorJesper Dangaard Brouer <netoptimizer@brouer.com>
Wed, 7 Feb 2018 22:21:19 +0000 (23:21 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 1 Mar 2018 13:36:50 +0000 (14:36 +0100)
Enable compiling eBPF programs with clang -target bpf.

This is mostly to workaround a bug in libbpf, where clang > ver 4.0.0
generates some ELF sections (.eh_frame) when -target bpf is NOT specified,
and libbpf fails loading such files.

Notice libbpf is provided by the kernel, and in kernel v4.16 the library
will contain the needed function for attaching to the XDP hook.

Kernel commit 949abbe88436 ("libbpf: add function to setup XDP")
 https://git.kernel.org/torvalds/c/949abbe88436

The library fix has reached kernel v4.16 but the workaround for Suricata
is interesting anyway in case people use a kernel v4.15.

Signed-off-by: Jesper Dangaard Brouer <netoptimizer@brouer.com>
ebpf/Makefile.am

index 00d25f936fb0750efa075338da7868614547ea6f..d0dc0b214f08f7fc3c11332c1eba5a2146303526 100644 (file)
@@ -6,7 +6,7 @@ BPF_CFLAGS = -Iinclude
 all: lb.bpf filter.bpf bypass_filter.bpf xdp_filter.bpf vlan_filter.bpf
 
 %.bpf: %.c
-       ${CC} -Wall $(BPF_CFLAGS) -O2 -I/usr/include/$(build_cpu)-$(build_os)/ -D__KERNEL__ -D__ASM_SYSREG_H -emit-llvm -c $< -o - | ${LLC} -march=bpf -filetype=obj -o $@
+       ${CC} -Wall $(BPF_CFLAGS) -O2  -I/usr/include/$(build_cpu)-$(build_os)/ -D__KERNEL__ -D__ASM_SYSREG_H -target bpf -emit-llvm -c $< -o - | ${LLC} -march=bpf -filetype=obj -o $@
 
 CLEANFILES = *.bpf