summaryrefslogtreecommitdiff
path: root/src/sim/process.cc
diff options
context:
space:
mode:
authorJoel Hestness <jthestness@gmail.com>2015-09-29 09:25:20 -0500
committerJoel Hestness <jthestness@gmail.com>2015-09-29 09:25:20 -0500
commit395b31f518f6d5f4be3c57ae47762ad4597b0247 (patch)
tree75f1acc037fb4d928d4562e771cc5fda5939e3fe /src/sim/process.cc
parent9a0129dcbf3cc223c88b8c0bc46ac9b375c11abf (diff)
downloadgem5-395b31f518f6d5f4be3c57ae47762ad4597b0247.tar.xz
syscall_emul: Bandage readlink /proc/self/exe
The recent changeset to readlink() to handle reading the /proc/self/exe link introduces a number of problems. This patch fixes two: 1) Because readlink() called on /proc/self/exe now uses LiveProcess::progName() to find the binary path, it will only get the zeroth parameter of the simulated system command line. However, if a config script also specifies the process' executable, the executable parameter is used to create the LiveProcess rather than the zeroth command line parameter. Thus, the zeroth command line parameter is not necessarily the correct path to the binary executing in the simulated system. To fix this, add a LiveProcess data member, 'executable', which is correctly set during instantiation and returned from progName(). 2) If a config script allows a user to pass a relative path as the zeroth simulated system command line parameter or process executable, readlink() will incorrecly return a relative path when called on '/proc/self/exe'. /proc/self/exe is always set to a full path, so running benchmarks can fail if a relative path is returned. To fix this, clean up the handling of LiveProcess::progName() within readlink() to get the full binary path. NOTE: This patch still leaves the potential problem that host full path to the binary bleeds into the simulated system, potentially causing the appearance of non-deterministic simulated system execution.
Diffstat (limited to 'src/sim/process.cc')
-rw-r--r--src/sim/process.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/sim/process.cc b/src/sim/process.cc
index 575627367..def42c0b2 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -472,6 +472,7 @@ Process::map(Addr vaddr, Addr paddr, int size, bool cacheable)
LiveProcess::LiveProcess(LiveProcessParams *params, ObjectFile *_objFile)
: Process(params), objFile(_objFile),
argv(params->cmd), envp(params->env), cwd(params->cwd),
+ executable(params->executable),
__uid(params->uid), __euid(params->euid),
__gid(params->gid), __egid(params->egid),
__pid(params->pid), __ppid(params->ppid),
@@ -528,11 +529,15 @@ LiveProcess::create(LiveProcessParams * params)
{
LiveProcess *process = NULL;
- string executable =
- params->executable == "" ? params->cmd[0] : params->executable;
- ObjectFile *objFile = createObjectFile(executable);
+ // If not specified, set the executable parameter equal to the
+ // simulated system's zeroth command line parameter
+ if (params->executable == "") {
+ params->executable = params->cmd[0];
+ }
+
+ ObjectFile *objFile = createObjectFile(params->executable);
if (objFile == NULL) {
- fatal("Can't load object file %s", executable);
+ fatal("Can't load object file %s", params->executable);
}
if (objFile->isDynamic())