diff options
author | Szabolcs Nagy <nsz@port70.net> | 2019-05-13 18:47:11 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2019-05-16 21:48:39 -0400 |
commit | a60b9e06861e56c0810bae0249b421e1758d281a (patch) | |
tree | 94cfc88638aa6a872e29be5df6690588e5a7275c /src | |
parent | 6104dae9088da7ffd9346671be867a43a4b03295 (diff) | |
download | musl-a60b9e06861e56c0810bae0249b421e1758d281a.tar.gz musl-a60b9e06861e56c0810bae0249b421e1758d281a.tar.bz2 musl-a60b9e06861e56c0810bae0249b421e1758d281a.tar.xz musl-a60b9e06861e56c0810bae0249b421e1758d281a.zip |
fix tls offsets when p_vaddr%p_align != 0 on TLS_ABOVE_TP targets
currently the bfd linker does not seem to create tls segments where
p_vaddr%p_align != 0, but this is valid in ELF and then the runtime
computed tls offset must satisfy
offset%p_align == (base+p_vaddr)%p_align
and in case of local exec tls (main executable) the smallest such
offset must be used (otherwise it is incompatible with the offset
computed by the static linker). the !TLS_ABOVE_TP case is handled
correctly (the offset is negative then in the formula).
the ldso code for TLS_ABOVE_TP is changed so the static tls offset
of each module satisfies the formula.
Diffstat (limited to 'src')
-rw-r--r-- | src/env/__init_tls.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c index 5f12500c..772baba3 100644 --- a/src/env/__init_tls.c +++ b/src/env/__init_tls.c @@ -115,7 +115,8 @@ static void static_init_tls(size_t *aux) & (main_tls.align-1); #ifdef TLS_ABOVE_TP main_tls.offset = GAP_ABOVE_TP; - main_tls.offset += -GAP_ABOVE_TP & (main_tls.align-1); + main_tls.offset += (-GAP_ABOVE_TP + (uintptr_t)main_tls.image) + & (main_tls.align-1); #else main_tls.offset = main_tls.size; #endif |