pub fn calculate_initial_linker_stack_size(
    msg_contents: &mut MessageContents,
    extra_handles: usize
) -> Result<usize, ProcessBuilderError>
Expand description

Calculate the size of the initial stack to allocate for the dynamic linker, based on the given process_args message contents.

The initial stack is used just for startup work in the dynamic linker and to hold the bootstrap message, so we only attempt to make it only as big as needed. The size returned is based on the stack space needed to read the bootstrap message with zx_channel_read, and thus includes the message data itself plus the size of the handles (i.e. the size of N zx_handle_t’s).

This also allows the caller to specify an number of “extra handles” to factor into the size calculation. This allows the size to be calculated before all the real handles have been added to the contents, for example if the size is needed to create those handles.