diff --git a/SOURCES/valgrind-3.13.0-arm64-hwcap.patch b/SOURCES/valgrind-3.13.0-arm64-hwcap.patch index 8f2a070..676b647 100644 --- a/SOURCES/valgrind-3.13.0-arm64-hwcap.patch +++ b/SOURCES/valgrind-3.13.0-arm64-hwcap.patch @@ -1,17 +1,79 @@ +commit 6bb6c8a65a341a67bd059ec6e1c805813eb17264 +Author: Mark Wielaard +Date: Tue Jun 19 18:00:45 2018 +0200 + + Mask AT_HWCAPS on arm64 to those instructions VEX implements. + + This patch makes sure that the process running under valgrind only sees + the AES, PMULL, SHA1, SHA2, CRC32, FP, and ASIMD features in auxv AT_HWCAPS. + + https://bugs.kde.org/show_bug.cgi?id=381556 + diff --git a/coregrind/m_initimg/initimg-linux.c b/coregrind/m_initimg/initimg-linux.c -index 30e1f85..387beae 100644 +index 30e1f85..61cc458 100644 --- a/coregrind/m_initimg/initimg-linux.c +++ b/coregrind/m_initimg/initimg-linux.c -@@ -703,6 +703,12 @@ Addr setup_client_stack( void* init_sp, +@@ -703,6 +703,19 @@ Addr setup_client_stack( void* init_sp, (and anything above) are not supported by Valgrind. */ auxv->u.a_val &= VKI_HWCAP_S390_TE - 1; } +# elif defined(VGP_arm64_linux) + { -+ /* Linux 4.11 started pupulating this for arm64, but we -+ currently don't support any. */ -+ auxv->u.a_val = 0; ++ /* Limit the AT_HWCAP to just those features we explicitly ++ support in VEX. */ ++#define ARM64_SUPPORTED_HWCAP (VKI_HWCAP_AES \ ++ | VKI_HWCAP_PMULL \ ++ | VKI_HWCAP_SHA1 \ ++ | VKI_HWCAP_SHA2 \ ++ | VKI_HWCAP_CRC32 \ ++ | VKI_HWCAP_FP \ ++ | VKI_HWCAP_ASIMD) ++ auxv->u.a_val &= ARM64_SUPPORTED_HWCAP; + } # endif break; # if defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux) +diff --git a/include/vki/vki-arm64-linux.h b/include/vki/vki-arm64-linux.h +index af6b435..54b0428 100644 +--- a/include/vki/vki-arm64-linux.h ++++ b/include/vki/vki-arm64-linux.h +@@ -692,6 +692,39 @@ struct vki_shminfo64 { + #define VKI_TIOCSSERIAL 0x541F + + //---------------------------------------------------------------------- ++// From linux-4.17/include/uapi/asm-generic/ioctls.h ++//---------------------------------------------------------------------- ++ ++#define VKI_HWCAP_FP (1 << 0) ++#define VKI_HWCAP_ASIMD (1 << 1) ++#define VKI_HWCAP_EVTSTRM (1 << 2) ++#define VKI_HWCAP_AES (1 << 3) ++#define VKI_HWCAP_PMULL (1 << 4) ++#define VKI_HWCAP_SHA1 (1 << 5) ++#define VKI_HWCAP_SHA2 (1 << 6) ++#define VKI_HWCAP_CRC32 (1 << 7) ++#define VKI_HWCAP_ATOMICS (1 << 8) ++#define VKI_HWCAP_FPHP (1 << 9) ++#define VKI_HWCAP_ASIMDHP (1 << 10) ++#define VKI_HWCAP_CPUID (1 << 11) ++#define VKI_HWCAP_ASIMDRDM (1 << 12) ++#define VKI_HWCAP_JSCVT (1 << 13) ++#define VKI_HWCAP_FCMA (1 << 14) ++#define VKI_HWCAP_LRCPC (1 << 15) ++#define VKI_HWCAP_DCPOP (1 << 16) ++#define VKI_HWCAP_SHA3 (1 << 17) ++#define VKI_HWCAP_SM3 (1 << 18) ++#define VKI_HWCAP_SM4 (1 << 19) ++#define VKI_HWCAP_ASIMDDP (1 << 20) ++#define VKI_HWCAP_SHA512 (1 << 21) ++#define VKI_HWCAP_SVE (1 << 22) ++#define VKI_HWCAP_ASIMDFHM (1 << 23) ++#define VKI_HWCAP_DIT (1 << 24) ++#define VKI_HWCAP_USCAT (1 << 25) ++#define VKI_HWCAP_ILRCPC (1 << 26) ++#define VKI_HWCAP_FLAGM (1 << 27) ++ ++//---------------------------------------------------------------------- + // And that's it! + //---------------------------------------------------------------------- + diff --git a/SOURCES/valgrind-3.13.0-arm64-ptrace.patch b/SOURCES/valgrind-3.13.0-arm64-ptrace.patch new file mode 100644 index 0000000..6ac1a44 --- /dev/null +++ b/SOURCES/valgrind-3.13.0-arm64-ptrace.patch @@ -0,0 +1,235 @@ +commit 122225d7ed260f6bd9de4472e5260ec768ce972d +Author: Mark Wielaard +Date: Tue Jun 19 18:26:43 2018 +0200 + + Implement ptrace syscall wrapper for arm64-linux. + + With this valgrind is able to run gdb on arm64. + Also fixes the memcheck/tests/linux/getregset testcase. + + https://bugs.kde.org/show_bug.cgi?id=368913 + +diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c +index 32b87bf..24a6493 100644 +--- a/coregrind/m_syswrap/syswrap-arm64-linux.c ++++ b/coregrind/m_syswrap/syswrap-arm64-linux.c +@@ -265,7 +265,7 @@ DECL_TEMPLATE(arm64_linux, sys_rt_sigreturn); + //ZZ DECL_TEMPLATE(arm_linux, sys_sigsuspend); + //ZZ DECL_TEMPLATE(arm_linux, sys_set_tls); + //ZZ DECL_TEMPLATE(arm_linux, sys_cacheflush); +-//ZZ DECL_TEMPLATE(arm_linux, sys_ptrace); ++DECL_TEMPLATE(arm64_linux, sys_ptrace); + + //ZZ PRE(sys_mmap2) + //ZZ { +@@ -459,137 +459,70 @@ PRE(sys_rt_sigreturn) + //ZZ "PRE(sys_cacheflush)" ); + //ZZ SET_STATUS_Success(0); + //ZZ } +-//ZZ +-//ZZ // ARG3 is only used for pointers into the traced process's address +-//ZZ // space and for offsets into the traced process's struct +-//ZZ // user_regs_struct. It is never a pointer into this process's memory +-//ZZ // space, and we should therefore not check anything it points to. +-//ZZ PRE(sys_ptrace) +-//ZZ { +-//ZZ PRINT("sys_ptrace ( %ld, %ld, %#lx, %#lx )", ARG1,ARG2,ARG3,ARG4); +-//ZZ PRE_REG_READ4(int, "ptrace", +-//ZZ long, request, long, pid, long, addr, long, data); +-//ZZ switch (ARG1) { +-//ZZ case VKI_PTRACE_PEEKTEXT: +-//ZZ case VKI_PTRACE_PEEKDATA: +-//ZZ case VKI_PTRACE_PEEKUSR: +-//ZZ PRE_MEM_WRITE( "ptrace(peek)", ARG4, +-//ZZ sizeof (long)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETREGS: +-//ZZ PRE_MEM_WRITE( "ptrace(getregs)", ARG4, +-//ZZ sizeof (struct vki_user_regs_struct)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETFPREGS: +-//ZZ PRE_MEM_WRITE( "ptrace(getfpregs)", ARG4, +-//ZZ sizeof (struct vki_user_fp)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETWMMXREGS: +-//ZZ PRE_MEM_WRITE( "ptrace(getwmmxregs)", ARG4, +-//ZZ VKI_IWMMXT_SIZE); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETCRUNCHREGS: +-//ZZ PRE_MEM_WRITE( "ptrace(getcrunchregs)", ARG4, +-//ZZ VKI_CRUNCH_SIZE); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETVFPREGS: +-//ZZ PRE_MEM_WRITE( "ptrace(getvfpregs)", ARG4, +-//ZZ sizeof (struct vki_user_vfp) ); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETHBPREGS: +-//ZZ PRE_MEM_WRITE( "ptrace(gethbpregs)", ARG4, +-//ZZ sizeof (unsigned long) ); +-//ZZ break; +-//ZZ case VKI_PTRACE_SETREGS: +-//ZZ PRE_MEM_READ( "ptrace(setregs)", ARG4, +-//ZZ sizeof (struct vki_user_regs_struct)); +-//ZZ break; +-//ZZ case VKI_PTRACE_SETFPREGS: +-//ZZ PRE_MEM_READ( "ptrace(setfpregs)", ARG4, +-//ZZ sizeof (struct vki_user_fp)); +-//ZZ break; +-//ZZ case VKI_PTRACE_SETWMMXREGS: +-//ZZ PRE_MEM_READ( "ptrace(setwmmxregs)", ARG4, +-//ZZ VKI_IWMMXT_SIZE); +-//ZZ break; +-//ZZ case VKI_PTRACE_SETCRUNCHREGS: +-//ZZ PRE_MEM_READ( "ptrace(setcrunchregs)", ARG4, +-//ZZ VKI_CRUNCH_SIZE); +-//ZZ break; +-//ZZ case VKI_PTRACE_SETVFPREGS: +-//ZZ PRE_MEM_READ( "ptrace(setvfpregs)", ARG4, +-//ZZ sizeof (struct vki_user_vfp)); +-//ZZ break; +-//ZZ case VKI_PTRACE_SETHBPREGS: +-//ZZ PRE_MEM_READ( "ptrace(sethbpregs)", ARG4, sizeof(unsigned long)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GET_THREAD_AREA: +-//ZZ PRE_MEM_WRITE( "ptrace(get_thread_area)", ARG4, sizeof(unsigned long)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETEVENTMSG: +-//ZZ PRE_MEM_WRITE( "ptrace(geteventmsg)", ARG4, sizeof(unsigned long)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETSIGINFO: +-//ZZ PRE_MEM_WRITE( "ptrace(getsiginfo)", ARG4, sizeof(vki_siginfo_t)); +-//ZZ break; +-//ZZ case VKI_PTRACE_SETSIGINFO: +-//ZZ PRE_MEM_READ( "ptrace(setsiginfo)", ARG4, sizeof(vki_siginfo_t)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETREGSET: +-//ZZ ML_(linux_PRE_getregset)(tid, ARG3, ARG4); +-//ZZ break; +-//ZZ case VKI_PTRACE_SETREGSET: +-//ZZ ML_(linux_PRE_setregset)(tid, ARG3, ARG4); +-//ZZ break; +-//ZZ default: +-//ZZ break; +-//ZZ } +-//ZZ } +-//ZZ +-//ZZ POST(sys_ptrace) +-//ZZ { +-//ZZ switch (ARG1) { +-//ZZ case VKI_PTRACE_PEEKTEXT: +-//ZZ case VKI_PTRACE_PEEKDATA: +-//ZZ case VKI_PTRACE_PEEKUSR: +-//ZZ POST_MEM_WRITE( ARG4, sizeof (long)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETREGS: +-//ZZ POST_MEM_WRITE( ARG4, sizeof (struct vki_user_regs_struct)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETFPREGS: +-//ZZ POST_MEM_WRITE( ARG4, sizeof (struct vki_user_fp)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETWMMXREGS: +-//ZZ POST_MEM_WRITE( ARG4, VKI_IWMMXT_SIZE); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETCRUNCHREGS: +-//ZZ POST_MEM_WRITE( ARG4, VKI_CRUNCH_SIZE); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETVFPREGS: +-//ZZ POST_MEM_WRITE( ARG4, sizeof(struct vki_user_vfp)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GET_THREAD_AREA: +-//ZZ case VKI_PTRACE_GETHBPREGS: +-//ZZ case VKI_PTRACE_GETEVENTMSG: +-//ZZ POST_MEM_WRITE( ARG4, sizeof(unsigned long)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETSIGINFO: +-//ZZ /* XXX: This is a simplification. Different parts of the +-//ZZ * siginfo_t are valid depending on the type of signal. +-//ZZ */ +-//ZZ POST_MEM_WRITE( ARG4, sizeof(vki_siginfo_t)); +-//ZZ break; +-//ZZ case VKI_PTRACE_GETREGSET: +-//ZZ ML_(linux_POST_getregset)(tid, ARG3, ARG4); +-//ZZ break; +-//ZZ default: +-//ZZ break; +-//ZZ } +-//ZZ } +-//ZZ +-//ZZ #undef PRE +-//ZZ #undef POST ++ ++// ARG3 is only used for pointers into the traced process's address ++// space and for offsets into the traced process's struct ++// user_regs_struct. It is never a pointer into this process's memory ++// space, and we should therefore not check anything it points to. ++PRE(sys_ptrace) ++{ ++ PRINT("sys_ptrace ( %ld, %ld, %#lx, %#lx )", ARG1,ARG2,ARG3,ARG4); ++ PRE_REG_READ4(int, "ptrace", ++ long, request, long, pid, long, addr, long, data); ++ switch (ARG1) { ++ case VKI_PTRACE_PEEKTEXT: ++ case VKI_PTRACE_PEEKDATA: ++ case VKI_PTRACE_PEEKUSR: ++ PRE_MEM_WRITE( "ptrace(peek)", ARG4, ++ sizeof (long)); ++ break; ++ case VKI_PTRACE_GETEVENTMSG: ++ PRE_MEM_WRITE( "ptrace(geteventmsg)", ARG4, sizeof(unsigned long)); ++ break; ++ case VKI_PTRACE_GETSIGINFO: ++ PRE_MEM_WRITE( "ptrace(getsiginfo)", ARG4, sizeof(vki_siginfo_t)); ++ break; ++ case VKI_PTRACE_SETSIGINFO: ++ PRE_MEM_READ( "ptrace(setsiginfo)", ARG4, sizeof(vki_siginfo_t)); ++ break; ++ case VKI_PTRACE_GETREGSET: ++ ML_(linux_PRE_getregset)(tid, ARG3, ARG4); ++ break; ++ case VKI_PTRACE_SETREGSET: ++ ML_(linux_PRE_setregset)(tid, ARG3, ARG4); ++ break; ++ default: ++ break; ++ } ++} ++ ++POST(sys_ptrace) ++{ ++ switch (ARG1) { ++ case VKI_PTRACE_PEEKTEXT: ++ case VKI_PTRACE_PEEKDATA: ++ case VKI_PTRACE_PEEKUSR: ++ POST_MEM_WRITE( ARG4, sizeof (long)); ++ break; ++ case VKI_PTRACE_GETEVENTMSG: ++ POST_MEM_WRITE( ARG4, sizeof(unsigned long)); ++ break; ++ case VKI_PTRACE_GETSIGINFO: ++ /* XXX: This is a simplification. Different parts of the ++ * siginfo_t are valid depending on the type of signal. ++ */ ++ POST_MEM_WRITE( ARG4, sizeof(vki_siginfo_t)); ++ break; ++ case VKI_PTRACE_GETREGSET: ++ ML_(linux_POST_getregset)(tid, ARG3, ARG4); ++ break; ++ default: ++ break; ++ } ++} ++ ++#undef PRE ++#undef POST + + /* --------------------------------------------------------------------- + The arm64/Linux syscall table +@@ -730,7 +663,7 @@ static SyscallTableEntry syscall_main_table[] = { + LINXY(__NR_clock_getres, sys_clock_getres), // 114 + LINXY(__NR_clock_nanosleep, sys_clock_nanosleep), // 115 + LINXY(__NR_syslog, sys_syslog), // 116 +- // (__NR_ptrace, sys_ptrace), // 117 ++ PLAXY(__NR_ptrace, sys_ptrace), // 117 + LINXY(__NR_sched_setparam, sys_sched_setparam), // 118 + LINX_(__NR_sched_setscheduler,sys_sched_setscheduler),// 119 + LINX_(__NR_sched_getscheduler,sys_sched_getscheduler),// 120 diff --git a/SOURCES/valgrind-3.13.0-build-id-phdrs.patch b/SOURCES/valgrind-3.13.0-build-id-phdrs.patch new file mode 100644 index 0000000..6a0a9df --- /dev/null +++ b/SOURCES/valgrind-3.13.0-build-id-phdrs.patch @@ -0,0 +1,17 @@ +diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c +index 70c28e629..8bd3e049c 100644 +--- a/coregrind/m_debuginfo/readelf.c ++++ b/coregrind/m_debuginfo/readelf.c +@@ -1137,7 +1137,11 @@ HChar* find_buildid(DiImage* img, Bool rel_ok, Bool search_shdrs) + + ElfXX_Ehdr ehdr; + ML_(img_get)(&ehdr, img, 0, sizeof(ehdr)); +- for (i = 0; i < ehdr.e_phnum; i++) { ++ /* Skip the phdrs when we have to search the shdrs. In separate ++ .debug files the phdrs might not be valid (they are a copy of ++ the main ELF file) and might trigger assertions when getting ++ image notes based on them. */ ++ for (i = 0; !search_shdrs && i < ehdr.e_phnum; i++) { + ElfXX_Phdr phdr; + ML_(img_get)(&phdr, img, + ehdr.e_phoff + i * ehdr.e_phentsize, sizeof(phdr)); diff --git a/SOURCES/valgrind-3.13.0-debug-alt-file.patch b/SOURCES/valgrind-3.13.0-debug-alt-file.patch new file mode 100644 index 0000000..9176bb1 --- /dev/null +++ b/SOURCES/valgrind-3.13.0-debug-alt-file.patch @@ -0,0 +1,160 @@ +commit be82bb5f9dfecd854c53eda321d1914f28f19790 +Author: Mark Wielaard +Date: Sat Dec 9 23:01:29 2017 +0100 + + Fix gnu debug alt file resolving. + + https://bugs.kde.org/show_bug.cgi?id=387773 + + The path to the alt file is relative to the actual debug file. + Make sure that we got the real file, not a (build-id) symlink. + Also handle the case where a debug or alt file is an absolute path. + +diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c +index e612250..c19ff21 100644 +--- a/coregrind/m_debuginfo/readelf.c ++++ b/coregrind/m_debuginfo/readelf.c +@@ -33,6 +33,7 @@ + + #include "pub_core_basics.h" + #include "pub_core_vki.h" ++#include "pub_core_vkiscnums.h" + #include "pub_core_debuginfo.h" + #include "pub_core_libcbase.h" + #include "pub_core_libcprint.h" +@@ -40,6 +41,7 @@ + #include "pub_core_machine.h" /* VG_ELF_CLASS */ + #include "pub_core_options.h" + #include "pub_core_oset.h" ++#include "pub_core_syscall.h" + #include "pub_core_tooliface.h" /* VG_(needs) */ + #include "pub_core_xarray.h" + #include "priv_misc.h" /* dinfo_zalloc/free/strdup */ +@@ -1323,6 +1325,12 @@ DiImage* find_debug_file( struct _DebugInfo* di, + + (extrapath ? VG_(strlen)(extrapath) : 0) + + (serverpath ? VG_(strlen)(serverpath) : 0)); + ++ if (debugname[0] == '/') { ++ VG_(sprintf)(debugpath, "%s", debugname); ++ dimg = open_debug_file(debugpath, buildid, crc, rel_ok, NULL); ++ if (dimg != NULL) goto dimg_ok; ++ } ++ + VG_(sprintf)(debugpath, "%s/%s", objdir, debugname); + dimg = open_debug_file(debugpath, buildid, crc, rel_ok, NULL); + if (dimg != NULL) goto dimg_ok; +@@ -1527,6 +1535,56 @@ static Bool check_compression(ElfXX_Shdr* h, DiSlice* s) { + return True; + } + ++/* Helper function to get the readlink path. Returns a copy of path if the ++ file wasn't a symbolic link. Returns NULL on error. Unless NULL is ++ returned the result needs to be released with dinfo_free. ++*/ ++static HChar* readlink_path (const HChar *path) ++{ ++ SizeT bufsiz = VG_(strlen)(path); ++ HChar *buf = ML_(dinfo_strdup)("readlink_path.strdup", path); ++ UInt tries = 6; ++ ++ while (tries > 0) { ++ SysRes res; ++#if defined(VGP_arm64_linux) ++ res = VG_(do_syscall4)(__NR_readlinkat, VKI_AT_FDCWD, ++ (UWord)path, (UWord)buf, bufsiz); ++#elif defined(VGO_linux) || defined(VGO_darwin) ++ res = VG_(do_syscall3)(__NR_readlink, (UWord)path, (UWord)buf, bufsiz); ++#elif defined(VGO_solaris) ++ res = VG_(do_syscall4)(__NR_readlinkat, VKI_AT_FDCWD, (UWord)path, ++ (UWord)buf, bufsiz); ++#else ++# error Unknown OS ++#endif ++ if (sr_isError(res)) { ++ if (sr_Err(res) == VKI_EINVAL) ++ return buf; // It wasn't a symbolic link, return the strdup result. ++ ML_(dinfo_free)(buf); ++ return NULL; ++ } ++ ++ SSizeT r = sr_Res(res); ++ if (r < 0) break; ++ if (r == bufsiz) { // buffer too small; increase and retry ++ bufsiz *= 2 + 16; ++ buf = ML_(dinfo_realloc)("readlink_path.realloc", buf, bufsiz); ++ tries--; ++ continue; ++ } ++ buf[r] = '\0'; ++ break; ++ } ++ ++ if (tries == 0) { // We tried, but weird long path? ++ ML_(dinfo_free)(buf); ++ return NULL; ++ } ++ ++ return buf; ++} ++ + /* The central function for reading ELF debug info. For the + object/exe specified by the DebugInfo, find ELF sections, then read + the symbols, line number info, file name info, CFA (stack-unwind +@@ -2926,8 +2984,12 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) + (debugaltlink_escn.szB - buildid_offset) + * 2 + 1); + +- /* The altfile might be relative to the debug file or main file. */ ++ /* The altfile might be relative to the debug file or main file. ++ Make sure that we got the real file, not a symlink. */ + HChar *dbgname = di->fsm.dbgname ? di->fsm.dbgname : di->fsm.filename; ++ HChar* rdbgname = readlink_path (dbgname); ++ if (rdbgname == NULL) ++ rdbgname = ML_(dinfo_strdup)("rdbgname", dbgname); + + for (j = 0; j < debugaltlink_escn.szB - buildid_offset; j++) + VG_(sprintf)( +@@ -2937,9 +2999,11 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) + + buildid_offset + j)); + + /* See if we can find a matching debug file */ +- aimg = find_debug_file( di, dbgname, altbuildid, ++ aimg = find_debug_file( di, rdbgname, altbuildid, + altfile_str_m, 0, True ); + ++ ML_(dinfo_free)(rdbgname); ++ + if (altfile_str_m) + ML_(dinfo_free)(altfile_str_m); + ML_(dinfo_free)(altbuildid); + +diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c +index c19ff212b..70c28e629 100644 +--- a/coregrind/m_debuginfo/readelf.c ++++ b/coregrind/m_debuginfo/readelf.c +@@ -1582,6 +1582,24 @@ static HChar* readlink_path (const HChar *path) + return NULL; + } + ++ if (buf[0] == '/') ++ return buf; ++ ++ /* Relative path, add link dir. */ ++ HChar *linkdirptr; ++ SizeT linkdir_len = VG_(strlen)(path); ++ if ((linkdirptr = VG_(strrchr)(path, '/')) != NULL) ++ linkdir_len -= VG_(strlen)(linkdirptr + 1); ++ ++ SizeT buflen = VG_(strlen)(buf); ++ SizeT needed = linkdir_len + buflen + 1; ++ if (bufsiz < needed) ++ buf = ML_(dinfo_realloc)("readlink_path.linkdir", buf, needed); ++ ++ VG_(memmove)(buf + linkdir_len, buf, buflen); ++ VG_(memcpy)(buf, path, linkdir_len); ++ buf[needed - 1] = '\0'; ++ + return buf; + } + + diff --git a/SOURCES/valgrind-3.13.0-ppc64-mtfprwa-constraint.patch b/SOURCES/valgrind-3.13.0-ppc64-mtfprwa-constraint.patch new file mode 100644 index 0000000..6b360e0 --- /dev/null +++ b/SOURCES/valgrind-3.13.0-ppc64-mtfprwa-constraint.patch @@ -0,0 +1,13 @@ +diff --git a/none/tests/ppc64/test_isa_2_07_part1.c b/none/tests/ppc64/test_isa_2_07_part1.c +index 73a563c..201fa88 100644 +--- a/none/tests/ppc64/test_isa_2_07_part1.c ++++ b/none/tests/ppc64/test_isa_2_07_part1.c +@@ -406,7 +406,7 @@ static void test_mtvsrwz (void) + + static void test_mtfprwa (void) + { +- __asm__ __volatile__ ("mtfprwa %x0,%1" : "=ws" (vec_out) : "r" (r14)); ++ __asm__ __volatile__ ("mtfprwa %x0,%1" : "=d" (vec_out) : "r" (r14)); + }; + + static test_t tests_move_ops_spe[] = { diff --git a/SOURCES/valgrind-3.13.0-s390-cgijnl.patch b/SOURCES/valgrind-3.13.0-s390-cgijnl.patch new file mode 100644 index 0000000..776bed6 --- /dev/null +++ b/SOURCES/valgrind-3.13.0-s390-cgijnl.patch @@ -0,0 +1,57 @@ +commit d6a810760ec61ddedf15445457edbbe288536a2f +Author: Julian Seward +Date: Tue Dec 12 22:31:54 2017 +0100 + + Fix false positive with s390x cgijnl instruction testing against sign bit. + + https://bugs.kde.org/show_bug.cgi?id=387712 + + When the cgij "compare immediate and branch relative" instruction + compares 0 <=signed dep1, that means dep1 >=signed 0, so it is a test + against the most significant bit of dep1. So only that bit needs + to be defined. + +diff --git a/VEX/priv/guest_s390_helpers.c b/VEX/priv/guest_s390_helpers.c +index 4cccdec..aacd833 100644 +--- a/VEX/priv/guest_s390_helpers.c ++++ b/VEX/priv/guest_s390_helpers.c +@@ -1818,6 +1818,13 @@ isC64(const IRExpr *expr) + return expr->tag == Iex_Const && expr->Iex.Const.con->tag == Ico_U64; + } + ++static inline Bool ++isC64_exactly(const IRExpr *expr, ULong n) ++{ ++ return expr->tag == Iex_Const && expr->Iex.Const.con->tag == Ico_U64 ++ && expr->Iex.Const.con->Ico.U64 == n; ++} ++ + + /* The returned expression is NULL if no specialization was found. In that + case the helper function will be called. Otherwise, the expression has +@@ -1895,9 +1902,25 @@ guest_s390x_spechelper(const HChar *function_name, IRExpr **args, + } + /* cc_dep1 > cc_dep2 ----> cc_dep2 < cc_dep1 */ + if (cond == 2 || cond == 2 + 1) { ++ /* If we ever need the counterpart of the bug387712 fix just ++ below, then here is the place. We'll need to give an ++ alternative expression for the case "cc_dep2 dep1 >=signed 0 ++ --> m.s.bit of dep1 == 0 */ ++ /* See bug 387712. This is an old trick from gcc to extract ++ the most significant bit of a word. */ ++ return unop(Iop_64to32, ++ binop(Iop_Xor64, ++ binop(Iop_Shr64, cc_dep1, mkU8(63)), ++ mkU64(1))); ++ } + return unop(Iop_1Uto32, binop(Iop_CmpLE64S, cc_dep2, cc_dep1)); + } + if (cond == 8 + 4 + 2 || cond == 8 + 4 + 2 + 1) { diff --git a/SPECS/valgrind.spec b/SPECS/valgrind.spec index 9879ba2..270b7a3 100644 --- a/SPECS/valgrind.spec +++ b/SPECS/valgrind.spec @@ -3,7 +3,7 @@ Summary: Tool for finding memory management bugs in programs Name: %{?scl_prefix}valgrind Version: 3.13.0 -Release: 10%{?dist} +Release: 13%{?dist} Epoch: 1 License: GPLv2+ URL: http://www.valgrind.org/ @@ -39,15 +39,23 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %endif %endif -# Note s390x doesn't have an openmpi port available. -# We never want the openmpi subpackage when building a software collecton +# We never want the openmpi subpackage when building a software collecton. +# We always want it for fedora. +# We only want it for older rhel. %if %{is_scl} %global build_openmpi 0 %else - %ifarch %{ix86} x86_64 ppc ppc64 ppc64le %{arm} aarch64 + %if 0%{?fedora} %global build_openmpi 1 - %else - %global build_openmpi 0 + %endif + %if 0%{?rhel} + # We only ever build for these architectures. Historically s390x + # didn't have an openmpi implementation. + %ifarch %{ix86} x86_64 ppc ppc64 ppc64le %{arm} aarch64 + %global build_openmpi 1 + %else + %global build_openmpi 0 + %endif %endif %endif @@ -147,6 +155,21 @@ Patch16: valgrind-3.13.0-static-tls.patch # KDE#386397 PPC64 valgrind truncates powerpc timebase to 32-bits. Patch17: valgrind-3.13.0-ppc64-timebase.patch +# KDE#387773 - Files in .gnu_debugaltlink should be resolved relative to .debug +Patch18: valgrind-3.13.0-debug-alt-file.patch + +# KDE#387712 s390x cgijnl reports Conditional jump depends on uninit value +Patch19: valgrind-3.13.0-s390-cgijnl.patch + +# KDE#391164 constraint bug in tests/ppc64/test_isa_2_07_part1.c for mtfprwa +Patch20: valgrind-3.13.0-ppc64-mtfprwa-constraint.patch + +# KDE#393062 Reading build-id ELF note "debuginfo reader: ensure_valid failed" +Patch21: valgrind-3.13.0-build-id-phdrs.patch + +# KDE#368913 WARNING: unhandled arm64-linux syscall: 117 (ptrace) +Patch22: valgrind-3.13.0-arm64-ptrace.patch + # RHEL7 specific patches. # RHBZ#996927 Ignore PPC floating point phased out category. @@ -154,6 +177,7 @@ Patch17: valgrind-3.13.0-ppc64-timebase.patch # public header under /usr/include/valgrind causing multilib problems. # The result would only be used for two test cases. Patch7001: valgrind-3.11.0-ppc-fppo.patch + %if %{build_multilib} # Ensure glibc{,-devel} is installed for both multilib arches @@ -286,6 +310,11 @@ Valgrind User Manual for details. %patch15 -p1 %patch16 -p1 %patch17 -p1 +%patch18 -p1 +%patch19 -p1 +%patch20 -p1 +%patch21 -p1 +%patch22 -p1 # RHEL7 specific patches %patch7001 -p1 @@ -312,6 +341,10 @@ CC="gcc -B `pwd`/shared/libgcc/" %else %define mpiccpath %{!?scl:%{_libdir}}%{?scl:%{_root_libdir}}/openmpi/*/bin/mpicc %endif +%else +# We explicitly don't want the libmpi wrapper. So make sure that configure +# doesn't pick some random mpi compiler that happens to be installed. +%define mpiccpath /bin/false %endif # Filter out some flags that cause lots of valgrind test failures. @@ -323,9 +356,7 @@ CC="gcc -B `pwd`/shared/libgcc/" %undefine _hardened_build OPTFLAGS="`echo " %{optflags} " | sed 's/ -m\(64\|3[21]\) / /g;s/ -fexceptions / /g;s/ -fstack-protector\([-a-z]*\) / / g;s/ -Wp,-D_FORTIFY_SOURCE=2 / /g;s/ -O2 / /g;s/ -mcpu=\([a-z0-9]\+\) / /g;s/^ //;s/ $//'`" %configure CC="$CC" CFLAGS="$OPTFLAGS" CXXFLAGS="$OPTFLAGS" \ -%if %{build_openmpi} --with-mpicc=%{mpiccpath} \ -%endif GDB=%{_bindir}/gdb make %{?_smp_mflags} @@ -491,6 +522,20 @@ echo ===============END TESTING=============== %endif %changelog +* Thu Jun 21 2018 Mark Wielaard - 3.13.0-13 +- Improved valgrind-3.13.0-arm64-hwcap.patch (#1593686) +- Add valgrind-3.13.0-arm64-ptrace.patch (#1593682) + +* Tue Jun 12 2018 Mark Wielaard - 3.13.0-12 +- Keep build_openmpi explicitly off for s390x (#1530219) + +* Tue Jun 12 2018 Mark Wielaard - 3.13.0-11 +- Make building of libmpi wrapper explicit (#1530219) +- Add valgrind-3.13.0-debug-alt-file.patch + and valgrind-3.13.0-build-id-phdrs.patch (#1589844) +- Add valgrind-3.13.0-s390-cgijnl.patch (#1589848) +- Add valgrind-3.13.0-ppc64-mtfprwa-constraint.patch (#1589852) + * Thu Nov 2 2017 Mark Wielaard - 3.13.0-10 - Add valgrind-3.13.0-ppc64-timebase.patch (#1508148)