#wit #btf #info #convert #dwarf #wit-bindgen #bindings

app btf2wit

Convert btf info to wit info

3 releases

0.1.2 Mar 10, 2023
0.1.1 Feb 13, 2023
0.1.0 Feb 11, 2023

#5 in #btf

MIT license

19KB
431 lines

Contains (ELF exe/lib, 2KB) source.bpf.o, (ELF exe/lib, 2KB) src/tests/nested-array.bpf.o

btf2wit

Conversion from BTF to WIT.

Usage: btf2wit [OPTIONS] <INPUT_FILE>

Arguments:
  <INPUT_FILE>  

Options:
  -o, --output-file <OUT_FILE>  
  -h, --help                    Print help
  -V, --version                 Print version

Extract BTF info from DWARF

  • Install pahole
sudo apt install pahole
  • Use clang or gcc to compile program with -g argument
clang simple.c -c -o simple.bpf.o -g
  • Use pahole to emit BTF info from DWARF and store it in the origin ELF file
pahole -J simple.bpf.o

Use btf2wit to emit WIT info from BTF

btf2wit simple.bpf.o -o simple.wit

Use wit-bindgen to emit bindings for C and Rust

wit-bindgen c simple.wit
wit-bindgen rust simple.wit

For examples, please refer to examples/simple.

License

MIT

Dependencies

~10MB
~190K SLoC