diff options
Diffstat (limited to 'src/arch/x86/process.cc')
-rw-r--r-- | src/arch/x86/process.cc | 78 |
1 files changed, 35 insertions, 43 deletions
diff --git a/src/arch/x86/process.cc b/src/arch/x86/process.cc index 9e34a7b5d..d01afbc25 100644 --- a/src/arch/x86/process.cc +++ b/src/arch/x86/process.cc @@ -762,8 +762,7 @@ X86Process::argsInit(int pageSize, { int intSize = sizeof(IntType); - typedef AuxVector<IntType> auxv_t; - std::vector<auxv_t> auxv = extraAuxvs; + std::vector<AuxVector<IntType>> auxv = extraAuxvs; string filename; if (argv.size() < 1) @@ -859,40 +858,40 @@ X86Process::argsInit(int pageSize, // Bits which describe the system hardware capabilities // XXX Figure out what these should be - auxv.push_back(auxv_t(M5_AT_HWCAP, features)); + auxv.emplace_back(M5_AT_HWCAP, features); // The system page size - auxv.push_back(auxv_t(M5_AT_PAGESZ, X86ISA::PageBytes)); + auxv.emplace_back(M5_AT_PAGESZ, X86ISA::PageBytes); // Frequency at which times() increments // Defined to be 100 in the kernel source. - auxv.push_back(auxv_t(M5_AT_CLKTCK, 100)); + auxv.emplace_back(M5_AT_CLKTCK, 100); // 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_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()); // XXX Figure out what this should be. - 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); // The address of 16 "random" bytes. - auxv.push_back(auxv_t(M5_AT_RANDOM, 0)); + auxv.emplace_back(M5_AT_RANDOM, 0); // The name of the program - auxv.push_back(auxv_t(M5_AT_EXECFN, 0)); + auxv.emplace_back(M5_AT_EXECFN, 0); // The platform string - auxv.push_back(auxv_t(M5_AT_PLATFORM, 0)); + auxv.emplace_back(M5_AT_PLATFORM, 0); } // Figure out how big the initial stack needs to be @@ -1006,29 +1005,24 @@ X86Process::argsInit(int pageSize, initVirtMem.writeString(file_name_base, filename.c_str()); // Fix up the aux vectors which point to data - assert(auxv[auxv.size() - 3].getHostAuxType() == M5_AT_RANDOM); - auxv[auxv.size() - 3].setAuxVal(aux_data_base); - assert(auxv[auxv.size() - 2].getHostAuxType() == M5_AT_EXECFN); - auxv[auxv.size() - 2].setAuxVal(argv_array_base); - assert(auxv[auxv.size() - 1].getHostAuxType() == M5_AT_PLATFORM); - auxv[auxv.size() - 1].setAuxVal(aux_data_base + numRandomBytes); + assert(auxv[auxv.size() - 3].type == M5_AT_RANDOM); + auxv[auxv.size() - 3].val = aux_data_base; + assert(auxv[auxv.size() - 2].type == M5_AT_EXECFN); + auxv[auxv.size() - 2].val = argv_array_base; + assert(auxv[auxv.size() - 1].type == M5_AT_PLATFORM); + auxv[auxv.size() - 1].val = aux_data_base + numRandomBytes; // 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 auxiliary vector - const uint64_t zero = 0; - initVirtMem.writeBlob(auxv_array_base + auxv.size() * 2 * intSize, - (uint8_t*)&zero, intSize); - initVirtMem.writeBlob(auxv_array_base + (auxv.size() * 2 + 1) * intSize, - (uint8_t*)&zero, intSize); + const AuxVector<uint64_t> zero(0, 0); + initVirtMem.write(auxv_array_end, zero); + auxv_array_end += sizeof(zero); initVirtMem.writeString(aux_data_base, platform.c_str()); @@ -1053,8 +1047,7 @@ void X86_64Process::argsInit(int pageSize) { std::vector<AuxVector<uint64_t> > extraAuxvs; - extraAuxvs.push_back(AuxVector<uint64_t>(M5_AT_SYSINFO_EHDR, - vsyscallPage.base)); + extraAuxvs.emplace_back(M5_AT_SYSINFO_EHDR, vsyscallPage.base); X86Process::argsInit<uint64_t>(pageSize, extraAuxvs); } @@ -1063,10 +1056,9 @@ I386Process::argsInit(int pageSize) { std::vector<AuxVector<uint32_t> > extraAuxvs; //Tell the binary where the vsyscall part of the vsyscall page is. - extraAuxvs.push_back(AuxVector<uint32_t>(M5_AT_SYSINFO, - vsyscallPage.base + vsyscallPage.vsyscallOffset)); - extraAuxvs.push_back(AuxVector<uint32_t>(M5_AT_SYSINFO_EHDR, - vsyscallPage.base)); + extraAuxvs.emplace_back(M5_AT_SYSINFO, + vsyscallPage.base + vsyscallPage.vsyscallOffset); + extraAuxvs.emplace_back(M5_AT_SYSINFO_EHDR, vsyscallPage.base); X86Process::argsInit<uint32_t>(pageSize, extraAuxvs); } |