201c201
< Addr alignmentMask = ~(sizeof(uint64_t) - 1);
---
> uint64_t align = 16;
266c266
< int mysterious_size = 8;
---
> int sentry_size = 8;
281,286c281,283
< //The info_block - This seems to need an pad for some reason.
< int info_block_size =
< (mysterious_size +
< file_name_size +
< env_data_size +
< arg_data_size + intSize);
---
> //The info_block.
> int base_info_block_size =
> sentry_size + file_name_size + env_data_size + arg_data_size;
287a285,288
> int info_block_size = roundUp(base_info_block_size, align);
>
> int info_block_padding = info_block_size - base_info_block_size;
>
297,298c298,299
< int space_needed =
< info_block_size +
---
> //Figure out the size of the contents of the actual initial frame
> int frame_size =
304a306,315
> //There needs to be padding after the auxiliary vector data so that the
> //very bottom of the stack is aligned properly.
> int aligned_partial_size = roundUp(frame_size, align);
> int aux_padding = aligned_partial_size - frame_size;
>
> int space_needed =
> info_block_size +
> aux_padding +
> frame_size;
>
306c317
< stack_min &= alignmentMask;
---
> stack_min = roundDown(stack_min, align);
314,324c325,336
< IntType window_save_base = stack_min;
< IntType argc_base = window_save_base + window_save_size;
< IntType argv_array_base = argc_base + argc_size;
< IntType envp_array_base = argv_array_base + argv_array_size;
< IntType auxv_array_base = envp_array_base + envp_array_size;
< //The info block is pushed up against the top of the stack, while
< //the rest of the initial stack frame is aligned to an 8 byte boudary.
< IntType arg_data_base = stack_base - info_block_size + intSize;
< IntType env_data_base = arg_data_base + arg_data_size;
< IntType file_name_base = env_data_base + env_data_size;
< IntType mysterious_base = file_name_base + file_name_size;
---
> IntType sentry_base = stack_base - sentry_size;
> IntType file_name_base = sentry_base - file_name_size;
> IntType env_data_base = file_name_base - env_data_size;
> IntType arg_data_base = env_data_base - arg_data_size;
> IntType auxv_array_base = arg_data_base -
> info_block_padding - aux_array_size - aux_padding;
> IntType envp_array_base = auxv_array_base - envp_array_size;
> IntType argv_array_base = envp_array_base - argv_array_size;
> IntType argc_base = argv_array_base - argc_size;
> #if TRACING_ON
> IntType window_save_base = argc_base - window_save_size;
> #endif
326a339,340
> DPRINTF(Sparc, "%#x - sentry NULL\n", sentry_base);
> DPRINTF(Sparc, "filename = %s\n", filename);
336a351,352
> assert(window_save_base == stack_min);
>
343,346c359,362
< //Write out the mysterious 0
< uint64_t mysterious_zero = 0;
< initVirtMem->writeBlob(mysterious_base,
< (uint8_t*)&mysterious_zero, mysterious_size);
---
> //Write out the sentry void *
> uint64_t sentry_NULL = 0;
> initVirtMem->writeBlob(sentry_base,
> (uint8_t*)&sentry_NULL, sentry_size);
362,363c378,381
< initVirtMem->writeBlob(auxv_array_base + 2 * intSize * auxv.size(),
< (uint8_t*)&zero, 2 * intSize);
---
> 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);