1 /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
3 * C Run Time support for NOLIBC
4 * Copyright (C) 2023 Zhangjin Wu <falcon@tinylab.org>
10 char **environ __attribute__((weak));
11 const unsigned long *_auxv __attribute__((weak));
13 static void __stack_chk_init(void);
14 static void exit(int);
16 void _start_c(long *sp)
21 const unsigned long *auxv;
22 /* silence potential warning: conflicting types for 'main' */
23 int _nolibc_main(int, char **, char **) __asm__ ("main");
25 /* initialize stack protector */
29 * sp : argc <-- argument count, required by main()
30 * argv: argv[0] <-- argument vector, required by main()
35 * environ: environ[0] <-- environment variables, required by main() and getenv()
39 * _auxv: _auxv[0] <-- auxiliary vector, required by getauxval()
45 /* assign argc and argv */
47 argv = (void *)(sp + 1);
50 environ = envp = argv + argc + 1;
53 for (auxv = (void *)envp; *auxv++;)
57 /* go to application */
58 exit(_nolibc_main(argc, argv, envp));
61 #endif /* _NOLIBC_CRT_H */