Re: [PATCH dwarves v1] btf_encoder: handle .BTF_ids section endianness when cross-compiling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21/11/2024 23:02, Eduard Zingerman wrote:
btf_encoder__tag_kfuncs() reads .BTF_ids section to identify a set of
kfuncs present in the ELF being processed. This section consists of
records of the following shape:

   struct btf_id_and_flag {
       uint32_t id;
       uint32_t flags;
   };

When endianness of binary operated by pahole differs from the
host endianness these fields require byte swap before using.

At the moment such byte swap does not happen and kfuncs are not marked
with decl tags when e.g. s390 kernel is compiled on x86.
To reproduces the bug:
- follow instructions from [0] to build an s390 vmlinux;
- execute:
   pahole --btf_features_strict=decl_tag_kfuncs,decl_tag \
          --btf_encode_detached=test.btf vmlinux
- observe no kfuncs generated:
   bpftool btf dump test.btf format c | grep __ksym

This commit fixes the issue by adding an endianness conversion step
for .BTF_ids section data before main processing step, modifying the
Elf_Data object in-place.
The choice is such in order to:
- minimize changes;
- keep using Elf_Data, as it provides fields {d_size,d_off} used
   by kfunc processing routines;
- avoid sprinkling bswap_32 at each 'struct btf_id_and_flag' field
   access in fear of forgetting to add new ones when code is modified.

[0] https://docs.kernel.org/bpf/s390.html


LGTM, Thanks!

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@xxxxxxxxx>






[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux