Differences From
Artifact [a74c88489c]:
19 19 mov edi, [rsp + 0] ; sizeof arguments
20 20 ; first argument to _boot(): argc
21 21 ; this is a 32-bit signed(??) integer
22 22 ; that is equal to the number of
23 23 ; elements in argv (see below). it is
24 24 ; not strictly necessary, because argv
25 25 ; is per spec always null-terminated,
26 - ; but we pass it just in case.
26 + ; but we pass it just in case. it is
27 + ; also used for finding the environment
28 + ; below.
27 29
28 30 lea rsi, [rsp + 8] ; &arguments
29 31 ; 2nd argument to _boot(): ptr to argv
30 32 ; this points to an array of strings
31 33 ; containing the program's command line
32 34 ; arguments. _boot() does not need to
33 35 ; parse this, but it does need to store
34 36 ; it in the structure passed to main()
37 + ; this exists on the stack, right above
38 + ; argc
35 39
36 - lea rdx, [rsp + 16] ; &environment
40 + lea rdx, [rsp + rdi * 8 + 16] ; &environment
37 41 ; third argument to _boot(): ptr to envp
38 42 ; this points to the list of environment
39 43 ; variables for the running program. it
40 44 ; is the responsibility of _boot to parse
41 45 ; this list and arrange it into a set of
42 - ; legible and useful C arrays.
46 + ; legible and useful C arrays. it exists
47 + ; above the argument list, the math is
48 + ; stack pointer + argc*pointers(8 bytes)
49 + ; + 16 bytes (argc itself and the
50 + ; terminating null from argv)
43 51
44 52 mov rax, 0 ; zero out %rax
45 53 ; this is required by the C ABI, and is
46 54 ; reputedly necessary for compatibility
47 55 ; with icc, intel's own proprietary C
48 56 ; compiler.
49 57