Joakim Tjernlund wrote:
Is there a reason the forwarding functions in libc are visible to other shared libraries - it seems to me they are just for libc internal use? If not, the patch below seems to fix the problem here. Any other ideas?

No other ideas, can't see a reason to export _X
functions, but your patch hides all non _X funs too and that looks wrong.

How so? Why would anything want to access these libc forwader functions instead of the ones in libpthread?

Anyhow, plan b is to make sure the table in pthread.c refers only to hidden libpthread-internal functions. That's done by the following patch.

Unfortunately, it's all a bit inconsistent. The pthread_mutex functions already have private versions prefixed with __. For most of the others, I've used libpthread_hidden_{proto,def} to create internal symbols; this however did not work for _pthread_cleanup_push_defer and _pthread_cleanup_pop_restore - it interfered with the weak stuff from libc-lock.h. The latter file is probably more complex than necessary in uClibc, as we don't seem to use any of the libc_*_lock functions (should we?). I've just created another name for these two functions with a strong alias.


Bernd
--
This footer brought to you by insane German lawmakers.
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368
Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif
Index: libpthread/linuxthreads.old/pthread.c
===================================================================
--- libpthread/linuxthreads.old/pthread.c       (revision 1667)
+++ libpthread/linuxthreads.old/pthread.c       (working copy)
@@ -284,6 +284,41 @@ int __libc_allocate_rtsig (int high)
 
 static void pthread_initialize(void) __attribute__((constructor));
 
+libpthread_hidden_proto(pthread_attr_destroy)
+libpthread_hidden_proto(pthread_attr_init)
+libpthread_hidden_proto(pthread_attr_getdetachstate)
+libpthread_hidden_proto(pthread_attr_setdetachstate)
+libpthread_hidden_proto(pthread_attr_getinheritsched)
+libpthread_hidden_proto(pthread_attr_setinheritsched)
+libpthread_hidden_proto(pthread_attr_setschedparam)
+libpthread_hidden_proto(pthread_attr_getschedparam)
+libpthread_hidden_proto(pthread_attr_getschedpolicy)
+libpthread_hidden_proto(pthread_attr_setschedpolicy)
+libpthread_hidden_proto(pthread_attr_getscope)
+libpthread_hidden_proto(pthread_attr_setscope)
+
+libpthread_hidden_proto(pthread_exit)
+
+libpthread_hidden_proto(pthread_equal)
+libpthread_hidden_proto(pthread_self)
+libpthread_hidden_proto(pthread_getschedparam)
+libpthread_hidden_proto(pthread_setschedparam)
+
+libpthread_hidden_proto(pthread_setcancelstate)
+libpthread_hidden_proto(pthread_setcanceltype)
+libpthread_hidden_proto(_pthread_cleanup_push_defer)
+libpthread_hidden_proto(_pthread_cleanup_pop_restore)
+
+libpthread_hidden_proto(pthread_cond_broadcast)
+libpthread_hidden_proto(pthread_cond_destroy)
+libpthread_hidden_proto(pthread_cond_init)
+libpthread_hidden_proto(pthread_cond_signal)
+libpthread_hidden_proto(pthread_cond_wait)
+libpthread_hidden_proto(pthread_cond_timedwait)
+
+libpthread_hidden_proto(pthread_condattr_destroy)
+libpthread_hidden_proto(pthread_condattr_init)
+
 struct pthread_functions __pthread_functions =
   {
 #if !(USE_TLS && HAVE___THREAD)
@@ -638,11 +673,13 @@ pthread_t pthread_self(void)
   pthread_descr self = thread_self();
   return THREAD_GETMEM(self, p_tid);
 }
-
+libpthread_hidden_def (pthread_self)
+    
 int pthread_equal(pthread_t thread1, pthread_t thread2)
 {
   return thread1 == thread2;
 }
+libpthread_hidden_def (pthread_equal)
 
 /* Helper function for thread_self in the case of user-provided stacks */
 
@@ -714,6 +751,7 @@ int pthread_setschedparam(pthread_t thre
     __pthread_manager_adjust_prio(th->p_priority);
   return 0;
 }
+libpthread_hidden_def(pthread_setschedparam)
 
 int pthread_getschedparam(pthread_t thread, int *policy,
                           struct sched_param *param)
@@ -734,6 +772,7 @@ int pthread_getschedparam(pthread_t thre
   *policy = pol;
   return 0;
 }
+libpthread_hidden_def(pthread_getschedparam)
 
 /* Process-wide exit() request */
 
Index: libpthread/linuxthreads.old/join.c
===================================================================
--- libpthread/linuxthreads.old/join.c  (revision 1667)
+++ libpthread/linuxthreads.old/join.c  (working copy)
@@ -25,10 +25,12 @@
 #include "restart.h"
 #include "debug.h" /* PDEBUG, added by StS */
 
+libpthread_hidden_proto (pthread_exit)
 void pthread_exit(void * retval)
 {
   __pthread_do_exit (retval, CURRENT_STACK_FRAME);
 }
+libpthread_hidden_def (pthread_exit)
 
 void __pthread_do_exit(void *retval, char *currentframe)
 {
Index: libpthread/linuxthreads.old/sysdeps/pthread/pthread.h
===================================================================
--- libpthread/linuxthreads.old/sysdeps/pthread/pthread.h       (revision 1667)
+++ libpthread/linuxthreads.old/sysdeps/pthread/pthread.h       (working copy)
@@ -635,6 +635,9 @@ extern void _pthread_cleanup_pop (struct
 extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer 
*__buffer,
                                         void (*__routine) (void *),
                                         void *__arg) __THROW;
+extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer 
*__buffer,
+                                         void (*__routine) (void *),
+                                         void *__arg) __THROW;
 
 /* Remove a cleanup handler as pthread_cleanup_pop does, but also
    restores the cancellation type that was in effect when the matching
@@ -645,6 +648,8 @@ extern void _pthread_cleanup_push_defer 
 
 extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer 
*__buffer,
                                          int __execute) __THROW;
+extern void __pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer 
*__buffer,
+                                          int __execute) __THROW;
 #endif
 
 
Index: libpthread/linuxthreads.old/attr.c
===================================================================
--- libpthread/linuxthreads.old/attr.c  (revision 1667)
+++ libpthread/linuxthreads.old/attr.c  (working copy)
@@ -25,6 +25,19 @@
 #include "pthread.h"
 #include "internals.h"
 
+libpthread_hidden_proto(pthread_attr_destroy)
+libpthread_hidden_proto(pthread_attr_init)
+libpthread_hidden_proto(pthread_attr_getdetachstate)
+libpthread_hidden_proto(pthread_attr_setdetachstate)
+libpthread_hidden_proto(pthread_attr_getinheritsched)
+libpthread_hidden_proto(pthread_attr_setinheritsched)
+libpthread_hidden_proto(pthread_attr_setschedparam)
+libpthread_hidden_proto(pthread_attr_getschedparam)
+libpthread_hidden_proto(pthread_attr_getschedpolicy)
+libpthread_hidden_proto(pthread_attr_setschedpolicy)
+libpthread_hidden_proto(pthread_attr_getscope)
+libpthread_hidden_proto(pthread_attr_setscope)
+
 /* NOTE: With uClibc I don't think we need this versioning stuff.
  * Therefore, define the function pthread_attr_init() here using
  * a strong symbol. */
@@ -45,6 +58,7 @@ int pthread_attr_init(pthread_attr_t *at
   attr->__stacksize = STACK_SIZE - ps;
   return 0;
 }
+libpthread_hidden_def(pthread_attr_init)
 
 /* uClibc: leave out this for now. */
 #if DO_PTHREAD_VERSIONING_WITH_UCLIBC
@@ -70,6 +84,8 @@ int pthread_attr_destroy(pthread_attr_t 
 {
   return 0;
 }
+libpthread_hidden_def(pthread_attr_destroy)
+
 
 int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
 {
@@ -79,12 +95,14 @@ int pthread_attr_setdetachstate(pthread_
   attr->__detachstate = detachstate;
   return 0;
 }
+libpthread_hidden_def(pthread_attr_setdetachstate)
 
 int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
 {
   *detachstate = attr->__detachstate;
   return 0;
 }
+libpthread_hidden_def(pthread_attr_getdetachstate)
 
 int pthread_attr_setschedparam(pthread_attr_t *attr,
                                const struct sched_param *param)
@@ -97,6 +115,7 @@ int pthread_attr_setschedparam(pthread_a
   memcpy (&attr->__schedparam, param, sizeof (struct sched_param));
   return 0;
 }
+libpthread_hidden_def(pthread_attr_setschedparam)
 
 int pthread_attr_getschedparam(const pthread_attr_t *attr,
                                struct sched_param *param)
@@ -104,6 +123,7 @@ int pthread_attr_getschedparam(const pth
   memcpy (param, &attr->__schedparam, sizeof (struct sched_param));
   return 0;
 }
+libpthread_hidden_def(pthread_attr_getschedparam)
 
 int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
 {
@@ -118,6 +138,7 @@ int pthread_attr_getschedpolicy(const pt
   *policy = attr->__schedpolicy;
   return 0;
 }
+libpthread_hidden_def(pthread_attr_getschedpolicy)
 
 int pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit)
 {
@@ -126,12 +147,14 @@ int pthread_attr_setinheritsched(pthread
   attr->__inheritsched = inherit;
   return 0;
 }
+libpthread_hidden_def(pthread_attr_setinheritsched)
 
 int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit)
 {
   *inherit = attr->__inheritsched;
   return 0;
 }
+libpthread_hidden_def(pthread_attr_getinheritsched)
 
 int pthread_attr_setscope(pthread_attr_t *attr, int scope)
 {
@@ -145,12 +168,14 @@ int pthread_attr_setscope(pthread_attr_t
     return EINVAL;
   }
 }
+libpthread_hidden_def(pthread_attr_setscope)
 
 int pthread_attr_getscope(const pthread_attr_t *attr, int *scope)
 {
   *scope = attr->__scope;
   return 0;
 }
+libpthread_hidden_def(pthread_attr_getscope)
 
 int __pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize)
 {
Index: libpthread/linuxthreads.old/cancel.c
===================================================================
--- libpthread/linuxthreads.old/cancel.c        (revision 1667)
+++ libpthread/linuxthreads.old/cancel.c        (working copy)
@@ -37,6 +37,8 @@ extern void __rpc_thread_destroy(void);
 # error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
 #endif
 
+libpthread_hidden_proto(pthread_setcancelstate)
+libpthread_hidden_proto(pthread_setcanceltype)
 
 int pthread_setcancelstate(int state, int * oldstate)
 {
@@ -51,6 +53,7 @@ int pthread_setcancelstate(int state, in
     __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
   return 0;
 }
+libpthread_hidden_def(pthread_setcancelstate)
 
 int pthread_setcanceltype(int type, int * oldtype)
 {
@@ -65,6 +68,7 @@ int pthread_setcanceltype(int type, int 
     __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
   return 0;
 }
+libpthread_hidden_def(pthread_setcanceltype)
 
 int pthread_cancel(pthread_t thread)
 {
@@ -165,6 +169,7 @@ void _pthread_cleanup_push_defer(struct 
   THREAD_SETMEM(self, p_canceltype, PTHREAD_CANCEL_DEFERRED);
   THREAD_SETMEM(self, p_cleanup, buffer);
 }
+strong_alias(_pthread_cleanup_push_defer,__pthread_cleanup_push_defer)
 
 void _pthread_cleanup_pop_restore(struct _pthread_cleanup_buffer * buffer,
                                  int execute)
@@ -178,6 +183,8 @@ void _pthread_cleanup_pop_restore(struct
       THREAD_GETMEM(self, p_canceltype) == PTHREAD_CANCEL_ASYNCHRONOUS)
     __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
 }
+strong_alias(_pthread_cleanup_pop_restore,__pthread_cleanup_pop_restore)
+
 
 void __pthread_perform_cleanup(char *currentframe)
 {
Index: libpthread/linuxthreads.old/condvar.c
===================================================================
--- libpthread/linuxthreads.old/condvar.c       (revision 1667)
+++ libpthread/linuxthreads.old/condvar.c       (working copy)
@@ -25,6 +25,16 @@
 #include "queue.h"
 #include "restart.h"
 
+libpthread_hidden_proto(pthread_cond_broadcast)
+libpthread_hidden_proto(pthread_cond_destroy)
+libpthread_hidden_proto(pthread_cond_init)
+libpthread_hidden_proto(pthread_cond_signal)
+libpthread_hidden_proto(pthread_cond_wait)
+libpthread_hidden_proto(pthread_cond_timedwait)
+
+libpthread_hidden_proto(pthread_condattr_destroy)
+libpthread_hidden_proto(pthread_condattr_init)
+
 int pthread_cond_init(pthread_cond_t *cond,
                       const pthread_condattr_t *cond_attr attribute_unused)
 {
@@ -32,12 +42,14 @@ int pthread_cond_init(pthread_cond_t *co
   cond->__c_waiting = NULL;
   return 0;
 }
+libpthread_hidden_def(pthread_cond_init)
 
 int pthread_cond_destroy(pthread_cond_t *cond)
 {
   if (cond->__c_waiting != NULL) return EBUSY;
   return 0;
 }
+libpthread_hidden_def(pthread_cond_destroy)
 
 /* Function called by pthread_cancel to remove the thread from
    waiting on a condition variable queue. */
@@ -132,6 +144,7 @@ int pthread_cond_wait(pthread_cond_t *co
   __pthread_mutex_lock(mutex);
   return 0;
 }
+libpthread_hidden_def(pthread_cond_wait)
 
 static int
 pthread_cond_timedwait_relative(pthread_cond_t *cond,
@@ -233,6 +246,7 @@ int pthread_cond_timedwait(pthread_cond_
   /* Indirect call through pointer! */
   return pthread_cond_timedwait_relative(cond, mutex, abstime);
 }
+libpthread_hidden_def(pthread_cond_timedwait)
 
 int pthread_cond_signal(pthread_cond_t *cond)
 {
@@ -248,6 +262,7 @@ int pthread_cond_signal(pthread_cond_t *
   }
   return 0;
 }
+libpthread_hidden_def(pthread_cond_signal)
 
 int pthread_cond_broadcast(pthread_cond_t *cond)
 {
@@ -266,16 +281,19 @@ int pthread_cond_broadcast(pthread_cond_
   }
   return 0;
 }
+libpthread_hidden_def(pthread_cond_broadcast)
 
 int pthread_condattr_init(pthread_condattr_t *attr attribute_unused)
 {
   return 0;
 }
+libpthread_hidden_def(pthread_condattr_init)
 
 int pthread_condattr_destroy(pthread_condattr_t *attr attribute_unused)
 {
   return 0;
 }
+libpthread_hidden_def(pthread_condattr_destroy)
 
 int pthread_condattr_getpshared (const pthread_condattr_t *attr 
attribute_unused, int *pshared)
 {
_______________________________________________
uClibc mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Reply via email to