summary refs log tree commit diff stats
path: root/hw
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2025-01-26 14:54:00 +0100
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2025-01-31 19:36:44 +0100
commit518f8fdfe265ffff6e2f2ad7a7bbb7f95b270434 (patch)
tree37096c80b7f4619f9bcf505f789a548181b26249 /hw
parentff12b602fc9077197839f068b5c21beb82c71964 (diff)
downloadfocaccia-qemu-518f8fdfe265ffff6e2f2ad7a7bbb7f95b270434.tar.gz
focaccia-qemu-518f8fdfe265ffff6e2f2ad7a7bbb7f95b270434.zip
hw/loader: Clarify local variable name in load_elf_ram_sym()
load_elf_ram_sym() compares target_data_order versus
host data_order. Rename 'data_order' -> 'host_data_order'
to ease code review. Avoid the preprocessor by directly
checking HOST_BIG_ENDIAN.

Reviewed-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250127113824.50177-4-philmd@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/core/loader.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/hw/core/loader.c b/hw/core/loader.c
index ead10fb6cb..de6b173f4a 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -443,7 +443,8 @@ ssize_t load_elf_ram_sym(const char *filename,
                          int clear_lsb, int data_swab,
                          AddressSpace *as, bool load_rom, symbol_fn_t sym_cb)
 {
-    int fd, data_order, target_data_order, must_swab;
+    const int host_data_order = HOST_BIG_ENDIAN ? ELFDATA2MSB : ELFDATA2LSB;
+    int fd, target_data_order, must_swab;
     ssize_t ret = ELF_LOAD_FAILED;
     uint8_t e_ident[EI_NIDENT];
 
@@ -461,12 +462,7 @@ ssize_t load_elf_ram_sym(const char *filename,
         ret = ELF_LOAD_NOT_ELF;
         goto fail;
     }
-#if HOST_BIG_ENDIAN
-    data_order = ELFDATA2MSB;
-#else
-    data_order = ELFDATA2LSB;
-#endif
-    must_swab = data_order != e_ident[EI_DATA];
+    must_swab = host_data_order != e_ident[EI_DATA];
     if (big_endian) {
         target_data_order = ELFDATA2MSB;
     } else {