aboutsummaryrefslogtreecommitdiff
path: root/gdb/sparc-nat.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2004-02-04 21:49:58 +0000
committerMark Kettenis <kettenis@gnu.org>2004-02-04 21:49:58 +0000
commitbaf92889ebd77dceec279733db08e537eefbff49 (patch)
tree46f836a0e5e0b0fe877ce37226f1c6ac3bb60282 /gdb/sparc-nat.c
parent6e4c6c91defcde7bd46625742b7df8108e8d597f (diff)
downloadgdb-baf92889ebd77dceec279733db08e537eefbff49.zip
gdb-baf92889ebd77dceec279733db08e537eefbff49.tar.gz
gdb-baf92889ebd77dceec279733db08e537eefbff49.tar.bz2
* target.h (target_object): Add TARGET_OBJECT_WCOOKIE.
* inftarg.c: Update copyright year. (child_xfer_partial): Add support for TARGET_OBJECT_WCOOKIE. * sparc-nat.c: Include "target.h" and "gdb_assert.h". (sparc_xfer_wcookie): New function. * sparc-tdep.c (sparc_fetch_wcookie): New function. * Makefile.in (sparc-nat.o): Update dependencies. * config/sparc/nm-nbsd.h: Include "target.h". (NATIVE_XFER_WCOOKIE): New define. (sparc_xfer_wcookie): New prototype.
Diffstat (limited to 'gdb/sparc-nat.c')
-rw-r--r--gdb/sparc-nat.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c
index 3ab21f0..477fc97 100644
--- a/gdb/sparc-nat.c
+++ b/gdb/sparc-nat.c
@@ -22,7 +22,9 @@
#include "defs.h"
#include "inferior.h"
#include "regcache.h"
+#include "target.h"
+#include "gdb_assert.h"
#include <signal.h>
#include "gdb_string.h"
#include <sys/ptrace.h>
@@ -246,8 +248,40 @@ store_inferior_registers (int regnum)
return;
}
}
+
+/* Fetch StackGhost Per-Process XOR cookie. */
+
+LONGEST
+sparc_xfer_wcookie (struct target_ops *ops, enum target_object object,
+ const char *annex, void *readbuf, const void *writebuf,
+ ULONGEST offset, LONGEST len)
+{
+ unsigned long wcookie = 0;
+ char *buf = (char *)&wcookie;
+
+ gdb_assert (object == TARGET_OBJECT_WCOOKIE);
+ gdb_assert (readbuf && writebuf == NULL);
+
+ if (offset >= sizeof (unsigned long))
+ return -1;
+#ifdef PT_WCOOKIE
+ /* 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;
+#endif /* PT_WCOOKIE */
+
+ if (len > sizeof (unsigned long) - offset)
+ len = sizeof (unsigned long) - offset;
+
+ memcpy (readbuf, buf + offset, len);
+ return len;
+}
+
+
/* Provide a prototype to silence -Wmissing-prototypes. */
void _initialize_sparc_nat (void);