aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2004-02-08 21:25:41 +0000
committerMark Kettenis <kettenis@gnu.org>2004-02-08 21:25:41 +0000
commit645d6d1047e8b9ae859f8cd295569bfc4d4ffcdf (patch)
tree10b747b96d666f77254997ee5028d0feeb3c463d
parent58dfe9ff598452395a21b5f886ac38eba9b44ebb (diff)
downloadgdb-645d6d1047e8b9ae859f8cd295569bfc4d4ffcdf.zip
gdb-645d6d1047e8b9ae859f8cd295569bfc4d4ffcdf.tar.gz
gdb-645d6d1047e8b9ae859f8cd295569bfc4d4ffcdf.tar.bz2
* sparc-nat.c (sparc_xfer_wcookie): Try to fetch the cookie using
the PT_WCOOKIE request.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/sparc-nat.c28
2 files changed, 31 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f61954f..f5e55e4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2004-02-08 Mark Kettenis <kettenis@gnu.org>
+
+ * sparc-nat.c (sparc_xfer_wcookie): Try to fetch the cookie using
+ the PT_WCOOKIE request.
+
2004-02-08 Andrew Cagney <cagney@redhat.com>
* mips-tdep.c (mips_unwind_pc): New function.
diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c
index 477fc97..955e65e 100644
--- a/gdb/sparc-nat.c
+++ b/gdb/sparc-nat.c
@@ -270,8 +270,32 @@ sparc_xfer_wcookie (struct target_ops *ops, enum target_object object,
/* If PT_WCOOKIE is defined (by <sys/ptrace.h>), assume we're
running on an OpenBSD release that uses StackGhost (3.1 or
later). As of release 3.4, OpenBSD doesn't use a randomized
- cookie yet. */
- wcookie = 0x3;
+ cookie yet, but a future release probably will. */
+ {
+ int pid;
+
+ pid = TIDGET (inferior_ptid);
+ if (pid == 0)
+ pid = PIDGET (inferior_ptid);
+
+ /* Sanity check. The proper type for a cookie is register_t, but
+ we can't assume that this type exists on all systems supported
+ by the code in this file. */
+ gdb_assert (sizeof (wcookie) == sizeof (register_t));
+
+ /* Fetch the cookie. */
+ if (ptrace (PT_WCOOKIE, pid, (PTRACE_ARG3_TYPE) &wcookie, 0) == -1)
+ {
+ if (errno != EINVAL)
+ perror_with_name ("Couldn't get StackGhost cookie");
+
+ /* Although PT_WCOOKIE is defined on OpenBSD 3.1 and later,
+ the request wasn't implemented until after OpenBSD 3.4. If
+ the kernel doesn't support the PT_WCOOKIE request, assume
+ we're running on a kernel that uses non-randomized cookies. */
+ wcookie = 0x3;
+ }
+ }
#endif /* PT_WCOOKIE */
if (len > sizeof (unsigned long) - offset)