|
From: <sv...@va...> - 2016-08-12 22:28:59
|
Author: iraisr
Date: Fri Aug 12 23:28:50 2016
New Revision: 15936
Log:
Follow recent Solaris development with respect to
SUNWDTRACE program header. Newer Solaris no longer utilizes
this program header as a scratchspace for DTrace fasttrap
provider, before libc is loaded.
For the time being, it serves as a space for initial thread
pointer.
n-i-bz
Modified:
trunk/configure.ac
trunk/coregrind/m_debuginfo/readelf.c
trunk/coregrind/m_ume/elf.c
trunk/include/vki/vki-solaris.h
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Fri Aug 12 23:28:50 2016
@@ -3649,6 +3649,29 @@
[Define to 1 if you have the schedctl page executable.])
])
+
+# Solaris-specific check determining if PT_SUNWDTRACE program header provides
+# scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
+# an initial thread pointer for libc (newer Solaris).
+#
+# C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
+# Automake-level symbol: none
+#
+AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
+AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <sys/fasttrap_isa.h>
+]], [[
+ return !FT_SCRATCHSIZE;
+]])], [
+solaris_pt_sunwdtrace_thrp=yes
+AC_MSG_RESULT([yes])
+AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
+ [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
+], [
+solaris_pt_sunwdtrace_thrp=no
+AC_MSG_RESULT([no])
+])
+
else
AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
Modified: trunk/coregrind/m_debuginfo/readelf.c
==============================================================================
--- trunk/coregrind/m_debuginfo/readelf.c (original)
+++ trunk/coregrind/m_debuginfo/readelf.c Fri Aug 12 23:28:50 2016
@@ -1594,6 +1594,10 @@
XArray* /* of RangeAndBias */ svma_ranges = NULL;
+# if defined(SOLARIS_PT_SUNDWTRACE_THRP)
+ Addr dtrace_data_vaddr = 0;
+# endif
+
vg_assert(di);
vg_assert(di->fsm.have_rx_map == True);
vg_assert(di->fsm.have_rw_map == True);
@@ -1815,6 +1819,16 @@
}
}
if (!loaded) {
+# if defined(SOLARIS_PT_SUNDWTRACE_THRP)
+ if ((a_phdr.p_memsz == VKI_PT_SUNWDTRACE_SIZE)
+ && ((a_phdr.p_flags & (PF_R | PF_W | PF_X)) == PF_R)) {
+ TRACE_SYMTAB("PT_LOAD[%ld]: ignore dtrace_data program "
+ "header\n", i);
+ dtrace_data_vaddr = a_phdr.p_vaddr;
+ continue;
+ }
+# endif /* SOLARIS_PT_SUNDWTRACE_THRP */
+
ML_(symerr)(di, False,
"ELF section outside all mapped regions");
/* This problem might be solved by further memory mappings.
@@ -2020,6 +2034,12 @@
/* Accept .data where mapped as rw (data), even if zero-sized */
if (0 == VG_(strcmp)(name, ".data")) {
+# if defined(SOLARIS_PT_SUNDWTRACE_THRP)
+ if ((size == VKI_PT_SUNWDTRACE_SIZE) && (svma == dtrace_data_vaddr)) {
+ TRACE_SYMTAB("ignoring .data section for dtrace_data "
+ "%#lx .. %#lx\n", svma, svma + size - 1);
+ } else
+# endif /* SOLARIS_PT_SUNDWTRACE_THRP */
if (inrw && !di->data_present) {
di->data_present = True;
di->data_svma = svma;
Modified: trunk/coregrind/m_ume/elf.c
==============================================================================
--- trunk/coregrind/m_ume/elf.c (original)
+++ trunk/coregrind/m_ume/elf.c Fri Aug 12 23:28:50 2016
@@ -55,6 +55,11 @@
#include <elf.h>
#if defined(VGO_solaris)
# include <sys/fasttrap.h> // PT_SUNWDTRACE_SIZE
+# if defined(SOLARIS_PT_SUNDWTRACE_THRP)
+# define PT_SUNWDTRACE_PROTECTION (PF_R)
+# else
+# define PT_SUNWDTRACE_PROTECTION (PF_R | PF_W | PF_X)
+# endif
#endif
/* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
@@ -617,11 +622,15 @@
# if defined(VGO_solaris)
case PT_SUNWDTRACE:
- if (ph->p_memsz < PT_SUNWDTRACE_SIZE ||
- (ph->p_flags & (PF_R | PF_W | PF_X)) != (PF_R | PF_W | PF_X)) {
+ if (ph->p_memsz < PT_SUNWDTRACE_SIZE) {
VG_(printf)("valgrind: m_ume.c: too small SUNWDTRACE size\n");
return VKI_ENOEXEC;
}
+ if ((ph->p_flags & PT_SUNWDTRACE_PROTECTION)
+ != PT_SUNWDTRACE_PROTECTION) {
+ VG_(printf)("valgrind: m_ume.c: SUNWDTRACE protection mismatch\n");
+ return VKI_ENOEXEC;
+ }
info->init_thrptr = ph->p_vaddr + ebase;
break;
@@ -657,12 +666,16 @@
# if defined(VGO_solaris)
if (iph->p_type == PT_SUNWDTRACE) {
- if (iph->p_memsz < PT_SUNWDTRACE_SIZE ||
- (iph->p_flags & (PF_R | PF_W | PF_X))
- != (PF_R | PF_W | PF_X)) {
+ if (iph->p_memsz < PT_SUNWDTRACE_SIZE) {
VG_(printf)("valgrind: m_ume.c: too small SUNWDTRACE size\n");
return VKI_ENOEXEC;
}
+ if ((iph->p_flags & PT_SUNWDTRACE_PROTECTION)
+ != PT_SUNWDTRACE_PROTECTION) {
+ VG_(printf)("valgrind: m_ume.c: SUNWDTRACE protection "
+ "mismatch\n");
+ return VKI_ENOEXEC;
+ }
/* Store the thrptr value into a temporary because we do not
know yet where the interpreter is mapped. */
Modified: trunk/include/vki/vki-solaris.h
==============================================================================
--- trunk/include/vki/vki-solaris.h (original)
+++ trunk/include/vki/vki-solaris.h Fri Aug 12 23:28:50 2016
@@ -483,6 +483,10 @@
#endif /* SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS */
+#include <sys/fasttrap.h>
+#define VKI_PT_SUNWDTRACE_SIZE PT_SUNWDTRACE_SIZE
+
+
#include <sys/fcntl.h>
#define VKI_O_RDONLY O_RDONLY
#define VKI_O_WRONLY O_WRONLY
|