mbox series

[dwarves,v2,0/4] BTF ELF writing changes

Message ID 20210201172530.1141087-1-gprocida@google.com (mailing list archive)
Headers show
Series BTF ELF writing changes | expand

Message

Giuliano Procida Feb. 1, 2021, 5:25 p.m. UTC
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(-)