Skip to content

Commit d996223

Browse files
committed
ld.so: Handle local TLSDESC entry from libstdc++?
1 parent 09af9ac commit d996223

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

linker/linker.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,18 @@ static int object_relocate(elf_t * object) {
578578
memcpy((void *)(table->r_offset + object->base), &x, sizeof(uintptr_t));
579579
break;
580580
case 1031: {
581-
x += *((ssize_t *)(table->r_offset + object->base));
582-
if (!hashmap_has(tls_map, symname)) {
583-
fprintf(stderr, "Don't know where to get %s from TLS\n", symname);
584-
exit(1);
581+
if (symbol) {
582+
if (!hashmap_has(tls_map, symname)) {
583+
fprintf(stderr, "Warning: Don't know where to get %s (symbol %d) from TLS\n", symname, symbol);
584+
break;
585+
}
586+
x += *((ssize_t *)(table->r_offset + object->base));
587+
x += (size_t)hashmap_get(tls_map, symname);
588+
} else {
589+
/* local tls descriptor? no symbol? idk what to do with this, hope it works */
590+
x = current_tls_offset;
591+
current_tls_offset += 8*4; /* idk, alignment I guess */
585592
}
586-
x += (size_t)hashmap_get(tls_map, symname);
587593
uintptr_t func = (uintptr_t)&__tlsdesc_static;
588594
memcpy((void *)(table->r_offset + object->base), &func, sizeof(uintptr_t));
589595
memcpy((void *)(table->r_offset + object->base + sizeof(uintptr_t)), &x, sizeof(uintptr_t));

0 commit comments

Comments
 (0)