Skip to content

How to modify BTF to allow inject a new program? #1738

Answered by ti-mo
SirHao asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, thanks for the question. ebpf-go unmarshals all BTF info (including .btf.ext) into Go types and attaches them as metadata to individual asm.Instructions when loading an ELF. When loading the program into the kernel, the metadata is marshaled back into BTF wire format along with the program. This is why, when you inspect a loaded program's BTF with bpftool, it'll only contain the types used by your program's funcinfo, not the original BTF blob that came with the ELF. The same concept applies to maps created by ebpf-go.

Here's an example of how to attach your own funcinfo to an instruction:

btf.WithFuncMetadata(asm.LoadImm(asm.R0, 0, asm.D…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ti-mo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants