user: implement mlibc as the libc, finally.

It's finally done..

Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
kaguya
2026-05-02 03:31:49 -04:00
parent 2fa39ad85a
commit 9a9b91c940
2387 changed files with 152741 additions and 315 deletions
@@ -0,0 +1,31 @@
#include <stdint.h>
#include <string.h>
#include <mlibc/debug.hpp>
#include <mlibc/stack_protector.hpp>
uintptr_t __stack_chk_guard = 0;
namespace mlibc {
void initStackGuard(void *entropy) {
if(entropy != nullptr) {
memcpy(&__stack_chk_guard, entropy, sizeof(__stack_chk_guard));
} else {
// If no entropy is available, set it to the terminator canary
__stack_chk_guard = 0;
__stack_chk_guard |= ('\n' << 16);
__stack_chk_guard |= (255 << 24);
}
}
} // namespace mlibc
extern "C" [[noreturn]] void __stack_chk_fail() {
mlibc::panicLogger() << "Stack smashing detected!" << frg::endlog;
__builtin_unreachable();
}
extern "C" [[noreturn, gnu::visibility("hidden")]] void __stack_chk_fail_local() {
__stack_chk_fail();
};