From 953cba365fa4d5267d30fcb8221d6e9acfdec4ac Mon Sep 17 00:00:00 2001 From: Andreas Tobler Date: Mon, 1 Oct 2018 18:46:35 +0000 Subject: [PATCH] This commit reverts 338930. The approach was wrong. Fix the issue with subtracting the TLS_TCB_SIZE too when we are trying to get the 'where' in the R_PPC_TPREL32 case. At allocation time we added an offset and the TLS_TCB_SIZE. This has to be subtracted as well. Now all the issues reported are fixed. Tests were done on G4 and G5 PowerMac's. Additionally I ran the tls tests from the gcc test suite and made sure the results are as good as pre 338486. Thanks to tuexen for reporting the malfunction and for patient testing. Also testing thanks goes to jhibbits. Reported by: tuexen Discussed with: jhibbits, nwhitehorn Approved by: re (gjb) Pointyhat to: andreast --- libexec/rtld-elf/powerpc/reloc.c | 2 +- libexec/rtld-elf/powerpc/rtld_machdep.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libexec/rtld-elf/powerpc/reloc.c b/libexec/rtld-elf/powerpc/reloc.c index 09c305089c19..3c157b23f2fa 100644 --- a/libexec/rtld-elf/powerpc/reloc.c +++ b/libexec/rtld-elf/powerpc/reloc.c @@ -258,7 +258,7 @@ reloc_nonplt_object(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela, *(Elf_Addr **)where = *where * sizeof(Elf_Addr) + (Elf_Addr *)(def->st_value + rela->r_addend - + defobj->tlsoffset - TLS_TP_OFFSET); + + defobj->tlsoffset - TLS_TP_OFFSET - TLS_TCB_SIZE); break; diff --git a/libexec/rtld-elf/powerpc/rtld_machdep.h b/libexec/rtld-elf/powerpc/rtld_machdep.h index 4e7854d34661..c89ec4817401 100644 --- a/libexec/rtld-elf/powerpc/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc/rtld_machdep.h @@ -69,12 +69,12 @@ void _rtld_powerpc_pltcall(void); #define TLS_TP_OFFSET 0x7000 #define TLS_DTV_OFFSET 0x8000 -#define TLS_TCB_SIZE 16 +#define TLS_TCB_SIZE 8 #define round(size, align) \ (((size) + (align) - 1) & ~((align) - 1)) #define calculate_first_tls_offset(size, align) \ - round(8, align) + TLS_TCB_SIZE #define calculate_tls_offset(prev_offset, prev_size, size, align) \ round(prev_offset + prev_size, align) #define calculate_tls_end(off, size) ((off) + (size))