Searched hist:"3774705 db1718a671a4ed2ac5066fea839b1d7d1" (Results 1 – 1 of 1) sorted by relevance
/openbmc/linux/tools/lib/bpf/ |
H A D | elf.c | diff 3774705db1718a671a4ed2ac5066fea839b1d7d1 Wed Aug 09 03:34:22 CDT 2023 Jiri Olsa <jolsa@kernel.org> libbpf: Add elf symbol iterator
Adding elf symbol iterator object (and some functions) that follow open-coded iterator pattern and some functions to ease up iterating elf object symbols.
The idea is to iterate single symbol section with:
struct elf_sym_iter iter; struct elf_sym *sym;
if (elf_sym_iter_new(&iter, elf, binary_path, SHT_DYNSYM)) goto error;
while ((sym = elf_sym_iter_next(&iter))) { ... }
I considered opening the elf inside the iterator and iterate all symbol sections, but then it gets more complicated wrt user checks for when the next section is processed.
Plus side is the we don't need 'exit' function, because caller/user is in charge of that.
The returned iterated symbol object from elf_sym_iter_next function is placed inside the struct elf_sym_iter, so no extra allocation or argument is needed.
Suggested-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20230809083440.3209381-11-jolsa@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
|