Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 86b0d3c

Browse files
Merge pull request #2354 from ibuclaw/fixx32
rt.sections_elf_shared: Fix struct tls_index definition on x32
2 parents 652c349 + 03a683a commit 86b0d3c

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/rt/sections_elf_shared.d

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ static if (SharedELF):
2121

2222
// debug = PRINTF;
2323
import core.memory;
24+
import core.stdc.config;
2425
import core.stdc.stdio;
2526
import core.stdc.stdlib : calloc, exit, free, malloc, EXIT_FAILURE;
2627
import core.stdc.string : strlen;
@@ -906,8 +907,27 @@ version (Shared) void* handleForAddr(void* addr) nothrow @nogc
906907
*/
907908
struct tls_index
908909
{
909-
size_t ti_module;
910-
size_t ti_offset;
910+
version (CRuntime_Glibc)
911+
{
912+
// For x86_64, fields are of type uint64_t, this is important for x32
913+
// where tls_index would otherwise have the wrong size.
914+
// See https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86_64/dl-tls.h
915+
version (X86_64)
916+
{
917+
ulong ti_module;
918+
ulong ti_offset;
919+
}
920+
else
921+
{
922+
c_ulong ti_module;
923+
c_ulong ti_offset;
924+
}
925+
}
926+
else
927+
{
928+
size_t ti_module;
929+
size_t ti_offset;
930+
}
911931
}
912932

913933
extern(C) void* __tls_get_addr(tls_index* ti) nothrow @nogc;

0 commit comments

Comments
 (0)