You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
program: move jump and call fixup out of asm package
Jumps and calls may have to be fixed up, if their target isn't known
at compile time. This happens when a user uses the asm package to write
"inline" BPF programs, and when using function calls in C derived BPF.
The jump and call targets have to be expressed in units of raw BPF
instructions. Since some asm.Instructions have to be encoded in two
BPF instructions there is no 1:1 mapping. Figuring out the raw
instruction offset therefore involves iterating all instructions
and keeping a running count.
Due to this the fixup currently happens during instruction marshalling.
This is a bit of a hack, but so far allowed to keep the details of raw
instruction offsets contained to the asm package.
With BPF CO-RE this doesn't work too well anymore: the fixup we have to do
is also based on raw BPF instruction offsets. Cramming this into
instruction marshalling seems like the wrong thing to do, and is
probably not possible due to import cycles between the asm and btf
package.
Introduce a RawInstructionOffset type and an InstructionIterator to
encapsulate the raw offset handling, and move jump and call fixup to
a function in the main package.
0 commit comments