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.
CC: Viktor Malik vmalik@redhat.com Signed-off-by: Tony Ambardar tony.ambardar@gmail.com
Acked-by: Eduard Zingerman eddyz87@gmail.com
[...]