I would like to how does C++ actually turn the command line arguments into a char array? What “secret” code does this? Where can I view the code that does this (even if it is in assembly, I know some assembly)? I am using Linux, if that helps.
Thank You
It’s an OS job to manage command line arguments and to put it to the stack during process creation.
For POSIX systems the execution path is:
exec()system call, transferring execution path to the userspace and eventually to the entry point of the process (this is usually routine fromcrt0.oobject file, which is linked by default to every executable – this routine callsmain()).For Linux, you can see this code here:
http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/fs/exec.c#L383 :
In the
do_execve()kernel counterpart of userspaceexecve()syscall, at line 1345,copy_strings()‘s are called, andcopy_strings()routine actually does the job you’re asking about.