Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/thread/tls.c

    r32254d6 rffccdff0  
    5959#endif
    6060
    61 static ptrdiff_t _tcb_data_offset(const void *elf)
     61static ptrdiff_t _tcb_data_offset(void)
    6262{
    6363        const elf_segment_header_t *tls =
    64             elf_get_phdr(elf, PT_TLS);
     64            elf_get_phdr(__progsymbols.elfstart, PT_TLS);
    6565
    6666        size_t tls_align = tls ? tls->p_align : 1;
     
    7474}
    7575
    76 /** Get address of static TLS block - only when RTLD is not initialized  */
     76/** Get address of static TLS block */
    7777void *tls_get(void)
    7878{
     
    8080        assert(runtime_env == NULL);
    8181#endif
    82         return (uint8_t *)__tcb_get() + _tcb_data_offset(__progsymbols.elfstart);
     82        return (uint8_t *)__tcb_get() + _tcb_data_offset();
    8383}
    8484
    8585static tcb_t *tls_make_generic(const void *elf, void *(*alloc)(size_t, size_t))
    8686{
    87         /*
    88          * See also rtld/module.c -> modules_process_tls(), where we have less
    89          * messy code for the dynamic-linking version of this.
    90          */
    9187        assert(!elf_get_phdr(elf, PT_DYNAMIC));
    9288#ifdef CONFIG_RTLD
     
    104100        assert(tls_align <= PAGE_SIZE);
    105101
    106         /*
    107          * FIXME: the calculation of alloc_size shouldn't include the alignment
    108          * of tcb_t (at least in Variant II)
    109          * See https://github.com/HelenOS/helenos/pull/240/files/4ef27ebf98a0656e09889b7d00efdec03343f1aa#r1929592924
    110          * (you will also need to fix _tcb_data_offset)
    111          */
    112 
    113102#ifdef CONFIG_TLS_VARIANT_1
    114103        size_t alloc_size =
     
    125114#ifdef CONFIG_TLS_VARIANT_1
    126115        tcb_t *tcb = area;
    127         uint8_t *data = (uint8_t *)tcb + _tcb_data_offset(elf);
     116        uint8_t *data = (uint8_t *)tcb + _tcb_data_offset();
    128117        memset(tcb, 0, sizeof(*tcb));
    129118#else
    130119        uint8_t *data = area;
    131         tcb_t *tcb = (tcb_t *) (data - _tcb_data_offset(elf));
     120        tcb_t *tcb = (tcb_t *) (data - _tcb_data_offset());
    132121        memset(tcb, 0, sizeof(tcb_t));
    133122        tcb->self = tcb;
Note: See TracChangeset for help on using the changeset viewer.