summaryrefslogtreecommitdiff
path: root/src/arch/x86/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/arch/x86/process.cc
parent4fc69db8f89049a881a5f4aa68545840818b124c (diff)
downloadgem5-9b4249410ec18cac9df2c7e9c0a4a6ce5459233d.tar.xz
base: support dynamic loading of Linux ELF objects in SE mode
Diffstat (limited to 'src/arch/x86/process.cc')
-rw-r--r--src/arch/x86/process.cc24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/arch/x86/process.cc b/src/arch/x86/process.cc
index d2ce4dbd1..66a520bc3 100644
--- a/src/arch/x86/process.cc
+++ b/src/arch/x86/process.cc
@@ -756,6 +756,9 @@ X86LiveProcess::argsInit(int pageSize,
//We want 16 byte alignment
uint64_t align = 16;
+ // Patch the ld_bias for dynamic executables.
+ updateBias();
+
// load object file into target memory
objFile->loadSections(initVirtMem);
@@ -798,8 +801,10 @@ X86LiveProcess::argsInit(int pageSize,
X86_IA64Processor = 1 << 30
};
- // Setup the auxilliary vectors. These will already have endian conversion.
- // Auxilliary vectors are loaded only for elf formatted executables.
+ // Setup the auxiliary vectors. These will already have endian
+ // conversion. Auxiliary vectors are loaded only for elf formatted
+ // executables; the auxv is responsible for passing information from
+ // the OS to the interpreter.
ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile);
if (elfObject) {
uint64_t features =
@@ -842,18 +847,17 @@ X86LiveProcess::argsInit(int pageSize,
//Frequency at which times() increments
//Defined to be 100 in the kernel source.
auxv.push_back(auxv_t(M5_AT_CLKTCK, 100));
- // For statically linked executables, this is the virtual address of the
- // program header tables if they appear in the executable image
+ // This is the virtual address of the program header tables if they
+ // appear in the executable image.
auxv.push_back(auxv_t(M5_AT_PHDR, elfObject->programHeaderTable()));
// This is the size of a program header entry from the elf file.
auxv.push_back(auxv_t(M5_AT_PHENT, elfObject->programHeaderSize()));
// This is the number of program headers from the original elf file.
auxv.push_back(auxv_t(M5_AT_PHNUM, elfObject->programHeaderCount()));
- //This is the address of the elf "interpreter", It should be set
- //to 0 for regular executables. It should be something else
- //(not sure what) for dynamic libraries.
- auxv.push_back(auxv_t(M5_AT_BASE, 0));
-
+ // This is the base address of the ELF interpreter; it should be
+ // zero for static executables or contain the base address for
+ // dynamic executables.
+ auxv.push_back(auxv_t(M5_AT_BASE, getBias()));
//XXX Figure out what this should be.
auxv.push_back(auxv_t(M5_AT_FLAGS, 0));
//The entry point to the program
@@ -1014,7 +1018,7 @@ X86LiveProcess::argsInit(int pageSize,
// There doesn't need to be any segment base added in since we're dealing
// with the flat segmentation model.
- tc->pcState(objFile->entryPoint());
+ tc->pcState(getStartPC());
//Align the "stack_min" to a page boundary.
stack_min = roundDown(stack_min, pageSize);