Lack of error handling before TLS is initialized
errno
is currently defined as a thread-local, and this makes all functions using errno
completely fault-intolerant when TLS has not yet been initialized, which is the case when mapping the TLS memory itself, and in (most of) ld.so. Any failure will thus cause a SIGSEGV, and while it may not make sense to handle errors while e.g. allocating the TCB or memory for loading dynamic programs, it should at least be possible to handle the errors. The best solution is probably to lower the use of errno to the C-facing API, away from the platform trait which is used internally. (We could also define errno
as a macro, like #define errno (*errno_location())
, and use TLS only after a flag has been set, even though TLS will have been initialized before user code starts, and we don't use C macros much inside relibc.)