From b23d4f7c5bf017e88771d5a35cf16909e2ae17c9 Mon Sep 17 00:00:00 2001 From: Matheus Date: Thu, 22 Sep 2022 14:52:39 -0300 Subject: [PATCH] mlibc port: libc logs go to stderr now --- patches/mlibc/sysdeps.patch | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/patches/mlibc/sysdeps.patch b/patches/mlibc/sysdeps.patch index b767cf4a..43ad9b9d 100644 --- a/patches/mlibc/sysdeps.patch +++ b/patches/mlibc/sysdeps.patch @@ -1,6 +1,6 @@ diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/crt-x86_64/crt0.S mlibc/sysdeps/astral/crt-x86_64/crt0.S --- mlibc-3.0.0-rc1/sysdeps/astral/crt-x86_64/crt0.S 1969-12-31 21:00:00.000000000 -0300 -+++ mlibc/sysdeps/astral/crt-x86_64/crt0.S 2022-09-21 18:37:56.035233535 -0300 ++++ mlibc/sysdeps/astral/crt-x86_64/crt0.S 2022-09-22 14:41:12.779845943 -0300 @@ -0,0 +1,7 @@ + +.section .text @@ -11,7 +11,7 @@ diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/crt-x86_64/crt0.S mlib + diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/generic/astral.cpp mlibc/sysdeps/astral/generic/astral.cpp --- mlibc-3.0.0-rc1/sysdeps/astral/generic/astral.cpp 1969-12-31 21:00:00.000000000 -0300 -+++ mlibc/sysdeps/astral/generic/astral.cpp 2022-09-21 18:37:56.035233535 -0300 ++++ mlibc/sysdeps/astral/generic/astral.cpp 2022-09-22 14:41:12.779845943 -0300 @@ -0,0 +1,6 @@ +#include + @@ -21,7 +21,7 @@ diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/generic/astral.cpp mli +} diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/generic/entry.cpp mlibc/sysdeps/astral/generic/entry.cpp --- mlibc-3.0.0-rc1/sysdeps/astral/generic/entry.cpp 1969-12-31 21:00:00.000000000 -0300 -+++ mlibc/sysdeps/astral/generic/entry.cpp 2022-09-21 18:37:56.035233535 -0300 ++++ mlibc/sysdeps/astral/generic/entry.cpp 2022-09-22 14:41:12.779845943 -0300 @@ -0,0 +1,34 @@ + +#include @@ -59,14 +59,15 @@ diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/generic/entry.cpp mlib + diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/generic/generic.cpp mlibc/sysdeps/astral/generic/generic.cpp --- mlibc-3.0.0-rc1/sysdeps/astral/generic/generic.cpp 1969-12-31 21:00:00.000000000 -0300 -+++ mlibc/sysdeps/astral/generic/generic.cpp 2022-09-21 19:25:33.425106934 -0300 -@@ -0,0 +1,184 @@ ++++ mlibc/sysdeps/astral/generic/generic.cpp 2022-09-22 14:48:18.236509081 -0300 +@@ -0,0 +1,189 @@ +#include +#include +#include +#include +#include +#include ++#include + +#define STUB_ONLY { __ensure(!"STUB_ONLY function was called"); __builtin_unreachable(); } + @@ -163,8 +164,12 @@ diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/generic/generic.cpp ml + } + + void sys_libc_log(const char *message){ ++ size_t len = strlen(message); ++ char str[len+1]; ++ memcpy(str, message, len); ++ str[len] = '\n'; + long ret; -+ syscall(SYSCALL_LIBC_LOG, &ret, (uint64_t)message); ++ sys_write(2, str, len+1, &ret); + } + + [[noreturn]] void sys_libc_panic(){ @@ -247,7 +252,7 @@ diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/generic/generic.cpp ml + diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/include/astral/archctl.h mlibc/sysdeps/astral/include/astral/archctl.h --- mlibc-3.0.0-rc1/sysdeps/astral/include/astral/archctl.h 1969-12-31 21:00:00.000000000 -0300 -+++ mlibc/sysdeps/astral/include/astral/archctl.h 2022-09-21 18:37:56.035233535 -0300 ++++ mlibc/sysdeps/astral/include/astral/archctl.h 2022-09-22 14:41:12.779845943 -0300 @@ -0,0 +1,11 @@ +#ifndef _ASTRAL_SYSCALL_ARCHCTL_INCLUDE +#define _ASTRAL_SYSCALL_ARCHCTL_INCLUDE @@ -262,7 +267,7 @@ diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/include/astral/archctl +#endif diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/include/astral/syscall.h mlibc/sysdeps/astral/include/astral/syscall.h --- mlibc-3.0.0-rc1/sysdeps/astral/include/astral/syscall.h 1969-12-31 21:00:00.000000000 -0300 -+++ mlibc/sysdeps/astral/include/astral/syscall.h 2022-09-21 18:37:56.035233535 -0300 ++++ mlibc/sysdeps/astral/include/astral/syscall.h 2022-09-22 14:41:12.779845943 -0300 @@ -0,0 +1,41 @@ +#ifndef _SYSCALL_H_INCLUDE +#define _SYSCALL_H_INCLUDE @@ -307,7 +312,7 @@ diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/include/astral/syscall +#endif diff -ruN --no-dereference mlibc-3.0.0-rc1/sysdeps/astral/meson.build mlibc/sysdeps/astral/meson.build --- mlibc-3.0.0-rc1/sysdeps/astral/meson.build 1969-12-31 21:00:00.000000000 -0300 -+++ mlibc/sysdeps/astral/meson.build 2022-09-21 18:37:56.035233535 -0300 ++++ mlibc/sysdeps/astral/meson.build 2022-09-22 14:41:12.779845943 -0300 @@ -0,0 +1,63 @@ + +rtdl_sources += files(