/*1* Copyright (c) 2022, Netflix, Inc.2*3* SPDX-License-Identifier: BSD-2-Clause4*/56/*7* MI part of the C startup code. We take a long * pointer (we assume long is8* the same size as a pointer, as the Linux world is wont to do). We get a9* pointer to the stack with the main args on it. We don't bother decoding the10* aux vector, but may need to do so in the future.11*12* The long *p points to:13*14* +--------------------+15* | argc | Small address16* +--------------------+17* | argv[0] | argv18* +--------------------+19* | argv[1] |20* +--------------------+21* ...22* +--------------------+23* | NULL | &argv[argc]24* +--------------------+25* | envp[0] | envp26* +--------------------+27* | envp[1] |28* +--------------------+29* ...30* +--------------------+31* | NULL |32* +--------------------+33* | aux type | AT_xxxx34* +--------------------+35* | aux value |36* +--------------------+37* | aux type | AT_xxxx38* +--------------------+39* | aux value |40* +--------------------+41* | aux type | AT_xxxx42* +--------------------+43* | aux value |44* +--------------------+45*...46* +--------------------+47* | NULL |48* +--------------------+49*50* The AUX vector contains additional information for the process to know from51* the kernel (not parsed currently). AT_xxxx constants are small (< 50).52*/5354extern void _start_c(long *);55extern int main(int, const char **, char **);5657#include "start_arch.h"5859void *stack_upper_limit;6061void62_start_c(long *p)63{64int argc;65const char **argv;66char **envp;6768stack_upper_limit = p; /* Save the upper limit of call stack */69argc = p[0];70argv = (const char **)(p + 1);71envp = (char **)argv + argc + 1;7273/* Note: we don't ensure that fd 0, 1, and 2 are sane at this level */74/* Also note: we expect main to exit, not return off the end */75main(argc, argv, envp);76}777879