MCPcopy Create free account
hub / github.com/F-Stack/f-stack / elf_reloc_code

Function elf_reloc_code

dpdk/lib/bpf/bpf_load_elf.c:233–264  ·  view source on GitHub ↗

* helper function, find relocation information (if any) * and update bpf code. */

Source from the content-addressed store, hash-verified

231 * and update bpf code.
232 */
233static int
234elf_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
266static struct rte_bpf *
267bpf_load_elf(const struct rte_bpf_prm *prm, int32_t fd, const char *section)

Callers 1

bpf_load_elfFunction · 0.85

Calls 1

process_relocFunction · 0.85

Tested by

no test coverage detected