
On 3/5/23 18:49, Ovidiu Panait wrote:
Add elf16_to_cpu() and elf32_to_cpu() functions that allow to read data in both big-endian and little-endian formats.
Signed-off-by: Ovidiu Panait ovpanait@gmail.com
tools/relocate-rela.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index 689e2d4655..84531b23a6 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -45,6 +45,7 @@ #endif
static int ei_class; +static int ei_data;
static uint64_t rela_start, rela_end, text_base, dyn_start;
@@ -61,6 +62,22 @@ static void debug(const char *fmt, ...) } }
+static uint16_t elf16_to_cpu(uint16_t data) +{
- if (ei_data == 0x01)
Can we used macros instead of hardcoding value?
/* e_ident[] data encoding */ #define ELFDATANONE 0 /* invalid */ #define ELFDATA2LSB 1 /* Little-Endian */ #define ELFDATA2MSB 2 /* Big-Endian */ #define ELFDATANUM 3 /* number of data encode defines */
M