From: Gabe Black Date: Wed, 2 Oct 2019 04:22:07 +0000 (-0700) Subject: arch,base: Stop loading the interpreter in ElfObject. X-Git-Tag: v19.0.0.0~458 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dd2b3bde4c3d067af68e1f2d10db81d9d0af9cb5;p=gem5.git arch,base: Stop loading the interpreter in ElfObject. The interpreter is a separate object file, and while it's convenient to hide loading it in the code which loads the main object file, it breaks the conceptual abstraction since you only asked it to load the main object file. Also, this makes every object file format reimplement the idea of loading the interpreter. Admittedly only ELF recognizes and sets up an interpreter, but other formats conceptually could too. This does move that limitted hypothetical redundancy out of the object file formats and moves it into the process objects, but I think conceptually that's where it belongs. It would also probably be pretty easy to add a method to the base Process class that would handle loading an image and also the interpreter image. This change does not (yet) separate reading symbol tables. Change-Id: I4a165eac599a9bcd30371a162379e833c4cc89b4 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21465 Tested-by: kokoro Reviewed-by: Brandon Potter Reviewed-by: Andreas Sandberg Maintainer: Gabe Black --- diff --git a/src/arch/alpha/process.cc b/src/arch/alpha/process.cc index 59cbebc1c..e266b92b2 100644 --- a/src/arch/alpha/process.cc +++ b/src/arch/alpha/process.cc @@ -78,6 +78,8 @@ AlphaProcess::argsInit(int intSize, int pageSize) updateBias(); objFile->loadSegments(initVirtMem); + if (objFile->getInterpreter()) + objFile->getInterpreter()->loadSegments(initVirtMem); std::vector> auxv; diff --git a/src/arch/arm/process.cc b/src/arch/arm/process.cc index f98572690..ff3b92f48 100644 --- a/src/arch/arm/process.cc +++ b/src/arch/arm/process.cc @@ -271,6 +271,8 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex) // load object file into target memory objFile->loadSegments(initVirtMem); + if (objFile->getInterpreter()) + objFile->getInterpreter()->loadSegments(initVirtMem); //Setup the auxilliary vectors. These will already have endian conversion. //Auxilliary vectors are loaded only for elf formatted executables. diff --git a/src/arch/mips/process.cc b/src/arch/mips/process.cc index 1808372d9..4c4b0e414 100644 --- a/src/arch/mips/process.cc +++ b/src/arch/mips/process.cc @@ -94,6 +94,8 @@ MipsProcess::argsInit(int pageSize) // load object file into target memory objFile->loadSegments(initVirtMem); + if (objFile->getInterpreter()) + objFile->getInterpreter()->loadSegments(initVirtMem); std::vector> auxv; diff --git a/src/arch/power/process.cc b/src/arch/power/process.cc index b391773ee..89b94b21f 100644 --- a/src/arch/power/process.cc +++ b/src/arch/power/process.cc @@ -100,6 +100,8 @@ PowerProcess::argsInit(int intSize, int pageSize) // load object file into target memory objFile->loadSegments(initVirtMem); + if (objFile->getInterpreter()) + objFile->getInterpreter()->loadSegments(initVirtMem); //Setup the auxilliary vectors. These will already have endian conversion. //Auxilliary vectors are loaded only for elf formatted executables. diff --git a/src/arch/riscv/process.cc b/src/arch/riscv/process.cc index e15197d78..35dde7600 100644 --- a/src/arch/riscv/process.cc +++ b/src/arch/riscv/process.cc @@ -125,6 +125,8 @@ RiscvProcess::argsInit(int pageSize) updateBias(); objFile->loadSegments(initVirtMem); + if (objFile->getInterpreter()) + objFile->getInterpreter()->loadSegments(initVirtMem); ElfObject* elfObject = dynamic_cast(objFile); memState->setStackMin(memState->getStackBase()); diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc index cca61c1be..1c020c6b1 100644 --- a/src/arch/sparc/process.cc +++ b/src/arch/sparc/process.cc @@ -209,6 +209,8 @@ SparcProcess::argsInit(int pageSize) // load object file into target memory objFile->loadSegments(initVirtMem); + if (objFile->getInterpreter()) + objFile->getInterpreter()->loadSegments(initVirtMem); enum hardwareCaps { diff --git a/src/arch/x86/process.cc b/src/arch/x86/process.cc index c743685d0..546474138 100644 --- a/src/arch/x86/process.cc +++ b/src/arch/x86/process.cc @@ -775,6 +775,8 @@ X86Process::argsInit(int pageSize, // load object file into target memory objFile->loadSegments(initVirtMem); + if (objFile->getInterpreter()) + objFile->getInterpreter()->loadSegments(initVirtMem); enum X86CpuFeature { X86_OnboardFPU = 1 << 0, diff --git a/src/base/loader/elf_object.cc b/src/base/loader/elf_object.cc index 4dee7d2c0..4cf20975d 100644 --- a/src/base/loader/elf_object.cc +++ b/src/base/loader/elf_object.cc @@ -464,18 +464,6 @@ ElfObject::loadWeakSymbols(SymbolTable *symtab, Addr base, Addr offset, return loadSomeSymbols(symtab, STB_WEAK, addr_mask, base, offset); } -bool -ElfObject::loadSegments(const PortProxy &mem_proxy) -{ - if (!ObjectFile::loadSegments(mem_proxy)) - return false; - - if (interpreter) - interpreter->loadSegments(mem_proxy); - - return true; -} - void ElfObject::getSections() { diff --git a/src/base/loader/elf_object.hh b/src/base/loader/elf_object.hh index f2af4142a..dbefadd19 100644 --- a/src/base/loader/elf_object.hh +++ b/src/base/loader/elf_object.hh @@ -89,8 +89,6 @@ class ElfObject : public ObjectFile public: virtual ~ElfObject() {} - bool loadSegments(const PortProxy &mem_proxy) override; - virtual bool loadAllSymbols(SymbolTable *symtab, Addr base = 0, Addr offset = 0, Addr addr_mask = maxAddr) override;