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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
atomtables
Posts: 14
Joined: Fri Nov 08, 2024 5:08 pm
Libera.chat IRC: atomtables

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

Post 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
User avatar
bellezzasolo
Member
Member
Posts: 163
Joined: Sun Feb 20, 2011 2:01 pm

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

Post by bellezzasolo »

Try removing the underscores from your prototypes. Remember that cdecl x86 prefixes the symbol with one underscore.
Whoever said you can't do OS development on Windows?
https://github.com/ChaiSoft/ChaiOS
User avatar
iansjack
Member
Member
Posts: 4908
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post 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
atomtables
Posts: 14
Joined: Fri Nov 08, 2024 5:08 pm
Libera.chat IRC: atomtables

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

Post 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.
Post Reply