The time has come for a kernel interfacing library layer
Matthew Dillon
dillon at apollo.backplane.com
Sun May 8 09:20:57 PDT 2005
:> Joerg, to make this work I need two other things:
:>
:> * We need to have the kernel automatically setup the initial TLS
:> space.
:
:Why? Do you want to completely eliminate the syscall wrappers from libc?
:That's going to add problems later I fear. I'd instead change it the
:interface between library layer and syscall functions in libc to always
:provide a pointer to errno as argument. That would solve the problems
:e.g. with RTLD too.
:
:Joerg
I considered providing a poiner to errno, but it would mean changing
the int $0x80 algorithm which right now assumes that the arguments are
a certain offset relative to the call stack.
It's easier to simply require that a pointer to errno be stored in
the TLS (via i386/include/tls.h).
I've almost got this working. I'm writing a new system call
configuration file format and a program to generate the fixed-offset
shims.
Basically as far as libc or rtld is concerned, they simply link
against another library called 'libsys' (rtld gets its own, which we
make the one libc uses part of the crt link sequence). This library
will contain the system calls in a specially-named section. The
kernel will then remap the section as appropriate. We have the option
of making the section a BSS section (so it takes up no space in the
actual linked program), or making the section a code section with real
'default' syscall entry points in it.
Here's an example of a BSS code section reserving fixed-offsets for
system calls:
.section special,"ax", @nobits
.globl fubar0
.globl fubar1
.globl fubar2
.p2align 12
.org 0
syscall0:
.org 64
syscall1:
.org 128
syscall2:
.org 192
.p2align 12
We generate a 'real code' version for the kernel to mmap-over the
space the 'user bss' version reserves in the program for userland.
Or, alternatively, we link the real code version into userland as
a default and still allow the kernel to override it with its own
'real code' version.
I am gunning for the BSS version myself, because it takes no extra
space in the program binary, but I haven't worked out all the
backwards compatibility issues yet. It could very well be that we
will have to have a third 'compact' syscall library just for rtld,
sorta like we do now with the compact libc library we link against
rtld.
-Matt
Matthew Dillon
<dillon at xxxxxxxxxxxxx>
More information about the Kernel
mailing list