Skip to content

btf_encoder: handle .BTF_ids section endianness

Eduard Zingerman bpf dwarves 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest1 patch 7 repliesIn review
  2. v21 patch 5 repliesSuperseded
  3. v11 patch 8 repliesSuperseded

Changelog from the cover letter

- v1 [1] -> v2:
- avoid modifying the 'idlist' Elf_Data object directly.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1btf_encoder: handle .BTF_ids section endiannessbtf_encoder.c+20 -67 replies

Reviews trailers per patch

The patch has a Reviewed-by or Acked-by.

PatchJiri OlsaVadim Fedorenko
1/1A-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH dwarves v3 0/1] btf_encoder: handle .BTF_ids section endianness

Currently, pahole does not generate kfunc declaration tags when generating BTF for ELF files with an endianness different from the host system. For example, this issue occurs when processing a vmlinux built for s390 on an x86 host.

To reproduce the bug:
- follow the instructions in [0] to build an s390 vmlinux;
- generate BTF requesting declaration tags for kfuncs:

  $ pahole --btf_features_strict=decl_tag_kfuncs,decl_tag \
           --btf_encode_detached=test.btf vmlinux
- observe that no kfuncs are generated:
  $ bpftool btf dump file test.btf format c | grep __ksym

This patch resolves the issue by adding the necessary byte-swapping operations.

Changelog:
- v1 [1] -> v2:
- avoid modifying the 'idlist' Elf_Data object directly.

    Instead, use struct local_elf_data (suggested by Jiri);
  - update the description of the .BTF_ids section (suggested by Jiri).
- v2 [2] -> v3:
  - use elf_getdata_rawchunk() instead of direct conversion loop
    (suggested by Andrii);

- removed Jiri's acked-by and Vadim's reviewed-by, as patch had changed significantly.

[0] https://docs.kernel.org/bpf/s390.html
[1] https://lore.kernel.org/dwarves/[email protected]/
[2] https://lore.kernel.org/dwarves/[email protected]/

Cc Alan Maguire <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Daniel Xu <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kumar Kartikeya Dwivedi <[email protected]>
Cc Vadim Fedorenko <[email protected]>

Eduard Zingerman (1):
btf_encoder: handle .BTF_ids section endianness

 btf_encoder.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)
Signature · 1 line
2.47.0