On Fri, 2024-09-20 at 00:49 -0700, Tony Ambardar wrote: > Initially, the .BTF_ids section was created zero-filled and then patched > with BTF IDs by resolve_btfids on the build host. Patching was done in > native endianness and thus failed to work for cross-endian compile targets. > This was fixed in [1] by using libelf-based translation to output patched > data in target byte order. > > The addition of 8-byte BTF sets in [2] lead to .BTF_ids creation with both > target-endian values and zero-filled data to be later patched. This again > broke cross-endian compilation as the already-correct target-endian values > were translated on output by libelf [1]. The problem was worked around [3] > by manually converting BTF SET8 values to native endianness, so that final > libelf output translation yields data in target byte order. > > Simplify and make the code more robust against future changes like [2] by > employing libelf-based endian translation on both input and output, which > is typical of libelf usage. > > [1]: 61e8aeda9398 ("bpf: Fix libelf endian handling in resolv_btfids") > [2]: ef2c6f370a63 ("tools/resolve_btfids: Add support for 8-byte BTF sets") > [3]: 903fad439466 ("tools/resolve_btfids: Fix cross-compilation to non-host endianness") > > CC: Viktor Malik <vmalik@xxxxxxxxxx> > Signed-off-by: Tony Ambardar <tony.ambardar@xxxxxxxxx> > --- Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx> [...]