Re: [PATCH v3 02/11] tools/nolibc: add new crt.h with _start_c

From: Zhangjin Wu
Date: Thu Jul 13 2023 - 02:23:44 EST


Hi, Thomas

> > On 2023-07-12 17:17:39+0800, Zhangjin Wu wrote:
> [...]
> > > +static void exit(int);
> > > +
> > > +void _start_c(long *sp)
> > > +{
> > > + int argc, i;
> > > + char **argv;
> > > + char **envp;
> > > + /* silence potential warning: conflicting types for 'main' */
> > > + _nolibc_main_fn _nolibc_main __asm__ ("main");
> >
> > What about the stackprotector initialization?
> > It would really fit great into this series.
> >
>
> Ok, which gcc version supports stackprotector? seems the test even skip
> on gcc 10, I will find one to verify the code change.
>

Thomas, please ignore this question, I forgot some options in my own script.

Best regards,
Zhangjin

> > > +
> > > + /*
> > > + * sp : argc <-- argument count, required by main()
> > > + * argv: argv[0] <-- argument vector, required by main()
> > > + * argv[1]
> > > + * ...
> > > + * argv[argc-1]
> > > + * null
> > > + * envp: envp[0] <-- environment variables, required by main() and getenv()
> > > + * envp[1]
> > > + * ...
> > > + * null
> > > + * _auxv: auxv[0] <-- auxiliary vector, required by getauxval()
> > > + * auxv[1]
> > > + * ...
> > > + * null
> > > + */
> > > +
> > > + /* assign argc and argv */
> > > + argc = sp[0];
> > > + argv = (void *)(sp + 1);
> >
> > Bit of a weird mismatch between array syntax and pointer arithmetic.
> >