nptl: fix libc nptl forwarding stubs

Timo Teräs timo.teras at iki.fi
Tue Apr 13 17:27:57 UTC 2010


The attribute_hidden is added to all forward stubs, to avoid self recursion.
If libc and libpthread linking order is reversed, the libc stub would end up
being used in the libpthread side struct pthread_functions. Apparently glibc
side is doing linker magic to avoid this. I don't think it really makes sense
for libc to export pthreads symbols, so I'm using attribute_hidden there.
Alternatively we could use protected visibility on libpthread side to make
sure it's using it's own symbols.

The pointer demangling is also turned off. Currently the stub calls would
demangle the pointer that is never mangled. Alternatively, we could sync
nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c with new glibc version
that properly mangles the pointers, but that would need more validation
to make sure that all struct pthread_function readers do demangling.
uclibc currently does not do pointer mangling everywhere so it's more
consistent to just disable it here too.

Signed-off-by: Timo Teras <timo.teras at iki.fi>

diff --git a/libpthread/nptl/forward.c b/libpthread/nptl/forward.c
index 8f528d0..e9a2a0b 100644
--- a/libpthread/nptl/forward.c
+++ b/libpthread/nptl/forward.c
@@ -32,6 +32,7 @@ int __libc_pthread_functions_init attribute_hidden;
 
 
 #define FORWARD2(name, rettype, decl, params, defaction) \
+rettype name decl attribute_hidden;					      \
 rettype									      \
 name decl								      \
 {									      \
diff --git a/libpthread/nptl/sysdeps/pthread/pthread-functions.h b/libpthread/nptl/sysdeps/pthread/pthread-functions.h
index 0c404fc..3808e4c 100644
--- a/libpthread/nptl/sysdeps/pthread/pthread-functions.h
+++ b/libpthread/nptl/sysdeps/pthread/pthread-functions.h
@@ -103,7 +103,7 @@ struct pthread_functions
 extern struct pthread_functions __libc_pthread_functions attribute_hidden;
 extern int __libc_pthread_functions_init attribute_hidden;
 
-#ifdef PTR_DEMANGLE
+#if 0
 # define PTHFCT_CALL(fct, params) \
   ({ __typeof (__libc_pthread_functions.fct) __p;			      \
      __p = __libc_pthread_functions.fct;				      \


More information about the uClibc mailing list