- recognize relocation emitted by llvm - since all regular function will be kept in .text section and llvm takes care of pc-relative offsets in bpf_call instruction simply copy all of .text to relevant program section while adjusting bpf_call instructions in program section to point to newly copied body of instructions from .text - do so for all programs in the elf file - set all programs types to the one passed to bpf_prog_load() Note for elf files with multiple programs that use different functions in .text section we need to do 'linker' style logic. This work is still TBD
Showing the changes to tools/include/uapi/linux (1 of 3 files). Show all
Unified · Split
| @@ -197,8 +197,14 @@ enum bpf_attach_type { · 196 unmodified lines | |||
| 197 | */ | 197 | */ |
| 198 | #define BPF_F_STRICT_ALIGNMENT (1U << 0) | 198 | #define BPF_F_STRICT_ALIGNMENT (1U << 0) |
| 199 | 199 | ||
| 200 | /* when bpf_ldimm64->src_reg == BPF_PSEUDO_MAP_FD, bpf_ldimm64->imm == fd */ | ||
| 200 | #define BPF_PSEUDO_MAP_FD 1 | 201 | #define BPF_PSEUDO_MAP_FD 1 |
| 201 | 202 | ||
| 203 | /* when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative | ||
| 204 | * offset to another bpf function | ||
| 205 | */ | ||
| 206 | #define BPF_PSEUDO_CALL 1 | ||
| 207 | |||
| 202 | /* flags for BPF_MAP_UPDATE_ELEM command */ | 208 | /* flags for BPF_MAP_UPDATE_ELEM command */ |
| 203 | #define BPF_ANY 0 /* create new element or update existing */ | 209 | #define BPF_ANY 0 /* create new element or update existing */ |
| 204 | #define BPF_NOEXIST 1 /* create new element if it didn't exist */ | 210 | #define BPF_NOEXIST 1 /* create new element if it didn't exist */ |