[llvm-dev] bpf compilation using clang (original) (raw)

Sameeh Jubran via llvm-dev llvm-dev at lists.llvm.org
Sun Sep 16 01:30:38 PDT 2018


ping? Who is maintaining bpf compilation On Thu, Sep 13, 2018 at 12:58 PM Sameeh Jubran <sameeh at daynix.com> wrote:

Hi all, I am trying to insert instructions into the bpf using the bpf syscall, the instructions were generated using the following command line: clang -I ~/Builds/bpfrss/iproute2/include -Wall -target bpf -O2 -emit-llvm -c upstream/qemu/hw/net/rsstapbpfprogram.c -o - | llc -march=bpf -filetype=obj -o tapbpfprogram.o and then were translated to bpf instructions using the BPFCparser tool Every time I try to insert the array of instructions the verfier fails with the following error: back-edge from insn 363 to 364 or something similar even though the compilation succeeds. I have multiple maps in my code and I translate only the code section to bpf insns structure and insert it using the bpf syscall as follows: memset(&attr, 0, sizeof(attr)); attr.progtype = BPFPROGTYPESOCKETFILTER; attr.insncnt = ARRAYSIZE(l3l4hashinsns); _attr.insns = (u64) (unsigned long) (l3l4hashinsns); _attr.license = (u64) (unsigned long) ("Dual BSD/GPL"); _attr.logbuf = (u64) (unsigned long) (buffer); attr.loglevel = 7; attr.logsize = BUFFLEN; attr.kernversion = 0; ret = sysbpf(BPFPROGLOAD, &attr, sizeof(attr)); I am not sure how to debug this error since the instructions are in binary and the precompiled source code doesn't seem to contain any weird loops or goto instructions... Is there a way to identify which line of source code is causing these errors? Thanks!

-- Respectfully, Sameeh Jubran Linkedin Software Engineer @ Daynix.



More information about the llvm-dev mailing list