summaryrefslogtreecommitdiff
path: root/libpthread/nptl/sysdeps/generic
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@st.com>2018-07-04 17:55:34 +0200
committerWaldemar Brodkorb <wbrodkorb@conet.de>2018-08-10 16:02:45 +0200
commit7f07872b8aea16611890865700fbfefd586bc1fb (patch)
treebd734164cf522b2b6950d90338d48b7d21789845 /libpthread/nptl/sysdeps/generic
parent4d6b4178c8e49dd6d3067a399e2a49d5379b7750 (diff)
nptl: Use linker-defined symbol to find start of .tdata section.
phdr->p_vaddr of TLS segment is not a valid value for FDPIC so we can either translate phdr->p_vaddr using loadmap (not easy here) or use a new linker script defined symbol, whih this patch does. * libpthread/nptl/sysdeps/generic/libc-tls.c (__tdata_start): Declare. (__libc_setup_tls): Support __FDPIC__. Signed-off-by: Mickaël Guêné <mickael.guene@st.com> Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Diffstat (limited to 'libpthread/nptl/sysdeps/generic')
-rw-r--r--libpthread/nptl/sysdeps/generic/libc-tls.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libpthread/nptl/sysdeps/generic/libc-tls.c b/libpthread/nptl/sysdeps/generic/libc-tls.c
index 58e77ff10..725f3dfc7 100644
--- a/libpthread/nptl/sysdeps/generic/libc-tls.c
+++ b/libpthread/nptl/sysdeps/generic/libc-tls.c
@@ -36,6 +36,11 @@
extern ElfW(Phdr) *_dl_phdr;
extern size_t _dl_phnum;
+#ifdef __FDPIC__
+/* phdr->p_vaddr is not valid in FDPIC mode. To find tdata start we
+ use the linker script defined symbol __tdata_start. */
+extern int __tdata_start;
+#endif
static dtv_t static_dtv[2 + TLS_SLOTINFO_SURPLUS];
@@ -130,7 +135,11 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
/* Remember the values we need. */
memsz = phdr->p_memsz;
filesz = phdr->p_filesz;
+#ifdef __FDPIC__
+ initimage = (void *) &__tdata_start;
+#else
initimage = (void *) phdr->p_vaddr;
+#endif
align = phdr->p_align;
if (phdr->p_align > max_align)
max_align = phdr->p_align;