]> git.baikalelectronics.ru Git - uboot.git/commit
tools: relocate-rela: Fix ELF decoding on big-endian hosts
authorSamuel Holland <samuel@sholland.org>
Fri, 15 Jul 2022 06:40:25 +0000 (01:40 -0500)
committerMichal Simek <michal.simek@amd.com>
Tue, 26 Jul 2022 06:23:54 +0000 (08:23 +0200)
commitc4f679f2adeeaa40f6a39ee0b11021d6f8cd170a
tree35587760956fd35d974bc7207c0d0cc6623699a9
parentf678dc9a8a1cc97d2055b522bec801d461da7a15
tools: relocate-rela: Fix ELF decoding on big-endian hosts

The new ELF decoding logic assumed that the target binary has the same
endianness as the host, which broke building ARM64 firmware binaries on
big-endian machines.

This commit fixes the ELF64 decoding to be host-endianness-neutral, and
applies the same changes to the ELF32 decoding. It does not fix the
microblaze-specific dynamic symbol decoding.

It also corrects the functions used for byte swapping in rela_elf64()
and rela_elf32(). The result is the same, but semantically the code is
converting bytes read from a foreign-endianness file to host byte order.

Fixes: 85349d86cd6d ("tools: relocate-rela: Read rela start/end directly from ELF")
Fixes: b228c6625931 ("tools: relocate-rela: Check that relocation works only for EM_AARCH64")
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20220715064026.54551-1-samuel@sholland.org
Signed-off-by: Michal Simek <michal.simek@amd.com>
tools/relocate-rela.c