diff mbox series

[uclibc-ng-devel] Fwd: [PATCH] or1k: fix some TLS issues

Message ID b0c9ef7e-0727-a732-0db1-6e7b0d50ad49@sionneau.net
State New
Headers show
Series [uclibc-ng-devel] Fwd: [PATCH] or1k: fix some TLS issues | expand

Commit Message

Yann Sionneau April 1, 2020, 6:35 a.m. UTC
From: Yann Sionneau <yann@sionneau.net>

Before this commit tst-tls-at-ctor test would segfault.
After it passes.

testsuite run before: https://pastebin.com/504JgQXa
testsuite run after: https://pastebin.com/d2aNciVt

Stafford Horne already fixed it in glibc:
*
https://github.com/openrisc/or1k-glibc/blob/bcd87396ebe78228645c0731b06c934dfd88855a/sysdeps/or1k/dl-machine.h#L298
*
https://github.com/openrisc/or1k-glibc/blob/bcd87396ebe78228645c0731b06c934dfd88855a/sysdeps/or1k/dl-machine.h#L99
---
ldso/ldso/or1k/dl-sysdep.h | 6 ++++--
ldso/ldso/or1k/elfinterp.c | 4 ++--
2 files changed, 6 insertions(+), 4 deletions(-)

#endif
diff mbox series

Patch

diff --git a/ldso/ldso/or1k/dl-sysdep.h b/ldso/ldso/or1k/dl-sysdep.h
index d79249449..d838a50eb 100644
--- a/ldso/ldso/or1k/dl-sysdep.h
+++ b/ldso/ldso/or1k/dl-sysdep.h
@@ -36,8 +36,10 @@  do { \
#define ELF_TARGET "or1k"
#define elf_machine_type_class(type) \
- (((type) == R_OR1K_JMP_SLOT) * ELF_RTYPE_CLASS_PLT \
- | ((type) == R_OR1K_COPY) * ELF_RTYPE_CLASS_COPY)
+ (((type) == R_OR1K_JMP_SLOT || (type) == R_OR1K_TLS_DTPMOD || \
+ (type) == R_OR1K_TLS_DTPOFF || \
+ (type) == R_OR1K_TLS_TPOFF) * ELF_RTYPE_CLASS_PLT \
+ | ((type) == R_OR1K_COPY) * ELF_RTYPE_CLASS_COPY)
static inline Elf32_Addr *
or1k_get_got (void)
diff --git a/ldso/ldso/or1k/elfinterp.c b/ldso/ldso/or1k/elfinterp.c
index 7fd0825ae..6b6589af5 100644
--- a/ldso/ldso/or1k/elfinterp.c
+++ b/ldso/ldso/or1k/elfinterp.c
@@ -249,11 +249,11 @@  _dl_do_reloc(struct elf_resolve *tpnt, struct
r_scope_elem *scope,
*reloc_addr = tls_tpnt->l_tls_modid;
break;
case R_OR1K_TLS_DTPOFF:
- *reloc_addr = symbol_addr;
+ *reloc_addr = symbol_addr + rpnt->r_addend;
break;
case R_OR1K_TLS_TPOFF:
CHECK_STATIC_TLS ((struct link_map *) tls_tpnt);
- *reloc_addr = tls_tpnt->l_tls_offset + symbol_addr + rpnt->r_addend;
+ *reloc_addr = tls_tpnt->l_tls_offset + symbol_addr + rpnt->r_addend -
TLS_TCB_SIZE;
break;