From 25a4424af47ad59030db0a2783957944510c689e 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 | 8 +++++++- src/base/loader/elf_object.cc | 12 ++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/arch/power/isa_traits.hh b/src/arch/power/isa_traits.hh index 4cf0c4430..2d90895c7 100644 --- a/src/arch/power/isa_traits.hh +++ b/src/arch/power/isa_traits.hh @@ -32,11 +32,17 @@ #define __ARCH_POWER_ISA_TRAITS_HH__ #include "base/types.hh" +#include "cpu/static_inst_fwd.hh" + +namespace LittleEndianGuest {} namespace PowerISA { -const ByteOrder GuestByteOrder = ByteOrder::big; +const ByteOrder GuestByteOrder = ByteOrder::little; +using namespace LittleEndianGuest; + +StaticInstPtr decodeInst(ExtMachInst); const Addr PageShift = 12; const Addr PageBytes = ULL(1) << PageShift; diff --git a/src/base/loader/elf_object.cc b/src/base/loader/elf_object.cc index 49fbd6dd7..124d983b3 100644 --- a/src/base/loader/elf_object.cc +++ b/src/base/loader/elf_object.cc @@ -245,16 +245,16 @@ ElfObject::determineArch() } else if (emach == EM_RISCV) { arch = (eclass == ELFCLASS64) ? Riscv64 : Riscv32; } else if (emach == EM_PPC && eclass == 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 (emach == EM_PPC64 && eclass == ELFCLASS64) { arch = Power; - if (edata != ELFDATA2MSB) { + if (edata != 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 (emach == 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 { warn("Unknown architecture: %d\n", emach); } -- 2.30.2