Changeset c880421 in mainline
- Timestamp:
- 2025-01-25T21:22:04Z (4 weeks ago)
- Parents:
- 4ef27eb
- Location:
- uspace/lib/c/generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/rtld/module.c
r4ef27eb rc880421 398 398 * be correct, "zero" offset (i.e. the total size) must be aligned 399 399 * to the strictest alignment present. 400 * Note that the padding is actually in front of the TLS data,401 * not after it.402 400 */ 403 401 rtld->tls_size = ALIGN_UP(rtld->tls_size, rtld->tls_align); 404 402 405 /* Space for the TCB. 403 /* 404 * Space for the TCB. 406 405 * Later, the TLS zero offset is equal to the pointer to tcb_t, so 407 406 * adding the sizeof(tcb_t) block AFTER we calculated the alignment -
uspace/lib/c/generic/thread/tls.c
r4ef27eb rc880421 104 104 assert(tls_align <= PAGE_SIZE); 105 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 106 113 #ifdef CONFIG_TLS_VARIANT_1 107 114 size_t alloc_size = … … 132 139 uintptr_t bias = elf_get_bias(elf); 133 140 134 /*135 * FIXME: I couldn't convince myself this is correct, but I couldn't136 * find a case where it breaks either: if the actual alloc_size is137 * bigger than the requested size (tls->p_memsz), the alignment padding138 * will be placed at the beginning (because TLS is (at least sometimes?)139 * indexed with negative offsets from the TCB pointer).140 *141 * Now we will copy the initialization data to a position at the start of142 * the allocation, so if the padding has nonzero size, if think the initialization143 * data is now incorrectly offset by its size?144 *145 * Maybe a diagram helps explaining this?146 * | allocation | |147 * | paddding | data | tcb |148 * ^149 * +--- we will copy the initialization data here150 * ^151 * +--- but the data should be actually here?152 */153 154 141 /* Copy thread local data from the initialization image. */ 155 142 memcpy(data, (void *)(tls->p_vaddr + bias), tls->p_filesz);
Note:
See TracChangeset
for help on using the changeset viewer.