From: Fangrui Song <i@maskray.me>
To: musl@lists.openwall.com
Subject: Re: [PATCH] fix tls offsets when p_vaddr%p_align != 0 for TLS_ABOVE_TP
Date: Sat, 18 May 2019 00:01:25 +0800 [thread overview]
Message-ID: <20190517160125.pg4ugmzq66ciqi6r@gmail.com> (raw)
In-Reply-To: <20190517123241.GG16415@port70.net>
On 2019-05-17, Szabolcs Nagy wrote:
>* Rich Felker <dalias@libc.org> [2019-05-16 21:50:43 -0400]:
>> On Fri, May 17, 2019 at 12:51:18AM +0200, Szabolcs Nagy wrote:
>> > + p->tls.offset = tls_offset + ( (p->tls_align-1) &
>> ~~~~~~~~~
>>
>> This should be tls.align. I can fix it up though when applying.
>
>yes, my bad.
I have verified 0001-fix-tls-offsets-when-p_vaddr-p_align-0-for-TLS_ABOVE.patch
With the following lld patch, p_vaddr%p_align!=0, the reproduce program
in https://bugs.llvm.org/show_bug.cgi?id=41527 works.
(a local exec variable defined in executable accessed by another module via `extern __thread int a` (initial exec/generic dynamic))
diff --git i/ELF/InputSection.cpp w/ELF/InputSection.cpp
index 1bf67e2a3..ff365ef0c 100644
--- i/ELF/InputSection.cpp
+++ w/ELF/InputSection.cpp
@@ -594,7 +594,8 @@ static int64_t getTlsTpOffset() {
// NB: While the ARM/AArch64 ABI formally has a 2-word TCB size, lld
// effectively increases the TCB size to 8 words for Android compatibility.
// It accomplishes this by increasing the segment's alignment.
- return alignTo(Config->Wordsize * 2, Out::TlsPhdr->p_align);
+ return alignTo(Config->Wordsize * 2, Out::TlsPhdr->p_align,
+ Out::TlsPhdr->FirstSec->Addr);
case EM_386:
case EM_X86_64:
// Variant 2. The TLS segment is located just before the thread pointer.
(I hope someone can improve my qemu workflow:
qemu-system-aarch64 -M virt -cpu cortex-a57 -nographic -smp 1 -m 2048 -kernel vmlinuz-vanilla -initrd initramfs-vanilla -append "console=ttyAMA0 ip=dhcp alpine_repo=http://dl-cdn.alpinelinux.org/alpine/edge/main")
prev parent reply other threads:[~2019-05-17 16:01 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
2019-05-17 12:32 ` Szabolcs Nagy
2019-05-17 16:01 ` Fangrui Song [this message]
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=20190517160125.pg4ugmzq66ciqi6r@gmail.com \
--to=i@maskray.me \
--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).