summaryrefslogtreecommitdiff
path: root/src/arch/sparc
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/sparc')
-rw-r--r--src/arch/sparc/process.cc53
1 files changed, 24 insertions, 29 deletions
diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc
index 6659a04fa..3419e0970 100644
--- a/src/arch/sparc/process.cc
+++ b/src/arch/sparc/process.cc
@@ -192,9 +192,7 @@ SparcProcess::argsInit(int pageSize)
{
int intSize = sizeof(IntType);
- typedef AuxVector<IntType> auxv_t;
-
- std::vector<auxv_t> auxv;
+ std::vector<AuxVector<IntType>> auxv;
string filename;
if (argv.size() < 1)
@@ -238,34 +236,34 @@ SparcProcess::argsInit(int pageSize)
ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile);
if (elfObject) {
// Bits which describe the system hardware capabilities
- auxv.push_back(auxv_t(M5_AT_HWCAP, hwcap));
+ auxv.emplace_back(M5_AT_HWCAP, hwcap);
// The system page size
- auxv.push_back(auxv_t(M5_AT_PAGESZ, SparcISA::PageBytes));
+ auxv.emplace_back(M5_AT_PAGESZ, SparcISA::PageBytes);
// Defined to be 100 in the kernel source.
// Frequency at which times() increments
- 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
- auxv.push_back(auxv_t(M5_AT_PHDR, elfObject->programHeaderTable()));
+ auxv.emplace_back(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
+ auxv.emplace_back(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()));
+ auxv.emplace_back(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()));
+ auxv.emplace_back(M5_AT_PHNUM, elfObject->programHeaderCount());
// 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()));
+ auxv.emplace_back(M5_AT_BASE, getBias());
// This is hardwired to 0 in the elf loading code in the kernel
- auxv.push_back(auxv_t(M5_AT_FLAGS, 0));
+ auxv.emplace_back(M5_AT_FLAGS, 0);
// The entry point to the program
- auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint()));
+ auxv.emplace_back(M5_AT_ENTRY, objFile->entryPoint());
// Different user and group IDs
- auxv.push_back(auxv_t(M5_AT_UID, uid()));
- auxv.push_back(auxv_t(M5_AT_EUID, euid()));
- auxv.push_back(auxv_t(M5_AT_GID, gid()));
- auxv.push_back(auxv_t(M5_AT_EGID, egid()));
+ auxv.emplace_back(M5_AT_UID, uid());
+ auxv.emplace_back(M5_AT_EUID, euid());
+ auxv.emplace_back(M5_AT_GID, gid());
+ auxv.emplace_back(M5_AT_EGID, egid());
// Whether to enable "secure mode" in the executable
- auxv.push_back(auxv_t(M5_AT_SECURE, 0));
+ auxv.emplace_back(M5_AT_SECURE, 0);
}
// Figure out how big the initial stack needs to be
@@ -373,19 +371,16 @@ SparcProcess::argsInit(int pageSize)
initVirtMem.writeString(file_name_base, filename.c_str());
// Copy the aux stuff
- for (int x = 0; x < auxv.size(); x++) {
- initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize,
- (uint8_t*)&(auxv[x].getAuxType()), intSize);
- initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize,
- (uint8_t*)&(auxv[x].getAuxVal()), intSize);
+ Addr auxv_array_end = auxv_array_base;
+ for (const auto &aux: auxv) {
+ initVirtMem.write(auxv_array_end, aux, GuestByteOrder);
+ auxv_array_end += sizeof(aux);
}
// Write out the terminating zeroed auxilliary vector
- const IntType zero = 0;
- initVirtMem.writeBlob(auxv_array_base + intSize * 2 * auxv.size(),
- (uint8_t*)&zero, intSize);
- initVirtMem.writeBlob(auxv_array_base + intSize * (2 * auxv.size() + 1),
- (uint8_t*)&zero, intSize);
+ const AuxVector<IntType> zero(0, 0);
+ initVirtMem.write(auxv_array_end, zero);
+ auxv_array_end += sizeof(zero);
copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);