Note that this is a backwards incompatible change: Unlike POSIX, exit()
will not flush all open streams, so you are responsible for flushing or
closing all your streams before successful exit.
Also, file.c will now also require calloc.c (and malloc.c).
Updated the test cases accordingly.
Only implemented and tested for x86.
The close syscall was missing an indirection and therefore closed random
file descriptors (very visible in strace output).
Test 0104 did not properly null terminate the envp, resulting in -EFAULT
on execve syscall in case the next value in memory does not happen to be
0 (which it seems to be right now).
Paraphrasing OriansJ's IRC message while working on kaem:
GCC needs fflush(stdout) to get matching behavior, as M2-Planet doesn't
buffer. I guess we will need to make a fflush function (it'll do nothing
but return 0).
Until now, each element on the compiled program stack was 128 bits long,
half of them unused because only one 64 bits value was stored.
Now it's 64 bits long, so we don't waste all that memory.
We workaround the architectural alignment restriction of the SP register by
using a free regular register. X18 is for platform use so it seems a good
candidate for this task.
At _start we copy the value of SP into X18. SP is not used anymore. When a
definition refers to SP it doesn't mean it literaly now, because here we
redefine (without renaming) the involved M1 macro definitions to operate
on X18 (easier transition; abstraction). INIT_SP is introduced.
The function arguments are passed via stack, so the offset from the Base
Pointer ("depth") to each of them is different now. Changes both to
compiler code (cc_core.c) and libc reflect that the arguments are 8 bytes
(instead of 16 bytes) apart now. Note that SUB_X0_32 and SUB_X0_48 are
removed, because we only need 8, 16 and 24 bytes subtraction to reach the
arguments from asm libc functions. SUB_X0_8 and SUB_X0_24 are introduced.
Thanks to Hagfish for proofreading this documentation.
My deepest thanks to Jeremiah Orians for supporting me during the
development of this patch series. Your wisdom and patience is greatly
appreciated.
Thanks to the rest of the #bootstrappable family.
All errors left are mine.