TLS emulation / handling errno in sysdep.h

Peter Mazinger ps.m at gmx.net
Mon Apr 11 10:47:48 UTC 2011


Hello,

if gcc is built with --disable-tls, then TLS symbols change their name,
for ex. "__libc_errno" becomes "__emutls_v.__libc_errno". Checking gcc for
__thread support does not fail in this case (done in Rules.mak), so we
are not bailing out early enough. I am not even sure, if this should be
considered an error (consider cross-compiling...)

The problem exhibits as failure later, when *.S files from the NPTL tree
are compiled, like close.S and the linker will fail missing __libc_errno.

Looking more deeply into this I want to propose following change to sysdep.h

#ifndef NOT_IN_libc
# undef SYSCALL_ERROR_LABEL
# define SYSCALL_ERROR_LABEL __syscall_error
#endif

#ifndef NOT_IN_libc
# undef SYSCALL_ERROR_HANDLER
# define SYSCALL_ERROR_HANDLER
#endif

This solves multiple issues:
1. we avoid to use the SYSCALL_ERROR_ERRNO definition
2. we reuse __syscall_error() already compiled correctly (using the proper errno independently of it's name)
3. since __syscall_error() is hidden, we do not have to care about PIC
4. some of the IF's/IFDEF's in sysdep.h can't be correctly used in uClibc
because we do no autodetection, so depending on CFLAGS we might anyway
choose the wrong section (like NO_TLS_DIRECT_SEG_REFS)

Opinions?

Anyway, all the glibc-copied sysdep.h have to be cleaned up, the assembler code adapted to use the same definition/macros, see for ex. the use of
ENTER_KERNEL (x86 has 3 different versions and we end up using 2
different versions in the same build)

Regards, Peter
-- 
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit 
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl


More information about the uClibc mailing list