66 Addr stack_base = 0xbf000000L;
68 Addr max_stack_size = 8 * 1024 * 1024;
71 Addr next_thread_stack_base = stack_base - max_stack_size;
74 Addr mmap_end = 0x70000000L;
76 memState = std::make_shared<MemState>(
77 this, brk_point, stack_base, max_stack_size,
78 next_thread_stack_base, mmap_end);
141 int intSize =
sizeof(IntType);
144 bool isLittleEndian = (
byteOrder == ByteOrder::little);
147 std::string filename;
214 int sentry_size = intSize;
216 std::string platform =
"v51";
217 int platform_size = platform.size() + 1;
223 int aux_data_size = filename.size() + 1;
225 const int numRandomBytes = 16;
226 aux_data_size += numRandomBytes;
228 int env_data_size = 0;
229 for (
int i = 0;
i <
envp.size(); ++
i) {
230 env_data_size +=
envp[
i].size() + 1;
232 int arg_data_size = 0;
233 for (
int i = 0;
i <
argv.size(); ++
i) {
234 arg_data_size +=
argv[
i].size() + 1;
237 int info_block_size =
238 sentry_size + env_data_size + arg_data_size +
239 aux_data_size + platform_size;
242 int aux_array_size = intSize * 2 * (auxv.size() + 1);
244 int envp_array_size = intSize * (
envp.size() + 1);
245 int argv_array_size = intSize * (
argv.size() + 1);
247 int argc_size = intSize;
259 int partial_size = frame_size;
260 int aligned_partial_size =
roundUp(partial_size, align);
261 int aux_padding = aligned_partial_size - partial_size;
263 int space_needed = frame_size + aux_padding;
265 Addr stack_min =
memState->getStackBase() - space_needed;
275 IntType sentry_base =
memState->getStackBase() - sentry_size;
276 IntType aux_data_base = sentry_base - aux_data_size;
277 IntType env_data_base = aux_data_base - env_data_size;
278 IntType arg_data_base = env_data_base - arg_data_size;
279 IntType platform_base = arg_data_base - platform_size;
280 IntType auxv_array_base = platform_base - aux_array_size - aux_padding;
281 IntType envp_array_base = auxv_array_base - envp_array_size;
282 IntType argv_array_base = envp_array_base - argv_array_size;
283 IntType argc_base = argv_array_base - argc_size;
285 DPRINTF(Stack,
"The addresses of items on the initial stack:\n");
286 DPRINTF(Stack,
"0x%x - aux data\n", aux_data_base);
287 DPRINTF(Stack,
"0x%x - env data\n", env_data_base);
288 DPRINTF(Stack,
"0x%x - arg data\n", arg_data_base);
289 DPRINTF(Stack,
"0x%x - platform base\n", platform_base);
290 DPRINTF(Stack,
"0x%x - auxv array\n", auxv_array_base);
291 DPRINTF(Stack,
"0x%x - envp array\n", envp_array_base);
292 DPRINTF(Stack,
"0x%x - argv array\n", argv_array_base);
293 DPRINTF(Stack,
"0x%x - argc \n", argc_base);
294 DPRINTF(Stack,
"0x%x - stack min\n", stack_min);
299 IntType argc =
argv.size();
303 IntType sentry_NULL = 0;
304 initVirtMem->writeBlob(sentry_base, &sentry_NULL, sentry_size);
307 for (
int i = auxv.size() - 1;
i >= 0;
i--) {
309 auxv[
i].val = platform_base;
310 initVirtMem->writeString(platform_base, platform.c_str());
312 auxv[
i].val = aux_data_base + numRandomBytes;
313 initVirtMem->writeString(aux_data_base, filename.c_str());
315 auxv[
i].val = aux_data_base;
320 Addr auxv_array_end = auxv_array_base;
321 for (
const auto &aux: auxv) {
323 auxv_array_end +=
sizeof(aux);
328 auxv_array_end +=
sizeof(zero);
335 initVirtMem->writeBlob(argc_base, &guestArgc, intSize);
356 msr.le = isLittleEndian;
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void setReg(const RegId ®, RegVal val)
virtual const PCStateBase & pcState() const =0
Declarations of a non-full system Page Table.