From: Ryan Prichard <rprichard@google.com>
To: musl@lists.openwall.com
Subject: musl can't handle gold's STB_LOCAL TLS symbols
Date: Thu, 23 May 2019 17:47:13 -0700 [thread overview]
Message-ID: <CALgsJzmgobp3xQKqXXm5_gM8NJ7XM1WeRwbV3T4RVhmS79M=_g@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1767 bytes --]
I noticed that if I use a version script with ld.gold to make a TLS symbol
in a DSO local, the symbol remains in the .dynsym table but with local
binding. Gold emits DTPMOD/DTPOFF relocations to the local TLS symbol, and
when musl tries to load the DSO, it apparently tries to look up the symbol
name globally and fails.
$ cat vers
{
global:
get_tls_var;
local:
*;
};
$ cat dso.c
__thread int tlsvar;
int get_tls_var(void) {
return tlsvar;
}
$ cat main.c
int get_tls_var(void);
int main() {
get_tls_var();
return 0;
}
$ musl-gcc dso.c -fpic -shared -fuse-ld=gold -Wl,-version-script=vers -o
libdso.so
$ musl-gcc main.c libdso.so -Wl,-rpath,'$ORIGIN' -o main
$ ./main
Error relocating /tmp/local-tls-symbol/libdso.so: tlsvar: symbol not found
Error relocating /tmp/local-tls-symbol/libdso.so: tlsvar: symbol not found
$ readelf -rW --dyn-syms libdso.so
...
0000000000001fd8 0000000100000010 R_X86_64_DTPMOD64 0000000000000000
tlsvar + 0
0000000000001fe0 0000000100000011 R_X86_64_DTPOFF64 0000000000000000
tlsvar + 0
...
1: 0000000000000000 4 TLS LOCAL DEFAULT 13 tlsvar
...
The test program works with ld.bfd, because ld.bfd converts the DTPMOD
relocation to 0 and omits the DTPOFF relocation. There was a somewhat
similar issue with gold+musl involving a DTPMOD relocation to a
local section symbol, https://sourceware.org/bugzilla/show_bug.cgi?id=17699.
That issue prompted a thread on the generic-abi group,
https://groups.google.com/d/topic/generic-abi/dJ4_Y78aQ2M/discussion.
I'm wondering if this problem is a bug in musl or gold. I also wonder if
DTPOFF can reference a TLS section, even though the value of a TLS section
symbol isn't suitable for DTPOFF unless it's first adjusted by the
segment's p_vaddr.
-Ryan
[-- Attachment #2: Type: text/html, Size: 2338 bytes --]
next reply other threads:[~2019-05-24 0:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-24 0:47 Ryan Prichard [this message]
2019-05-24 1:12 ` Rich Felker
2019-05-25 9:18 ` Szabolcs Nagy
2019-05-25 16:51 ` Rich Felker
2019-05-25 20:49 ` Szabolcs Nagy
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='CALgsJzmgobp3xQKqXXm5_gM8NJ7XM1WeRwbV3T4RVhmS79M=_g@mail.gmail.com' \
--to=rprichard@google.com \
--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).