Removes the "-unix" element and with it any trademark exposure to The
Open Group.
The split follows the ecosystem layout: SchOS is the system, and the
kernel has its own name. Kernel-identity strings are the only places
that take SchIFT -- uname(2) sysname, /proc/version, and the two licence
sentences that say "kernel" outright. That is what every Unix does here:
`uname -s` on Linux reports the kernel, not the distribution. Everything
a user reads as the product -- panic screen, boot menu, error prefixes,
docs, LICENSE, NOTICE -- is SchOS.
schunix.img is schos.img, the logo assets and the musl TLS patch are
renamed, and __SCHUNIX__ is __SCHOS__ (the define and the patch that
consumes it moved together).
Two things the rename broke, both found by the bootcheck suite:
- shmtest wrote "SCHUNIX-MMAP-OK" with a hardcoded length of 15 and
compared it back by hand-counted offsets (m[3]=='U', m[14]=='K').
The shorter marker left the write running two bytes past the literal
and the compare reading past the data, failing a file-backed mmap
that was working correctly. Now written and compared through one
constant with sizeof.
- bootcheck asserted a 31-byte file after appending to
"hello-from-schunix"; the shorter string makes it 29.
Both are the same mistake: a string literal whose length is written out
somewhere else. Full suite green -- base, Tty, Ps, Sock, Fb, Usb, Evdev.
44 lines
1.8 KiB
ArmAsm
44 lines
1.8 KiB
ArmAsm
/* SPDX-License-Identifier: Apache-2.0
|
|
* SchOS — process entry point.
|
|
*
|
|
* This has to be assembly, and the reason is worth recording.
|
|
*
|
|
* exec() hands a new process its arguments in registers, not on the stack:
|
|
* kernel/fs/exec.c sets proc->tf->rdi = argc and proc->tf->rsi = argv. Those
|
|
* are already the first two SysV argument registers, so _start's entire job
|
|
* is to call main and then exit — it must not touch %rdi or %rsi at all.
|
|
*
|
|
* It used to be written in C, capturing the incoming registers with GCC's
|
|
*
|
|
* register int argc_reg asm("rdi");
|
|
*
|
|
* That is not what local register variables mean. Both GCC and clang only
|
|
* guarantee the binding when the variable is used as an operand of an inline
|
|
* asm statement; reading one to pick up an incoming argument is undefined.
|
|
* GCC happened to do the useful thing. clang compiled it to
|
|
*
|
|
* movl -0x4(%rbp), %eax # two uninitialised stack slots
|
|
* movq -0x10(%rbp), %rax
|
|
*
|
|
* and every program was handed a garbage argc and argv. Nothing crashed --
|
|
* init, shmtest and socktest take no arguments and passed their whole test
|
|
* suites -- so the only symptom was `inputtest -n 6` quietly ignoring its
|
|
* limit. A compiler-dependent way to read registers has no business being in
|
|
* C when four instructions of assembly are exactly right.
|
|
*/
|
|
|
|
.text
|
|
.globl _start
|
|
_start:
|
|
xorq %rbp, %rbp /* end the frame-pointer chain here */
|
|
|
|
/* SysV wants %rsp 16-byte aligned immediately before a call, so that the
|
|
* callee sees %rsp+8 aligned once the return address is pushed. Rounding
|
|
* down is safe: argc and argv arrive in registers, so nothing below is
|
|
* needed. */
|
|
andq $-16, %rsp
|
|
|
|
callq main /* main(%rdi = argc, %rsi = argv) */
|
|
callq exit /* exit() is noreturn, but be certain */
|
|
1: hlt
|
|
jmp 1b
|