1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 3 * Copyright (c) 2016 The University of Virginia 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 74 unchanged lines hidden (view full) --- 83{ 84 updateBias(); 85 objFile->loadSections(initVirtMem); 86 ElfObject* elfObject = dynamic_cast<ElfObject*>(objFile); 87 memState->setStackMin(memState->getStackBase()); 88 89 // Determine stack size and populate auxv 90 Addr stack_top = memState->getStackMin(); |
91 stack_top -= elfObject->programHeaderSize(); |
92 for (const string& arg: argv) 93 stack_top -= arg.size() + 1; 94 for (const string& env: envp) 95 stack_top -= env.size() + 1; 96 stack_top &= -sizeof(Addr); 97 98 vector<AuxVector<IntType>> auxv; 99 if (elfObject != nullptr) { --- 9 unchanged lines hidden (view full) --- 109 stack_top -= (1 + argv.size()) * sizeof(Addr) + 110 (1 + envp.size()) * sizeof(Addr) + 111 sizeof(Addr) + 2 * sizeof(IntType) * auxv.size(); 112 stack_top &= -2*sizeof(Addr); 113 memState->setStackSize(memState->getStackBase() - stack_top); 114 allocateMem(roundDown(stack_top, pageSize), 115 roundUp(memState->getStackSize(), pageSize)); 116 |
117 // Copy program headers to stack 118 memState->setStackMin(memState->getStackMin() - 119 elfObject->programHeaderSize()); 120 uint8_t* phdr = new uint8_t[elfObject->programHeaderSize()]; 121 initVirtMem.readBlob(elfObject->programHeaderTable(), phdr, 122 elfObject->programHeaderSize()); 123 initVirtMem.writeBlob(memState->getStackMin(), phdr, 124 elfObject->programHeaderSize()); 125 delete phdr; 126 |
127 // Copy argv to stack 128 vector<Addr> argPointers; 129 for (const string& arg: argv) { 130 memState->setStackMin(memState->getStackMin() - (arg.size() + 1)); 131 initVirtMem.writeString(memState->getStackMin(), arg.c_str()); 132 argPointers.push_back(memState->getStackMin()); 133 if (DTRACE(Stack)) { 134 string wrote; --- 108 unchanged lines hidden --- |