From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] fix tls offsets when p_vaddr%p_align != 0 for TLS_ABOVE_TP
Date: Thu, 16 May 2019 21:50:43 -0400 [thread overview]
Message-ID: <20190517015043.GA23599@brightrain.aerifal.cx> (raw)
In-Reply-To: <20190516225117.GF16415@port70.net>
On Fri, May 17, 2019 at 12:51:18AM +0200, Szabolcs Nagy wrote:
> * Rich Felker <dalias@libc.org> [2019-05-16 09:22:46 -0400]:
> > > i can make the tls_offset fix a separate change from
> > > the p_vaddr%p_align!=0 fix.
> >
> > I'd like that, both because it was non-obvious to me that this was
> > another major change, and because it fixes a separate, major
> > user-facing bug (this is what was breaking rust, and could break lots
> > of other things) rather than the new issue with lld's Bionic hack.
>
> ok
Thanks!
> From 28dd0b581b4d8b0903447b5e169155f11be94cf7 Mon Sep 17 00:00:00 2001
> From: Szabolcs Nagy <nsz@port70.net>
> Date: Mon, 13 May 2019 18:47:11 +0000
> Subject: [PATCH 2/2] 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.
> ---
> ldso/dynlink.c | 7 ++++---
> src/env/__init_tls.c | 3 ++-
> 2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/ldso/dynlink.c b/ldso/dynlink.c
> index 566b69e6..f9a7cc06 100644
> --- a/ldso/dynlink.c
> +++ b/ldso/dynlink.c
> @@ -1126,8 +1126,8 @@ static struct dso *load_library(const char *name, struct dso *needed_by)
> p->tls_id = ++tls_cnt;
> tls_align = MAXP2(tls_align, p->tls.align);
> #ifdef TLS_ABOVE_TP
> - p->tls.offset = tls_offset + ( (tls_align-1) &
> - -(tls_offset + (uintptr_t)p->tls.image) );
> + p->tls.offset = tls_offset + ( (p->tls_align-1) &
~~~~~~~~~
This should be tls.align. I can fix it up though when applying.
Rich
next prev parent reply other threads:[~2019-05-17 1:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-14 2:01 Szabolcs Nagy
2019-05-16 0:20 ` Rich Felker
2019-05-16 7:48 ` Szabolcs Nagy
2019-05-16 13:22 ` Rich Felker
2019-05-16 22:51 ` Szabolcs Nagy
2019-05-17 1:50 ` Rich Felker [this message]
2019-05-17 12:32 ` Szabolcs Nagy
2019-05-17 16:01 ` Fangrui Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190517015043.GA23599@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).