|
|
Subscribe / Log in / New account

Removing syscall() from OpenBSD

Removing syscall() from OpenBSD

Posted Oct 30, 2023 14:35 UTC (Mon) by zwol (guest, #126152)
In reply to: Removing syscall() from OpenBSD by NYKevin
Parent article: Removing syscall() from OpenBSD

Yeah, the built-in Windows component that performs "the C library"'s function of communicating directly with the kernel is NTDLL.DLL.

It's instructive to read up on what-all NTDLL.DLL provides, because it started out, back in the days of NT 4.0, as a "just the system calls" shim under KERNEL32.DLL, like someone was saying we should have over in Unix land. But look at the actual file "c:\windows\system32\ntdll.dll" in a current-generation Windows. It's bigger than libc.so.6. If you dump out its symbol table, it provides a whole lot of functionality besides the system calls.

This is for practical engineering reasons. NTDLL.DLL is the only piece of code that is guaranteed to be loaded into every user space process, and that means it's the logical place to put functionality that every process needs, no matter what — such as the dynamic loader. Well, it turns out that a dynamic loader is a big Twinkie with a lot of dependencies, because it needs a heap allocator, it needs to be able to report errors, and it needs to be tied so intimately into the thread library that it's easiest to make it be the thread library. All by themselves those things add up to most of a conventional "language runtime". And then once you have that, inevitably it suffers feature creep.

I have occasionally thought about what a minimal "just the syscalls" shared library, that all the post-C languages could agree on, would look like, and, well, I think the only plausible way for it to be truly "minimal" and "language-agnostic" is if we somehow move the dynamic loader out of process. That would be worth doing for various security-related reasons as well, but it needs a bunch of new kernel API (so it can manipulate an arbitrary process's memory map without becoming that process's debugger), and it might be unacceptably slow, and it adds, um, challenges to system boot.

(It might be interesting to think about a different split, though, in which we divide all of ISO C + POSIX functionality into "everyone needs this" and "only programs written in C want this", accepting that much of the "everyone needs" pile will retain a certain C flavor to it. I don't know if it would be worth doing, I would have to take the time to make the lists.)


to post comments

Removing syscall() from OpenBSD

Posted Nov 1, 2023 17:32 UTC (Wed) by simcop2387 (subscriber, #101710) [Link]

It's not explicitly targeting that topic, but you might give a look to Redox-OS since the whole gimmic there is that it's written in rust and with no C (in theory, not sure if it's completely that way). They provide a c library for compatibility but it's not used as the way to interact with the kernel.

https://www.redox-os.org/


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds