* helper function, find relocation information (if any) * and update bpf code. */
| 231 | * and update bpf code. |
| 232 | */ |
| 233 | static int |
| 234 | elf_reloc_code(Elf *elf, Elf_Data *ed, size_t sidx, |
| 235 | const struct rte_bpf_prm *prm) |
| 236 | { |
| 237 | Elf64_Rel *re; |
| 238 | Elf_Scn *sc; |
| 239 | const Elf64_Shdr *sh; |
| 240 | const Elf_Data *sd; |
| 241 | int32_t rc; |
| 242 | |
| 243 | rc = 0; |
| 244 | |
| 245 | /* walk through all sections */ |
| 246 | for (sc = elf_nextscn(elf, NULL); sc != NULL && rc == 0; |
| 247 | sc = elf_nextscn(elf, sc)) { |
| 248 | |
| 249 | sh = elf64_getshdr(sc); |
| 250 | |
| 251 | /* relocation data for our code section */ |
| 252 | if (sh->sh_type == SHT_REL && sh->sh_info == sidx) { |
| 253 | sd = elf_getdata(sc, NULL); |
| 254 | if (sd == NULL || sd->d_size == 0 || |
| 255 | sd->d_size % sizeof(re[0]) != 0) |
| 256 | return -EINVAL; |
| 257 | rc = process_reloc(elf, sh->sh_link, |
| 258 | sd->d_buf, sd->d_size, ed->d_buf, ed->d_size, |
| 259 | prm); |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | return rc; |
| 264 | } |
| 265 | |
| 266 | static struct rte_bpf * |
| 267 | bpf_load_elf(const struct rte_bpf_prm *prm, int32_t fd, const char *section) |
no test coverage detected