36 #include "debug/Loader.hh"
38 #include "params/Process.hh"
56 Addr stack_base = 0x7FFFFFFF;
58 Addr max_stack_size = 8 * 1024 * 1024;
61 Addr next_thread_stack_base = stack_base - max_stack_size;
68 Addr mmap_end = brk_point + 0x40000000
L;
70 memState = make_shared<MemState>(
this, brk_point, stack_base,
71 max_stack_size, next_thread_stack_base,
83 template<
class IntType>
87 int intSize =
sizeof(IntType);
101 auxv.emplace_back(
M5_AT_PHDR, elfObject->programHeaderTable());
103 elfObject->programHeaderTable());
105 auxv.emplace_back(
M5_AT_PHENT, elfObject->programHeaderSize());
107 auxv.emplace_back(
M5_AT_PHNUM, elfObject->programHeaderCount());
123 int argv_array_size = intSize * (
argv.size() + 1);
124 int envp_array_size = intSize * (
envp.size() + 1);
125 int auxv_array_size = intSize * 2 * (auxv.size() + 1);
127 int arg_data_size = 0;
129 arg_data_size +=
argv[
i].size() + 1;
132 const int numRandomBytes = 16;
133 int aux_data_size = numRandomBytes;
135 int env_data_size = 0;
137 env_data_size +=
envp[
i].size() + 1;
158 IntType argv_array_base =
memState->getStackMin() + intSize;
159 IntType envp_array_base = argv_array_base + argv_array_size;
160 IntType auxv_array_base = envp_array_base + envp_array_size;
161 IntType arg_data_base = auxv_array_base + auxv_array_size;
162 IntType aux_data_base = arg_data_base - arg_data_size;
163 IntType env_data_base = aux_data_base + aux_data_size;
166 IntType argc =
argv.size();
168 argc =
htole((IntType)argc);
179 for (
auto &aux: auxv) {
181 aux.val = aux_data_base;
185 Addr auxv_array_end = auxv_array_base;
186 for (
const auto &aux: auxv) {
188 auxv_array_end +=
sizeof(aux);
194 auxv_array_end +=
sizeof(zero);