Changeset 328b89f in mainline


Ignore:
Timestamp:
2025-01-24T23:50:40Z (11 days ago)
Author:
Matěj Volf <git@…>
Children:
544c5b4
Parents:
bf0716f
git-author:
Matěj Volf <git@…> (2025-01-24 23:49:43)
git-committer:
Matěj Volf <git@…> (2025-01-24 23:50:40)
Message:

fix calculation of TLS size for main fibril

Before this patch, _tcb_data_offset always used progsymbols.elfstart. However,
that is wrong when it is being called from the loader server!! Now we pass to it
a pointer to the correct ELF, falling back to elfstart in the public tls_get call.

(debugging this was quite an ordeal and took me like 5 hours, thanks for asking (':)

File:
1 edited

Legend:

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

    rbf0716f r328b89f  
    5959#endif
    6060
    61 static ptrdiff_t _tcb_data_offset(void)
     61static ptrdiff_t _tcb_data_offset(const void* elf)
    6262{
    6363        const elf_segment_header_t *tls =
    64             elf_get_phdr(__progsymbols.elfstart, PT_TLS);
     64            elf_get_phdr(elf, PT_TLS);
    6565
    6666        size_t tls_align = tls ? tls->p_align : 1;
     
    8080        assert(runtime_env == NULL);
    8181#endif
    82         return (uint8_t *)__tcb_get() + _tcb_data_offset();
     82        return (uint8_t *)__tcb_get() + _tcb_data_offset(__progsymbols.elfstart);
    8383}
    8484
     
    114114#ifdef CONFIG_TLS_VARIANT_1
    115115        tcb_t *tcb = area;
    116         uint8_t *data = (uint8_t *)tcb + _tcb_data_offset();
     116        uint8_t *data = (uint8_t *)tcb + _tcb_data_offset(elf);
    117117        memset(tcb, 0, sizeof(*tcb));
    118118#else
    119119        uint8_t *data = area;
    120         tcb_t *tcb = (tcb_t *) (data - _tcb_data_offset());
     120        tcb_t *tcb = (tcb_t *) (data - _tcb_data_offset(elf));
    121121        memset(tcb, 0, sizeof(tcb_t));
    122122        tcb->self = tcb;
Note: See TracChangeset for help on using the changeset viewer.