Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Thu, 23 May 2019 17:47:13 -0700
From: Ryan Prichard <>
Subject: musl can't handle gold's STB_LOCAL TLS symbols

I noticed that if I use a version script with 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

$ cat dso.c
__thread int tlsvar;
int get_tls_var(void) {
  return tlsvar;

$ cat main.c
int get_tls_var(void);
int main() {
  return 0;

$ musl-gcc dso.c -fpic -shared -fuse-ld=gold -Wl,-version-script=vers -o
$ musl-gcc main.c -Wl,-rpath,'$ORIGIN' -o main
$ ./main
Error relocating /tmp/local-tls-symbol/ tlsvar: symbol not found
Error relocating /tmp/local-tls-symbol/ tlsvar: symbol not found

$ readelf -rW --dyn-syms
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,
That issue prompted a thread on the generic-abi group,

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.


Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.