From c8bf00572595139cc763455d4555ee1c34e48794 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Oct 17 2017 23:15:05 +0000 Subject: Implement static TLS code for more platforms Add valgrind-3.13.0-static-tls.patch --- diff --git a/valgrind-3.13.0-static-tls.patch b/valgrind-3.13.0-static-tls.patch new file mode 100644 index 0000000..578a3c5 --- /dev/null +++ b/valgrind-3.13.0-static-tls.patch @@ -0,0 +1,81 @@ +commit f1ff8597ef9c37ff1a853411b9e3be1696c36d92 +Author: Philippe Waroquiers +Date: Tue Sep 19 23:17:48 2017 +0200 + + Implement static TLS code for more platforms + + gdbserver_tests/hgtls is failing on a number of platforms + as it looks like static tls handling is now needed. + So, omplement static tls for a few more platforms. + The formulas that are platform dependent are somewhat wild guesses + obtained with trial and errors. + Note that arm/arm64/ppc32 are not (yet) done + +diff --git a/coregrind/m_gdbserver/target.c b/coregrind/m_gdbserver/target.c +index 10e52fc..1f03c12 100644 +--- a/coregrind/m_gdbserver/target.c ++++ b/coregrind/m_gdbserver/target.c +@@ -712,6 +712,7 @@ Bool valgrind_get_tls_addr (ThreadState *tst, + // Check we can read the modid + CHECK_DEREF(lm+lm_modid_offset, sizeof(unsigned long int), "link_map modid"); + modid = *(unsigned long int *)(lm+lm_modid_offset); ++ dlog (2, "tid %u modid %lu\n", tst->tid, modid); + + // Check we can access the dtv entry for modid + CHECK_DEREF(dtv + 2 * modid, sizeof(CORE_ADDR), "dtv[2*modid]"); +@@ -719,7 +720,6 @@ Bool valgrind_get_tls_addr (ThreadState *tst, + // Compute the base address of the tls block. + *tls_addr = *(dtv + 2 * modid); + +-#if defined(VGA_mips32) || defined(VGA_mips64) + if (*tls_addr & 1) { + /* This means that computed address is not valid, most probably + because given module uses Static TLS. +@@ -731,17 +731,24 @@ Bool valgrind_get_tls_addr (ThreadState *tst, + CORE_ADDR tls_offset_addr; + PtrdiffT tls_offset; + +- dlog(1, "computing tls_addr using static TLS\n"); ++ dlog(2, "tls_addr (%p & 1) => computing tls_addr using static TLS\n", ++ (void*) *tls_addr); + + /* Assumes that tls_offset is placed right before tls_modid. + To check the assumption, start a gdb on none/tests/tls and do: +- p &((struct link_map*)0x0)->l_tls_modid +- p &((struct link_map*)0x0)->l_tls_offset */ ++ p &((struct link_map*)0x0)->l_tls_modid ++ p &((struct link_map*)0x0)->l_tls_offset ++ Instead of assuming this, we could calculate this similarly to ++ lm_modid_offset, by extending getplatformoffset to support querying ++ more than one offset. ++ */ + tls_offset_addr = lm + lm_modid_offset - sizeof(PtrdiffT); + + // Check we can read the tls_offset. + CHECK_DEREF(tls_offset_addr, sizeof(PtrdiffT), "link_map tls_offset"); + tls_offset = *(PtrdiffT *)(tls_offset_addr); ++ dlog(2, "tls_offset_addr %p tls_offset %ld\n", ++ (void*)tls_offset_addr, (long)tls_offset); + + /* Following two values represent platform dependent constants + NO_TLS_OFFSET and FORCED_DYNAMIC_TLS_OFFSET, respectively. */ +@@ -751,9 +758,18 @@ Bool valgrind_get_tls_addr (ThreadState *tst, + } + + // This calculation is also platform dependent. ++#if defined(VGA_mips32) || defined(VGA_mips64) + *tls_addr = ((CORE_ADDR)dtv_loc + 2 * sizeof(CORE_ADDR) + tls_offset); +- } ++#elif defined(VGA_ppc64be) || defined(VGA_ppc64le) ++ *tls_addr = ((CORE_ADDR)dtv_loc + sizeof(CORE_ADDR) + tls_offset); ++#elif defined(VGA_x86) || defined(VGA_amd64) || defined(VGA_s390x) ++ *tls_addr = (CORE_ADDR)dtv_loc - tls_offset - sizeof(CORE_ADDR); ++#else ++ // ppc32, arm, arm64 ++ dlog(0, "target.c is missing platform code for static TLS\n"); ++ return False; + #endif ++ } + + // Finally, add tls variable offset to tls block base address. + *tls_addr += offset; diff --git a/valgrind.spec b/valgrind.spec index f6b7ee4..0ac843a 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -138,6 +138,12 @@ Patch13: valgrind-3.13.0-ppc64-vex-fixes.patch # Fix eflags handling in amd64 instruction tests Patch14: valgrind-3.13.0-amd64-eflags-tests.patch +# KDE#385868 ld.so _dl_runtime_resolve_avx_slow conditional jump warning +Patch15: valgrind-3.13.0-suppress-dl-trampoline-sse-avx.patch + +# Implement static TLS code for more platforms +Patch16: valgrind-3.13.0-static-tls.patch + %if %{build_multilib} # Ensure glibc{,-devel} is installed for both multilib arches BuildRequires: /lib/libc.so.6 /usr/lib/libc.so /lib64/libc.so.6 /usr/lib64/libc.so @@ -266,6 +272,8 @@ Valgrind User Manual for details. %patch12 -p1 %patch13 -p1 %patch14 -p1 +%patch15 -p1 +%patch16 -p1 %build # We need to use the software collection compiler and binutils if available. @@ -470,6 +478,8 @@ echo ===============END TESTING=============== %changelog * Tue Oct 17 2017 Mark Wielaard - Add valgrind-3.13.0-amd64-eflags-tests.patch +- Add valgrind-3.13.0-suppress-dl-trampoline-sse-avx.patch +- Add valgrind-3.13.0-static-tls.patch * Mon Oct 16 2017 Mark Wielaard - 3.13.0-8 - Add valgrind-3.13.0-ppc64-vex-fixes.patch