• Evgeniy Stepanov's avatar
    Initialize TLS before any application code is run. · 1a78fbb5
    Evgeniy Stepanov authored
    Since e19d702b, dlsym and friends use recursive mutexes that
    require the current thread id, which is not available before the libc
    constructor. This prevents us from using dlsym() in .preinit_array.
    
    This change moves TLS initialization from libc constructor to the earliest
    possible point - immediately after linker itself is relocated. As a result,
    pthread_internal_t for the initial thread is available from the start.
    
    As a bonus, values stored in TLS in .preinit_array are not lost when libc is
    initialized.
    
    Change-Id: Iee5a710ee000173bff63e924adeb4a4c600c1e2d
    1a78fbb5
bionic_tls.h 5.16 KB