libk  Check-in [62fd1bfe97]

Overview
Comment:Fix _start to properly find the environment. The arguments and environment are directly on the initial stack, which means that more work is needed to find the start of the environment properly. Also remove the hack in _boot that made it work if there were no arguments, as all of the math is being done in _start now.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 62fd1bfe97dfd2f741f8c43d1c888577661c1913d55113f0f050ba7fe433e7cb
User & Date: glowpelt on 2020-01-05 17:52:15
Other Links: manifest | tags
Context
2020-01-19
04:12
Partially fix shared library build by making sure that data_objects are linked in. This means that internal.ident.o is properly linked in, but internal.ident.o itself still references undefined symbols, so this is only a partial fix. check-in: 0d71b71cc8 user: glowpelt tags: trunk
2020-01-05
17:52
Fix _start to properly find the environment. The arguments and environment are directly on the initial stack, which means that more work is needed to find the start of the environment properly. Also remove the hack in _boot that made it work if there were no arguments, as all of the math is being done in _start now. check-in: 62fd1bfe97 user: glowpelt tags: trunk
2019-11-19
05:34
add freebsd signal numbers check-in: de2d78ff77 user: lexi tags: trunk
Changes

Modified mod/kcore/boot.rt.c from [a8282db34a] to [298efe4468].

     7      7   unsigned long long
     8      8   _boot(unsigned int argc, /* argument count */
     9      9   		const char** argv, /* arguments */
    10     10   		char** envp /* environment */ ) {
    11     11   
    12     12   	_k_internal_binary_name = argv[0];
    13     13   
    14         -	envp ++; /* envp seems to point at a leading null;
    15         -				this is probably a sign of breakage but
    16         -				i don't know what else to do about it for
    17         -				the moment. */
    18         -
    19     14   	char** ep;
    20     15   	/* advance ep until it points at the last element */
    21     16   	for (ep = envp; *ep != 0; ++ep);
    22     17   
    23     18   	/* allocate space for each environment variable */
    24     19   	kvar variables [ep - envp];
    25     20   

Modified mod/kcore/boot.rt.x86.lin.64.s from [a74c88489c] to [78d762a0b4].

    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