Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate a executable from bcc python script

Tags:

bpf

ebpf

bcc-bpf

bcc uses python to compile ebpf programs, is there any convenient way to generate a executable file from these python scripts so that I can run these tracing programs on servers where clang and llvm environment are not installed?

like image 221
Cauchy Schwarz Avatar asked Jan 21 '26 05:01

Cauchy Schwarz


1 Answers

TL;DR. No, not with BCC. You might want to check out BPF CO-RE though.


There are two pieces to solving this for bcc. First, you need to compile an object file with the BPF program and maps that would work on your target system (same kernel version/headers and same conventions as Linux BPF loader). Second, you need BCC's userspace component to recognize and work with this program and maps.

Neither of these is enabled by BCC currently. My fork has a (somewhat stale) branch where I implemented support for dumping an object file to disk with conventions that enable you to load it in the Linux kernel. This is probably incomplete for your purpose, as I was only trying to load the program in the kernel; I didn't care what happened afterward. There has also been some work to run BCC's tools on remote systems, but I don't know what the current state of that is.

One effort underway that will address your issue is BPF CO-RE. BPF CO-RE allows you to develop BPF tracing programs that are portable across Linux versions. You therefore don't need to compile with the Linux headers of the target system and don't need LLVM/Clang anymore. The team behind this effort recently posted two articles on the principles and inner workings of BPF CO-RE and how it would apply to BCC's tools.

like image 134
pchaigno Avatar answered Jan 23 '26 10:01

pchaigno



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!