-
Notifications
You must be signed in to change notification settings - Fork 834
Description
Describe the bug
I'd like to change the line field in the btf.Line structure for a single instruction of a program, but cannot find a way to do that.
Background
I'm templating an eBPF program by replacing a placeholder function in its instructions with some custom instructions. Then I use WithMetadata() (see #832) to copy over the metadata of the first placeholder instruction (that has the symbol) to the new one.
This works fine, but I'd like to also change the BTF line info for the first instruction to contain some information about the inserted logic so it can be recognized in an instruction dump / verifier log.
I could use .WithSource(asm.Comment("ABC")) for that, but this causes a missing bpf_line_info for 1 funcs starting from func#1 verifier error, because the line info seems to go missing then.
What I probably need to do is, to retrieve the existing bpf.Line structure using .Source().(*btf.Line) and change its fields, but these are unexported, so there doesn't seem to be a way to do that.
I'd like to discuss what would be the preferred solution here, before I make a pull request.
How to reproduce
Load an eBPF program and call this on the first instruction of a function (the one with the symbol):
insns[i] = insns[i].WithMetadata(insn.Metadata).WithSource(asm.Comment("ABC"))
Then try to load the program and check the verifier error.
Version information
github.com/cilium/ebpf v0.14.0