Changes in uspace/lib/c/generic/thread/tls.c [ffccdff0:32254d6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/thread/tls.c
rffccdff0 r32254d6 59 59 #endif 60 60 61 static ptrdiff_t _tcb_data_offset( void)61 static ptrdiff_t _tcb_data_offset(const void *elf) 62 62 { 63 63 const elf_segment_header_t *tls = 64 elf_get_phdr( __progsymbols.elfstart, PT_TLS);64 elf_get_phdr(elf, 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 */76 /** Get address of static TLS block - only when RTLD is not initialized */ 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( );82 return (uint8_t *)__tcb_get() + _tcb_data_offset(__progsymbols.elfstart); 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 less 89 * messy code for the dynamic-linking version of this. 90 */ 87 91 assert(!elf_get_phdr(elf, PT_DYNAMIC)); 88 92 #ifdef CONFIG_RTLD … … 100 104 assert(tls_align <= PAGE_SIZE); 101 105 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 102 113 #ifdef CONFIG_TLS_VARIANT_1 103 114 size_t alloc_size = … … 114 125 #ifdef CONFIG_TLS_VARIANT_1 115 126 tcb_t *tcb = area; 116 uint8_t *data = (uint8_t *)tcb + _tcb_data_offset( );127 uint8_t *data = (uint8_t *)tcb + _tcb_data_offset(elf); 117 128 memset(tcb, 0, sizeof(*tcb)); 118 129 #else 119 130 uint8_t *data = area; 120 tcb_t *tcb = (tcb_t *) (data - _tcb_data_offset( ));131 tcb_t *tcb = (tcb_t *) (data - _tcb_data_offset(elf)); 121 132 memset(tcb, 0, sizeof(tcb_t)); 122 133 tcb->self = tcb;
Note:
See TracChangeset
for help on using the changeset viewer.