aboutsummaryrefslogtreecommitdiff
path: root/include/hw/elf_ops.h
diff options
context:
space:
mode:
authorAlistair Francis <alistair.francis@xilinx.com>2016-09-22 18:13:07 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-09-22 18:13:07 +0100
commit8cf6e9daca19e08216cf09e523d1dcdf3cfdaec7 (patch)
tree5353ce4f931eb3212601a125e534e912173e2182 /include/hw/elf_ops.h
parent1372fc0b87b80634313ad332279f9c7ca0583862 (diff)
loader: Allow ELF loader to auto-detect the ELF arch
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 <alistair.francis@xilinx.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: f2d70b47fcad31445f947f8817a0e146d80a046b.1474331683.git.alistair.francis@xilinx.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include/hw/elf_ops.h')
-rw-r--r--include/hw/elf_ops.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h
index f510e7ec2a..5038c7f058 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) {