修订版 | db4b12ae6213a28136d7622b74405c6c71c055b0 (tree) |
---|---|
时间 | 2020-04-02 04:43:45 |
作者 | Yann Sionneau <yann@sion...> |
Commiter | Waldemar Brodkorb |
or1k: fix some TLS issues
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
@@ -36,8 +36,10 @@ do { \ | ||
36 | 36 | #define ELF_TARGET "or1k" |
37 | 37 | |
38 | 38 | #define elf_machine_type_class(type) \ |
39 | - (((type) == R_OR1K_JMP_SLOT) * ELF_RTYPE_CLASS_PLT \ | |
40 | - | ((type) == R_OR1K_COPY) * ELF_RTYPE_CLASS_COPY) | |
39 | + (((type) == R_OR1K_JMP_SLOT || (type) == R_OR1K_TLS_DTPMOD || \ | |
40 | + (type) == R_OR1K_TLS_DTPOFF || \ | |
41 | + (type) == R_OR1K_TLS_TPOFF) * ELF_RTYPE_CLASS_PLT \ | |
42 | + | ((type) == R_OR1K_COPY) * ELF_RTYPE_CLASS_COPY) | |
41 | 43 | |
42 | 44 | static inline Elf32_Addr * |
43 | 45 | or1k_get_got (void) |
@@ -249,11 +249,11 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope, | ||
249 | 249 | *reloc_addr = tls_tpnt->l_tls_modid; |
250 | 250 | break; |
251 | 251 | case R_OR1K_TLS_DTPOFF: |
252 | - *reloc_addr = symbol_addr; | |
252 | + *reloc_addr = symbol_addr + rpnt->r_addend; | |
253 | 253 | break; |
254 | 254 | case R_OR1K_TLS_TPOFF: |
255 | 255 | CHECK_STATIC_TLS ((struct link_map *) tls_tpnt); |
256 | - *reloc_addr = tls_tpnt->l_tls_offset + symbol_addr + rpnt->r_addend; | |
256 | + *reloc_addr = tls_tpnt->l_tls_offset + symbol_addr + rpnt->r_addend - TLS_TCB_SIZE; | |
257 | 257 | break; |
258 | 258 | #endif |
259 | 259 |