[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 26/36] loader: Allow ELF loader to auto-detect the EL
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 26/36] loader: Allow ELF loader to auto-detect the ELF arch |
Date: |
Thu, 22 Sep 2016 18:22:05 +0100 |
From: Alistair Francis <address@hidden>
If the caller didn't specify an architecture for the ELF machine
the load_elf() function will auto detect it based on the ELF file.
Signed-off-by: Alistair Francis <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
Message-id: address@hidden
Signed-off-by: Peter Maydell <address@hidden>
---
include/hw/elf_ops.h | 5 +++++
include/hw/loader.h | 2 ++
2 files changed, 7 insertions(+)
diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h
index f510e7e..5038c7f 100644
--- a/include/hw/elf_ops.h
+++ b/include/hw/elf_ops.h
@@ -280,6 +280,11 @@ static int glue(load_elf, SZ)(const char *name, int fd,
glue(bswap_ehdr, SZ)(&ehdr);
}
+ if (elf_machine <= EM_NONE) {
+ /* The caller didn't specify an ARCH, we can figure it out */
+ elf_machine = ehdr.e_machine;
+ }
+
switch (elf_machine) {
case EM_PPC64:
if (ehdr.e_machine != EM_PPC64) {
diff --git a/include/hw/loader.h b/include/hw/loader.h
index 4879b63..c59673d 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -68,6 +68,8 @@ const char *load_elf_strerror(int error);
* load will fail if the target ELF does not match. Some architectures
* have some architecture-specific behaviours that come into effect when
* their particular values for @elf_machine are set.
+ * If @elf_machine is EM_NONE then the machine type will be read from the
+ * ELF header and no checks will be carried out against the machine type.
*/
int load_elf(const char *filename, uint64_t (*translate_fn)(void *, uint64_t),
--
2.7.4
- [Qemu-devel] [PULL 04/36] aspeed-soc: provide a framework to add new SoCs, (continued)
- [Qemu-devel] [PULL 04/36] aspeed-soc: provide a framework to add new SoCs, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 31/36] loader: Add AddressSpace loading support to targphys, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 32/36] dma: xlnx-zynq-devcfg: Fix up XLNX_ZYNQ_DEVCFG_R_MAX, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 34/36] vmstateify ssi-sd, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 36/36] imx: Use 'const char', not 'char const', Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 06/36] palmetto-bmc: replace palmetto_bmc with aspeed, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 17/36] hw/ptimer: Introduce timer policy feature, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 19/36] tests: Add ptimer tests, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 24/36] cadence_gem: Correct indentation, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 28/36] loader: Allow a custom AddressSpace when loading ROMs, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 26/36] loader: Allow ELF loader to auto-detect the ELF arch,
Peter Maydell <=
- [Qemu-devel] [PULL 05/36] palmetto-bmc: rename the Aspeed board file to aspeed.c, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 23/36] cadence_gem: Add queue support, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 35/36] disas/arm.c: Remove unused macro definitions, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 33/36] vmstateify ssd0323 display, Peter Maydell, 2016/09/22
- Re: [Qemu-devel] [PULL 00/36] target-arm queue, no-reply, 2016/09/22
- Re: [Qemu-devel] [PULL 00/36] target-arm queue, Peter Maydell, 2016/09/23