Note: The 4 patches in this series supersede patches 2-4 of the previous version of this series (patch 1 was applied). pahole -J currently uses llvm-objcopy to add .BTF as a section (and segment) to an ELF object containing DWARF debug information. If a .BTF section is already present it is rewritten but segment information is not updated. In terms of the current Linux linker script, all that's needed is either a dump of the raw BTF or a file containing a .BTF section. This is because the script dumps .BTF out to a file, creates a single-section ELF file and then links this into a final vmlinux. The first commit in this series removes the dependency on llvm-objcopy. The remaining commits attempt to roughly duplicate the desired end result, namely adding a .BTF section which is also a loadable segment. They may not be sufficient. In terms of non-kernel .BTF use, they are probably not necessary. Nevertheless, this was an interesting exercise and removing the llvm-objcopy dependency is a worthwhile goal. I'm not well-placed to test the viability of vmlinux with .BTF as generated by these patches, so any feedback is very welcome. Giuliano Procida (4): btf_encoder: Add .BTF section using libelf btf_encoder: Manually lay out updated ELF sections btf_encoder: Add .BTF as a loadable segment btf_encoder: Align .BTF section/segment to 8 bytes libbtf.c | 240 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 197 insertions(+), 43 deletions(-) -- 2.30.0.365.g02bc693789-goog