2 # This patch converts libsigsegv from using the obsolete (since Solaris 2.6, |
2 # This patch converts libsigsegv from using the obsolete (since Solaris 2.6, |
3 # 1997) ioctl-based version of the /proc interface to using the structured |
3 # 1997) ioctl-based version of the /proc interface to using the structured |
4 # /proc interface as described in the proc(4) manual page. |
4 # /proc interface as described in the proc(4) manual page. |
5 # See libsigsegv bug: https://savannah.gnu.org/bugs/?42187 |
5 # See libsigsegv bug: https://savannah.gnu.org/bugs/?42187 |
6 # |
6 # |
7 diff -r -u libsigsegv-2.6/configure.orig libsigsegv-2.6/configure |
7 diff -Naru libsigsegv-2.10.original/configure libsigsegv-2.10/configure |
8 --- libsigsegv-2.6/configure.orig 2008-08-24 15:58:15.000000000 -0700 |
8 --- libsigsegv-2.10.original/configure 2011-04-03 08:50:50.000000000 -0700 |
9 +++ libsigsegv-2.6/configure 2014-04-10 11:02:03.212637829 -0700 |
9 +++ libsigsegv-2.10/configure 2016-05-12 19:05:26.396147574 -0700 |
10 @@ -15596,8 +15596,8 @@ |
10 @@ -14601,20 +14601,19 @@ |
11 _ACEOF |
|
12 |
11 |
13 |
12 |
14 -{ $as_echo "$as_me:$LINENO: checking for PIOCMAP in sys/procfs.h" >&5 |
13 |
|
14 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PIOCMAP in sys/procfs.h" >&5 |
15 -$as_echo_n "checking for PIOCMAP in sys/procfs.h... " >&6; } |
15 -$as_echo_n "checking for PIOCMAP in sys/procfs.h... " >&6; } |
16 +{ $as_echo "$as_me:$LINENO: checking for prmap_t in procfs.h" >&5 |
16 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for prmap_t in procfs.h" >&5 |
17 +$as_echo_n "checking for prmap_t in procfs.h... " >&6; } |
17 +$as_echo_n "checking for prmap_t in procfs.h... " >&6; } |
18 if test "${sv_cv_procfsvma+set}" = set; then |
18 if ${sv_cv_procfsvma+:} false; then : |
19 $as_echo_n "(cached) " >&6 |
19 $as_echo_n "(cached) " >&6 |
20 else |
20 else |
21 @@ -15608,12 +15608,11 @@ |
21 |
22 cat confdefs.h >>conftest.$ac_ext |
22 cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
23 cat >>conftest.$ac_ext <<_ACEOF |
|
24 /* end confdefs.h. */ |
23 /* end confdefs.h. */ |
25 -#include <sys/procfs.h> |
24 -#include <sys/procfs.h> |
26 +#include <procfs.h> |
25 +#include <procfs.h> |
27 int |
26 int |
28 main () |
27 main () |
31 - ; |
30 - ; |
32 + prmap_t y; |
31 + prmap_t y; |
33 return 0; |
32 return 0; |
34 } |
33 } |
35 _ACEOF |
34 _ACEOF |
36 diff -r -u libsigsegv-2.6/configure.ac.orig libsigsegv-2.6/configure.ac |
35 diff -Naru libsigsegv-2.10.original/configure.ac libsigsegv-2.10/configure.ac |
37 --- libsigsegv-2.6/configure.ac.orig 2014-04-10 10:55:23.907673765 -0700 |
36 --- libsigsegv-2.10.original/configure.ac 2011-04-03 08:30:16.000000000 -0700 |
38 +++ libsigsegv-2.6/configure.ac 2014-04-10 11:02:35.810560742 -0700 |
37 +++ libsigsegv-2.10/configure.ac 2016-05-12 19:08:31.848947387 -0700 |
39 @@ -619,9 +619,9 @@ |
38 @@ -648,9 +648,9 @@ |
40 STACK_DIRECTION = 0 => spaghetti stack.]) |
39 dnl Requires AC_CANONICAL_HOST. |
41 |
40 |
42 dnl Determination of the stack's virtual memory area. |
41 dnl Determination of the stack's virtual memory area. |
43 -AC_CACHE_CHECK([for PIOCMAP in sys/procfs.h], sv_cv_procfsvma, [ |
42 -AC_CACHE_CHECK([for PIOCMAP in sys/procfs.h], [sv_cv_procfsvma], [ |
44 - AC_TRY_LINK([#include <sys/procfs.h>], |
43 - AC_TRY_LINK([#include <sys/procfs.h>], |
45 - [int x = PIOCNMAP + PIOCMAP; prmap_t y;], |
44 - [int x = PIOCNMAP + PIOCMAP; prmap_t y;], |
46 +AC_CACHE_CHECK([for prmap_t in procfs.h], sv_cv_procfsvma, [ |
45 +AC_CACHE_CHECK([for prmap_t in procfs.h], sv_cv_procfsvma, [ |
47 + AC_TRY_LINK([#include <procfs.h>], |
46 + AC_TRY_LINK([#include <procfs.h>], |
48 + [ prmap_t y;], |
47 + [ prmap_t y;], |
49 sv_cv_procfsvma=yes, sv_cv_procfsvma=no) |
48 [sv_cv_procfsvma=yes], [sv_cv_procfsvma=no]) |
50 ]) |
49 ]) |
51 AC_CHECK_FUNCS([mincore]) |
50 AC_CHECK_FUNCS([mquery mincore]) |
52 diff -r -u libsigsegv-2.6/src/stackvma-procfs.c.orig libsigsegv-2.6/src/stackvma-procfs.c |
51 diff -Naru libsigsegv-2.10.original/src/stackvma-procfs.c libsigsegv-2.10/src/stackvma-procfs.c |
53 --- libsigsegv-2.6/src/stackvma-procfs.c.orig 2014-04-10 11:05:58.957104341 -0700 |
52 --- libsigsegv-2.10.original/src/stackvma-procfs.c 2009-08-16 04:10:00.000000000 -0700 |
54 +++ libsigsegv-2.6/src/stackvma-procfs.c 2014-04-10 10:49:41.584900672 -0700 |
53 +++ libsigsegv-2.10/src/stackvma-procfs.c 2016-05-12 19:11:17.173911686 -0700 |
55 @@ -19,8 +19,9 @@ |
54 @@ -20,8 +20,9 @@ |
56 #include <unistd.h> /* open, close */ |
|
57 #include <fcntl.h> /* open */ |
55 #include <fcntl.h> /* open */ |
|
56 #include <string.h> /* memcpy */ |
58 #include <sys/types.h> |
57 #include <sys/types.h> |
59 +#include <sys/stat.h> |
58 +#include <sys/stat.h> |
60 #include <sys/mman.h> /* mmap, munmap */ |
59 #include <sys/mman.h> /* mmap, munmap */ |
61 -#include <sys/procfs.h> /* PIOC*, prmap_t */ |
60 -#include <sys/procfs.h> /* PIOC*, prmap_t */ |
62 +#include <procfs.h> /* prmap_t */ |
61 +#include <procfs.h> /* prmap_t */ |
63 |
62 |
64 #include "stackvma-simple.c" |
63 #include "stackvma-simple.c" |
65 |
64 |
66 @@ -43,10 +44,7 @@ |
65 @@ -44,10 +45,7 @@ |
67 int |
66 int |
68 sigsegv_get_vma (unsigned long address, struct vma_struct *vma) |
67 sigsegv_get_vma (unsigned long address, struct vma_struct *vma) |
69 { |
68 { |
70 - char fnamebuf[6+10+1]; |
69 - char fnamebuf[6+10+1]; |
71 - char *fname; |
70 - char *fname; |
72 int fd; |
71 int fd; |
73 - int nmaps; |
72 - int nmaps; |
74 size_t memneed; |
73 size_t memneed; |
75 #if HAVE_MMAP_ANON |
74 #if HAVE_MMAP_ANON |
76 # define zero_fd -1 |
75 # define zero_fd -1 |
77 @@ -58,6 +56,7 @@ |
76 @@ -59,6 +57,7 @@ |
78 int zero_fd; |
77 int zero_fd; |
79 # define map_flags 0 |
78 # define map_flags 0 |
80 #endif |
79 #endif |
81 + struct stat statb; |
80 + struct stat statb; |
82 void *auxmap; |
81 void *auxmap; |
83 unsigned long auxmap_start; |
82 unsigned long auxmap_start; |
84 unsigned long auxmap_end; |
83 unsigned long auxmap_end; |
85 @@ -71,26 +70,14 @@ |
84 @@ -72,26 +71,14 @@ |
86 if (pagesize == 0) |
85 if (pagesize == 0) |
87 init_pagesize (); |
86 init_pagesize (); |
88 |
87 |
89 - /* Construct fname = sprintf (fnamebuf+i, "/proc/%u", getpid ()). */ |
88 - /* Construct fname = sprintf (fnamebuf+i, "/proc/%u", getpid ()). */ |
90 - fname = fnamebuf + sizeof (fnamebuf) - 1; |
89 - fname = fnamebuf + sizeof (fnamebuf) - 1; |
110 - memneed = (nmaps + 10) * sizeof (prmap_t); |
109 - memneed = (nmaps + 10) * sizeof (prmap_t); |
111 + memneed = statb.st_size + 10 * sizeof (prmap_t); |
110 + memneed = statb.st_size + 10 * sizeof (prmap_t); |
112 /* Allocate memneed bytes of memory. |
111 /* Allocate memneed bytes of memory. |
113 We cannot use alloca here, because we are low on stack space. |
112 We cannot use alloca here, because we are low on stack space. |
114 We also cannot use malloc here, because a malloc() call may have been |
113 We also cannot use malloc here, because a malloc() call may have been |
115 @@ -112,7 +99,7 @@ |
114 @@ -113,7 +100,7 @@ |
116 auxmap_end = auxmap_start + memneed; |
115 auxmap_end = auxmap_start + memneed; |
117 maps = (prmap_t *) auxmap; |
116 maps = (prmap_t *) auxmap; |
118 |
117 |
119 - if (ioctl (fd, PIOCMAP, maps) < 0) |
118 - if (ioctl (fd, PIOCMAP, maps) < 0) |
120 + if (read(fd, (void *)maps, memneed) <= 0) |
119 + if (read(fd, (void *)maps, memneed) <= 0) |