Understanding The Linux Kernel says that execve() calls do_execve( ) which in turn
copies the file pathname, command-line arguments, and environment strings into one or more newly allocated page frames. (Eventually, they are assigned to the User Mode address space.)
Am I correct that after execve() terminates with success, the process invokes _start routine of rt0.o?
According to APUE:
When a C program is executed by the kernel—by one of the exec functions, a special start-up routine is called before the main function is called. The executable program file specifies this routine as the starting address for the program; this is set up by the link editor when it is invoked by the C compiler. This start-up routine takes values from the kernel—the command-line arguments and the environment — and sets things up so that the main function is called as shown earlier.
Does the __start routine also copy command line arguments and the environment again?
What are differences between do_execve() and _start both copying the command line arguments and environment? Isn't it wasteful to copy twice?
Thanks.
_start, although compilers love to add such symbol name for it – 炸鱼薯条德里克 Feb 04 '19 at 02:04