/* hello-musl: the first Foundry OS C program (milestone M2), plain C on musl. * * Built by `make` with toolchain/foundry-cc, i.e. gcc + our musl as a * static-PIE (see docs/porting.md), and installed as /bin/hello-musl. * On Rustbelt it prints "hello from musl on Rustbelt 0.20.0 (...)"; the * same binary also runs on a Linux PC ("hello from musl on Linux 6.x"). */ #include #include #include extern const char __ehdr_start[]; /* our own ELF header, wherever we were loaded */ int main(void) { const Elf64_Ehdr *me = (const void *)__ehdr_start; const char *kind = me->e_type == ET_DYN ? "static-PIE" : "ET_EXEC"; struct utsname u; if (uname(&u) == 0) printf("hello from musl on %s %s (Foundry OS, %s)\n", u.sysname, u.release, kind); else printf("hello from musl (Foundry OS, %s)\n", kind); return 0; }