Changes in uspace/lib/c/generic/thread/tls.c [32254d6:ffccdff0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/thread/tls.c
r32254d6 rffccdff0 59 59 #endif 60 60 61 static ptrdiff_t _tcb_data_offset( const void *elf)61 static ptrdiff_t _tcb_data_offset(void) 62 62 { 63 63 const elf_segment_header_t *tls = 64 elf_get_phdr( elf, PT_TLS);64 elf_get_phdr(__progsymbols.elfstart, PT_TLS); 65 65 66 66 size_t tls_align = tls ? tls->p_align : 1; … … 74 74 } 75 75 76 /** Get address of static TLS block - only when RTLD is not initialized*/76 /** Get address of static TLS block */ 77 77 void *tls_get(void) 78 78 { … … 80 80 assert(runtime_env == NULL); 81 81 #endif 82 return (uint8_t *)__tcb_get() + _tcb_data_offset( __progsymbols.elfstart);82 return (uint8_t *)__tcb_get() + _tcb_data_offset(); 83 83 } 84 84 85 85 static tcb_t *tls_make_generic(const void *elf, void *(*alloc)(size_t, size_t)) 86 86 { 87 /*88 * See also rtld/module.c -> modules_process_tls(), where we have less89 * messy code for the dynamic-linking version of this.90 */91 87 assert(!elf_get_phdr(elf, PT_DYNAMIC)); 92 88 #ifdef CONFIG_RTLD … … 104 100 assert(tls_align <= PAGE_SIZE); 105 101 106 /*107 * FIXME: the calculation of alloc_size shouldn't include the alignment108 * of tcb_t (at least in Variant II)109 * See https://github.com/HelenOS/helenos/pull/240/files/4ef27ebf98a0656e09889b7d00efdec03343f1aa#r1929592924110 * (you will also need to fix _tcb_data_offset)111 */112 113 102 #ifdef CONFIG_TLS_VARIANT_1 114 103 size_t alloc_size = … … 125 114 #ifdef CONFIG_TLS_VARIANT_1 126 115 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(); 128 117 memset(tcb, 0, sizeof(*tcb)); 129 118 #else 130 119 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()); 132 121 memset(tcb, 0, sizeof(tcb_t)); 133 122 tcb->self = tcb;
Note:
See TracChangeset
for help on using the changeset viewer.