summaryrefslogtreecommitdiff
path: root/src/sim/process.cc
diff options
context:
space:
mode:
authorBrandon Potter <brandon.potter@amd.com>2016-03-17 10:31:03 -0700
committerBrandon Potter <brandon.potter@amd.com>2016-03-17 10:31:03 -0700
commit9b4249410ec18cac9df2c7e9c0a4a6ce5459233d (patch)
treec3260ef4f23b9eca7d835ab1e0dfc8ce1173b17c /src/sim/process.cc
parent4fc69db8f89049a881a5f4aa68545840818b124c (diff)
downloadgem5-9b4249410ec18cac9df2c7e9c0a4a6ce5459233d.tar.xz
base: support dynamic loading of Linux ELF objects in SE mode
Diffstat (limited to 'src/sim/process.cc')
-rw-r--r--src/sim/process.cc47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/sim/process.cc b/src/sim/process.cc
index 81a7ec89e..7fa160995 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -518,6 +518,48 @@ LiveProcess::findDriver(std::string filename)
return NULL;
}
+void
+LiveProcess::updateBias()
+{
+ ObjectFile *interp = objFile->getInterpreter();
+
+ if (!interp || !interp->relocatable())
+ return;
+
+ // Determine how large the interpreters footprint will be in the process
+ // address space.
+ Addr interp_mapsize = roundUp(interp->mapSize(), TheISA::PageBytes);
+
+ // We are allocating the memory area; set the bias to the lowest address
+ // in the allocated memory region.
+ Addr ld_bias = mmapGrowsDown() ? mmap_end - interp_mapsize : mmap_end;
+
+ // Adjust the process mmap area to give the interpreter room; the real
+ // execve system call would just invoke the kernel's internal mmap
+ // functions to make these adjustments.
+ mmap_end = mmapGrowsDown() ? ld_bias : mmap_end + interp_mapsize;
+
+ interp->updateBias(ld_bias);
+}
+
+
+Addr
+LiveProcess::getBias()
+{
+ ObjectFile *interp = objFile->getInterpreter();
+
+ return interp ? interp->bias() : objFile->bias();
+}
+
+
+Addr
+LiveProcess::getStartPC()
+{
+ ObjectFile *interp = objFile->getInterpreter();
+
+ return interp ? interp->entryPoint() : objFile->entryPoint();
+}
+
LiveProcess *
LiveProcess::create(LiveProcessParams * params)
@@ -535,11 +577,6 @@ LiveProcess::create(LiveProcessParams * params)
fatal("Can't load object file %s", params->executable);
}
- if (objFile->isDynamic())
- fatal("Object file is a dynamic executable however only static "
- "executables are supported!\n Please recompile your "
- "executable as a static binary and try again.\n");
-
#if THE_ISA == ALPHA_ISA
if (objFile->getArch() != ObjectFile::Alpha)
fatal("Object file architecture does not match compiled ISA (Alpha).");