EBPF: Difference between revisions

No edit summary
Line 16: Line 16:
LLVM has enjoyed <tt>bpf</tt> backend support since 3.7. Compile using <tt>-target bpf</tt> to generate BPF bytecode, adding <tt>-g</tt> to generate BTF information.
LLVM has enjoyed <tt>bpf</tt> backend support since 3.7. Compile using <tt>-target bpf</tt> to generate BPF bytecode, adding <tt>-g</tt> to generate BTF information.


<tt>readelf</tt> on the resulting object ought look like:
<tt>readelf</tt> on the resulting object ought indicate a <tt>Machine</tt> of "Linux BPF" or "EM_BPF". The resulting object can be loaded into the kernel with <tt>bpftool prog load</tt> or libbpf's <tt>bpf_object__open()</tt>.
<pre>
ELF Header:
  Magic:  7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                            ELF64
  Data:                              2's complement, little endian
  Version:                          1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                      0
  Type:                              REL (Relocatable file)
  Machine:                          Linux BPF
  Version:                          0x1
  Entry point address:              0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          360 (bytes into file)
  Flags:                            0x0
...
</pre>
The resulting object can be loaded into the kernel with <tt>bpftool prog load</tt> or libbpf's <tt>bpf_object__open()</tt>.


===JIT===
===JIT===