Page 1 of 1

Trouble porting newlib to my kernel (Syscalls are not being implemented?)

Posted: Thu Nov 13, 2025 10:39 pm
by atomtables
Hi. I'm able to build newlib including my syscalls, but when I go to compile a test program, the syscalls seem to be missing and not implemented. This is perplexing, since the syscalls.c file seems to be linked but the syscalls are considered missing.

The port of newlib is on this github: https://github.com/atomtables/newlib_astatine

This is the simple test program

Code: Select all

#include <stdio.h>

void main() {
    printf("Hello, World!\n");
    while(1);
}
And this is the output

Code: Select all

i686-astatine-gcc main.c -lc -lg -lm -lnosys
...i686-astatine/bin/ld: ...astatine/sysroot/usr/lib/libc.a(libc_a-closer.o): in function `_close_r':
...newlib-cygwin/build/i686-astatine/newlib/../../../newlib/libc/reent/closer.c:47:(.text+0x14): warning: _close is not implemented and will always fail
...i686-astatine/bin/ld: ...astatine/sysroot/usr/lib/libc.a(libc_a-fstatr.o): in function `_fstat_r':
...newlib-cygwin/build/i686-astatine/newlib/../../../newlib/libc/reent/fstatr.c:55:(.text+0x17): warning: _fstat is not implemented and will always fail
...
similar like that for _write, _read, _lseek, _isatty.

if someone could please it help it would be greatly appreciated

Re: Trouble porting newlib to my kernel (Syscalls are not being implemented?)

Posted: Fri Nov 14, 2025 5:36 am
by bellezzasolo
Try removing the underscores from your prototypes. Remember that cdecl x86 prefixes the symbol with one underscore.

Re: Trouble porting newlib to my kernel (Syscalls are not being implemented?)

Posted: Fri Nov 14, 2025 6:37 am
by iansjack
The missing functions are the reentrant versions of these system calls. See section 3.2 of https://www.embecosm.com/appnotes/ean9/ ... ib-1.0.pdf

Re: Trouble porting newlib to my kernel (Syscalls are not being implemented?)

Posted: Fri Nov 14, 2025 7:06 am
by atomtables
bellezzasolo wrote: Fri Nov 14, 2025 5:36 am Try removing the underscores from your prototypes. Remember that cdecl x86 prefixes the symbol with one underscore.
This worked, it seems that when I first tried following the osdev wiki guide, my gcc was built with a stubbed libc without any file, so it made its own stderr and redefined a lot of stuff, so I assume that's where I actually faced trouble. Once I recompiled the cross-compiler with the headers of newlib it works now.
iansjack wrote: Fri Nov 14, 2025 6:37 am The missing functions are the reentrant versions of these system calls. See section 3.2 of https://www.embecosm.com/appnotes/ean9/ ... ib-1.0.pdf
I don't think the reentrant versions have to be manually made unless we specify they should. Of course that's a goal, but since the system's currently single-threaded I don't think it's required for implementation anyway.