Revision 20625, opendir

Bernd Schmidt bernds_cb1 at
Fri Jun 6 22:47:57 UTC 2008

I'm reviewing old patches before checking them into the Blackfin 

   r20625 | carmelo | 2007-12-05

   Fix opendir problem when statically linked due to a missing
   initialization of the mutex field within DIR struct.
   When linked dynamically instead, __pthread_mutex_init will
   initialize the mutex itself. Without this fix, any call to
   readdir will stuck forever trying to acquire the mutex.

This makes no sense to me, and we'd probably have noticed if readdir 
wasn't working.  In a static link that does not include libpthread, all 
the pthread_ functions are supposed to resolve to a weak function called 
___pthread_return_0, and this is what happens over here:

bernds at beaker $ bfin-uclinux-nm a.out.gdb|grep pthread
00000710 W __pthread_cleanup_pop_restore
00000710 W __pthread_cleanup_push_defer
          w ___pthread_initialize_minimal
00000700 W ___pthread_mutex_init
00000700 W ___pthread_mutex_lock
00000700 W ___pthread_mutex_trylock
00000700 W ___pthread_mutex_unlock
00000700 t ___pthread_return_0
00000710 t ___pthread_return_void

When libpthread is included in the link, __pthread_mutex_init will do 
the initialization.  So, what's going on?

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

More information about the uClibc mailing list