From fe7ace1e919fb160107701edc870548b9da155bc Mon Sep 17 00:00:00 2001 From: Sandipan Das Date: Mon, 4 Jun 2018 21:51:23 +0530 Subject: [PATCH] arch-power: Make ELF interpreter read 64-bit LSB executables This makes the ELF interpreter read 64-bit little endian (LSB) PowerPC executables only. This drops support for the 32-bit big endian (MSB) executables as the goal here is to enable a modern 64-bit execution environment for the Power ISA. Change-Id: I0569f7e1d1e58ce874ec2d13291e7a758d56399f Signed-off-by: Sandipan Das --- src/arch/power/isa_traits.hh | 4 ++-- src/base/loader/elf_object.cc | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/arch/power/isa_traits.hh b/src/arch/power/isa_traits.hh index 9afe6803a..99f76ffad 100644 --- a/src/arch/power/isa_traits.hh +++ b/src/arch/power/isa_traits.hh @@ -39,12 +39,12 @@ #include "base/types.hh" #include "cpu/static_inst_fwd.hh" -namespace BigEndianGuest {} +namespace LittleEndianGuest {} namespace PowerISA { -using namespace BigEndianGuest; +using namespace LittleEndianGuest; StaticInstPtr decodeInst(ExtMachInst); diff --git a/src/base/loader/elf_object.cc b/src/base/loader/elf_object.cc index 60c79f803..8e1e065a5 100644 --- a/src/base/loader/elf_object.cc +++ b/src/base/loader/elf_object.cc @@ -115,16 +115,17 @@ ElfObject::tryFile(const std::string &fname, size_t len, uint8_t *data, arch = Riscv; } else if (ehdr.e_machine == EM_PPC && ehdr.e_ident[EI_CLASS] == ELFCLASS32) { + fatal("The binary you're trying to load is compiled for 32-bit " + "Power.\ngem5 only supports 64-bit Power. Please " + "recompile your binary.\n"); + } else if (ehdr.e_machine == EM_PPC64 && + ehdr.e_ident[EI_CLASS] == ELFCLASS64) { arch = Power; - if (ehdr.e_ident[EI_DATA] != ELFDATA2MSB) { + if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB) { fatal("The binary you're trying to load is compiled for " - "little endian Power.\ngem5 only supports big " + "big endian Power.\ngem5 only supports little " "endian Power. Please recompile your binary.\n"); } - } else if (ehdr.e_machine == EM_PPC64) { - fatal("The binary you're trying to load is compiled for 64-bit " - "Power. M5\n only supports 32-bit Power. Please " - "recompile your binary.\n"); } else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) { // Since we don't know how to check for alpha right now, we'll // just assume if it wasn't something else and it's 64 bit, that's -- 2.30.2