htl: moving symbol that are in ldsodefs.h
Florian Weimer
fweimer@redhat.com
Mon Dec 9 20:36:47 GMT 2024
* Guy-Fleury Iteriteka:
> Hello,
>
> I apologize for bothering you, but I'm currently stuck with moving a
> specific symbol. I want to move __pthread_sigstate_init into libc, but
> this function tries to access _dl_pthread_num_threads like *GL
> (dl_pthread_num_threads)*, which is defined in
> sysdeps/htl/dl-support.c and declared in sysdeps/generic/ldsodefs.h as
> EXTERN int _dl_pthread_num_threads;. This symbol is already part of
> the ELF, but when I attempt to move __pthread_sigstate_init into libc,
> I also try to move _dl_pthread_num_threads out of the PTHREAD_IN_LIBC
> block in ldsodefs.h. I've moved _dl_pthread_num_threads into the ELF
> Versions ld, yet I still encounter an error stating that
> _dl_pthread_num_threads is not defined while compiling
> __pthread_sigstate_init.
We currently do not have a kernel-specific hook for struct rtld_global.
Maybe it's time to create a file dl-rtld_global.c from this block of code:
#if PTHREAD_IN_LIBC
/* List of active thread stacks, with memory managed by glibc. */
EXTERN list_t _dl_stack_used;
/* List of thread stacks that were allocated by the application. */
EXTERN list_t _dl_stack_user;
/* List of queued thread stacks. */
EXTERN list_t _dl_stack_cache;
/* Total size of all stacks in the cache (sum over stackblock_size). */
EXTERN size_t _dl_stack_cache_actsize;
/* We need to record what list operations we are going to do so
that, in case of an asynchronous interruption due to a fork()
call, we can correct for the work. */
EXTERN uintptr_t _dl_in_flight_stack;
/* Mutex protecting the stack lists. */
EXTERN int _dl_stack_cache_lock;
#else
/* The total number of thread IDs currently in use, or on the list of
available thread IDs. */
EXTERN int _dl_pthread_num_threads;
/* Array of __pthread structures and its lock. */
EXTERN struct __pthread **_dl_pthread_threads;
__libc_rwlock_define (EXTERN, _dl_pthread_threads_lock)
#endif
So create an empty file sysdeps/generic/dl-rtld_global.c. Move the
first part into sysdeps/unix/sysv/linux/dl-rtld_global.c. Move the
second part in to sysdeps/htl/dl-rtld_global.c (or somewhere else that
is part of the Hurd build). And then replace the block with
#include <dl-rtld_global.c>. Similar to what we already do
for dl-vdso-setup.c.
Obviously this change should be in a separate commit.
> Additionally, I have another question: how will other components not
> yet in libc, such as htl/pt-create.c, access _dl_pthread_num_threads
> if move _dl_pthread_num_threads out of PTHREAD_IN_LIBC?
It's still availabe as GL (dl_pthread_num_threads) after the changes
above.
Thanks,
Florian
More information about the Libc-alpha
mailing list