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

Function process_reloc

dpdk/lib/bpf/bpf_load_elf.c:183–227  ·  view source on GitHub ↗

* helper function to process data from relocation table. */

Source from the content-addressed store, hash-verified

181 * helper function to process data from relocation table.
182 */
183static int
184process_reloc(Elf *elf, size_t sym_idx, Elf64_Rel *re, size_t re_sz,
185 struct ebpf_insn *ins, size_t ins_sz, const struct rte_bpf_prm *prm)
186{
187 int32_t rc;
188 uint32_t i, n;
189 size_t ofs, sym;
190 const char *sn;
191 const Elf64_Ehdr *eh;
192 Elf_Scn *sc;
193 const Elf_Data *sd;
194 Elf64_Sym *sm;
195
196 eh = elf64_getehdr(elf);
197
198 /* get symtable by section index */
199 sc = elf_getscn(elf, sym_idx);
200 sd = elf_getdata(sc, NULL);
201 if (sd == NULL)
202 return -EINVAL;
203 sm = sd->d_buf;
204
205 n = re_sz / sizeof(re[0]);
206 for (i = 0; i != n; i++) {
207
208 ofs = re[i].r_offset;
209
210 /* retrieve index in the symtable */
211 sym = ELF64_R_SYM(re[i].r_info);
212 if (sym * sizeof(sm[0]) >= sd->d_size)
213 return -EINVAL;
214
215 sn = elf_strptr(elf, eh->e_shstrndx, sm[sym].st_name);
216
217 rc = resolve_xsym(sn, ofs, ins, ins_sz, prm);
218 if (rc != 0) {
219 RTE_BPF_LOG(ERR,
220 "resolve_xsym(%s, %zu) error code: %d\n",
221 sn, ofs, rc);
222 return rc;
223 }
224 }
225
226 return 0;
227}
228
229/*
230 * helper function, find relocation information (if any)

Callers 1

elf_reloc_codeFunction · 0.85

Calls 1

resolve_xsymFunction · 0.85

Tested by

no test coverage detected