[PATCH 0/6] hw/loader: Pass ELFDATA endian order argument to load_elf()

Philippe Mathieu-Daudé posted 6 patches 2 months, 1 week ago
include/hw/loader.h            | 22 ++++------------
hw/core/loader.c               | 48 +++++++++++-----------------------
hw/alpha/dp264.c               |  4 +--
hw/arm/armv7m.c                |  2 +-
hw/arm/boot.c                  | 16 ++++++------
hw/avr/boot.c                  |  8 +++---
hw/core/generic-loader.c       |  6 +----
hw/hppa/machine.c              |  4 +--
hw/i386/multiboot.c            |  4 +--
hw/i386/x86-common.c           |  4 +--
hw/loongarch/boot.c            |  2 +-
hw/m68k/an5206.c               |  2 +-
hw/m68k/mcf5208.c              |  2 +-
hw/m68k/q800.c                 |  2 +-
hw/m68k/virt.c                 |  2 +-
hw/microblaze/boot.c           |  6 +++--
hw/mips/boston.c               |  2 +-
hw/mips/fuloong2e.c            |  2 +-
hw/mips/loongson3_virt.c       |  2 +-
hw/mips/malta.c                |  5 ++--
hw/mips/mipssim.c              |  3 ++-
hw/openrisc/boot.c             |  2 +-
hw/pci-host/raven.c            |  4 +--
hw/ppc/e500.c                  |  2 +-
hw/ppc/mac_newworld.c          |  5 ++--
hw/ppc/mac_oldworld.c          |  4 +--
hw/ppc/pegasos2.c              |  8 +++---
hw/ppc/ppc405_boards.c         |  2 +-
hw/ppc/ppc440_bamboo.c         |  3 ++-
hw/ppc/sam460ex.c              |  2 +-
hw/ppc/spapr.c                 |  8 +++---
hw/ppc/virtex_ml507.c          |  4 +--
hw/riscv/boot.c                |  3 ++-
hw/s390x/ipl.c                 |  6 ++---
hw/sparc/leon3.c               |  2 +-
hw/sparc/sun4m.c               |  5 ++--
hw/sparc64/sun4u.c             |  6 ++---
hw/tricore/triboard.c          |  2 +-
hw/tricore/tricore_testboard.c |  2 +-
hw/xtensa/sim.c                |  3 ++-
hw/xtensa/xtfpga.c             |  3 ++-
41 files changed, 99 insertions(+), 125 deletions(-)
[PATCH 0/6] hw/loader: Pass ELFDATA endian order argument to load_elf()
Posted by Philippe Mathieu-Daudé 2 months, 1 week ago
Hi,

The goal of this series is to be able to use the generic loader
on heterogeneous binary. In order to do that we need to remove
its target_words_bigendian() call. This series replace the
'bool is_big_endian' (~equivalent) argument of load_elf*() API
by ELFDATA (which can be LSB / MSB or NONE), updating all the
call sites.

Philippe Mathieu-Daudé (6):
  hw/avr/boot: Replace load_elf_ram_sym() -> load_elf_as()
  hw/loader: Remove unused load_elf_ram()
  hw/loader: Clarify local variable name in load_elf_ram_sym()
  hw/loader: Pass ELFDATA endian order argument to load_elf_ram_sym()
  hw/loader: Pass ELFDATA endian order argument to load_elf_as()
  hw/loader: Pass ELFDATA endian order argument to load_elf()

 include/hw/loader.h            | 22 ++++------------
 hw/core/loader.c               | 48 +++++++++++-----------------------
 hw/alpha/dp264.c               |  4 +--
 hw/arm/armv7m.c                |  2 +-
 hw/arm/boot.c                  | 16 ++++++------
 hw/avr/boot.c                  |  8 +++---
 hw/core/generic-loader.c       |  6 +----
 hw/hppa/machine.c              |  4 +--
 hw/i386/multiboot.c            |  4 +--
 hw/i386/x86-common.c           |  4 +--
 hw/loongarch/boot.c            |  2 +-
 hw/m68k/an5206.c               |  2 +-
 hw/m68k/mcf5208.c              |  2 +-
 hw/m68k/q800.c                 |  2 +-
 hw/m68k/virt.c                 |  2 +-
 hw/microblaze/boot.c           |  6 +++--
 hw/mips/boston.c               |  2 +-
 hw/mips/fuloong2e.c            |  2 +-
 hw/mips/loongson3_virt.c       |  2 +-
 hw/mips/malta.c                |  5 ++--
 hw/mips/mipssim.c              |  3 ++-
 hw/openrisc/boot.c             |  2 +-
 hw/pci-host/raven.c            |  4 +--
 hw/ppc/e500.c                  |  2 +-
 hw/ppc/mac_newworld.c          |  5 ++--
 hw/ppc/mac_oldworld.c          |  4 +--
 hw/ppc/pegasos2.c              |  8 +++---
 hw/ppc/ppc405_boards.c         |  2 +-
 hw/ppc/ppc440_bamboo.c         |  3 ++-
 hw/ppc/sam460ex.c              |  2 +-
 hw/ppc/spapr.c                 |  8 +++---
 hw/ppc/virtex_ml507.c          |  4 +--
 hw/riscv/boot.c                |  3 ++-
 hw/s390x/ipl.c                 |  6 ++---
 hw/sparc/leon3.c               |  2 +-
 hw/sparc/sun4m.c               |  5 ++--
 hw/sparc64/sun4u.c             |  6 ++---
 hw/tricore/triboard.c          |  2 +-
 hw/tricore/tricore_testboard.c |  2 +-
 hw/xtensa/sim.c                |  3 ++-
 hw/xtensa/xtfpga.c             |  3 ++-
 41 files changed, 99 insertions(+), 125 deletions(-)

-- 
2.47.1


Re: [PATCH 0/6] hw/loader: Pass ELFDATA endian order argument to load_elf()
Posted by Philippe Mathieu-Daudé 2 months ago
On 27/1/25 12:38, Philippe Mathieu-Daudé wrote:

> Philippe Mathieu-Daudé (6):
>    hw/avr/boot: Replace load_elf_ram_sym() -> load_elf_as()
>    hw/loader: Remove unused load_elf_ram()
>    hw/loader: Clarify local variable name in load_elf_ram_sym()

Thanks, series queued squashing:

-- >8--

diff --git a/hw/core/loader.c b/hw/core/loader.c
index 8afb2d6cf35..fd25c5e01bd 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -445,3 +445,4 @@ ssize_t load_elf_ram_sym(const char *filename,
  {
-    int fd, host_data_order, must_swab;
+    const int host_data_order = HOST_BIG_ENDIAN ? ELFDATA2MSB : 
ELFDATA2LSB;
+    int fd, must_swab;
      ssize_t ret = ELF_LOAD_FAILED;
@@ -469,7 +470,2 @@ ssize_t load_elf_ram_sym(const char *filename,

-#if HOST_BIG_ENDIAN
-    host_data_order = ELFDATA2MSB;
-#else
-    host_data_order = ELFDATA2LSB;
-#endif
      must_swab = host_data_order != e_ident[EI_DATA];
---

>    hw/loader: Pass ELFDATA endian order argument to load_elf_ram_sym()
>    hw/loader: Pass ELFDATA endian order argument to load_elf_as()
>    hw/loader: Pass ELFDATA endian order argument to load_elf()