Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
btf_encoder: handle .BTF_ids section endianness
btf_encoder__tag_kfuncs() reads .BTF_ids section to identify a set of kfuncs present in the ELF file being processed. This section consists of: - arrays of uint32_t elements; - arrays of records with the following structure: struct btf_id_and_flag { uint32_t id; uint32_t flags; }; When endianness of a binary operated by pahole differs from the host system's endianness, these fields require byte-swapping before use. Currently, this byte-swapping does not occur, resulting in kfuncs not being marked with declaration tags. This commit resolves the issue by using elf_getdata_rawchunk() function to read .BTF_ids section data. When called with ELF_T_WORD as 'type' parameter it does necessary byte order conversion (only if host and elf endianness do not match). Fixes: 72e88f2 ("pahole: Inject kfunc decl tags into BTF") Reviewed-by: Vadim Fedorenko <[email protected]> Signed-off-by: Eduard Zingerman <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Alan Maguire <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: Daniel Xu <[email protected]> Cc: [email protected] Cc: Kumar Kartikeya Dwivedi <[email protected]> Cc: Vadim Fedorenko <[email protected]> Cc: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
- Loading branch information