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);
17 void _start_c(long *sp)
22 const unsigned long *auxv;
23 /* silence potential warning: conflicting types for 'main' */
24 int _nolibc_main(int, char **, char **) __asm__ ("main");
26 /* initialize stack protector */
30 * sp : argc <-- argument count, required by main()
31 * argv: argv[0] <-- argument vector, required by main()
36 * environ: environ[0] <-- environment variables, required by main() and getenv()
40 * _auxv: _auxv[0] <-- auxiliary vector, required by getauxval()
46 /* assign argc and argv */
48 argv = (void *)(sp + 1);
51 environ = envp = argv + argc + 1;
54 for (auxv = (void *)envp; *auxv++;)
58 /* go to application */
59 exit(_nolibc_main(argc, argv, envp));
62 #endif /* _NOLIBC_CRT_H */