Flash 29 lines
// start — flibc's `_start` argc/argv shim, ported to Flash from the hand-written
// Zig. It is the default ELF entry point for flibc-linked programs that take
// command-line arguments: the kernel's execve path lays an argv block on the
// new user stack and erets to the entry with `x0 = argc`, `x1 = argv` per
// AAPCS64, and this shim trampolines into the program's `main(argc, argv)`.
//
// Declaring argc/argv as parameters makes the compiler treat x0/x1 as live-in
// arguments, so the standard prologue never clobbers them before they are
// forwarded — no naked register read is needed. `main` is `noreturn` (flibc
// programs exit explicitly, never by returning), so the shim carries no
// fallback path. A program opts in by importing this module and forcing the
// shim's emission with the comptime `#export`; a program with a bespoke
// `_start` simply does not, and keeps its own entry.
//
// New grammar this port needs: a bodyless `extern fn` prototype, an explicit
// `callconv(.c)` in the signature, and a top-level `comptime { … }` block. The
// `argv` spelling lowers to the argv pointer type `[*]const ?[*:0]const u8`;
// the `//` header is dropped, as Flash carries only `///` doc comments.
extern fn main(argc usize, argv argv) callconv(.c) noreturn
fn _start_shim(argc usize, argv argv) callconv(.c) noreturn {
main(argc, argv)
}
comptime {
#export(&_start_shim, .{ .name = "_start", .linkage = .strong })
}