mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2025-01-21 00:15:13 +00:00
* 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.
This commit is contained in:
parent
6e4c6c91de
commit
baf92889eb
@ -2383,8 +2383,9 @@ sparc-linux-tdep.o: sparc-linux-tdep.c $(defs_h) $(floatformat_h) $(frame_h) \
|
||||
$(frame_unwind_h) $(gdbarch_h) $(gdbcore_h) $(osabi_h) $(regcache_h) \
|
||||
$(solib_svr4_h) $(symtab_h) $(trad_frame_h) $(gdb_assert_h) \
|
||||
$(gdb_string_h) $(sparc_tdep_h)
|
||||
sparc-nat.o: sparc-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
|
||||
$(gdb_string_h) $(gdb_wait_h) $(sparc_tdep_h) $(sparc_nat_h)
|
||||
sparc-nat.o: sparc-nat.c $(defs_h) $(inferior_h) $(regcache_h) $(target_h) \
|
||||
$(gdb_assert_h) $(gdb_string_h) $(gdb_wait_h) $(sparc_tdep_h) \
|
||||
$(sparc_nat_h)
|
||||
sparcnbsd-nat.o: sparcnbsd-nat.c $(defs_h) $(sparc_tdep_h) $(sparc_nat_h)
|
||||
sparcnbsd-tdep.o: sparcnbsd-tdep.c $(defs_h) $(floatformat_h) $(frame_h) \
|
||||
$(frame_unwind_h) $(gdbcore_h) $(osabi_h) $(regcache_h) $(regset_h) \
|
||||
|
@ -25,5 +25,17 @@
|
||||
|
||||
/* Get generic NetBSD native definitions. */
|
||||
#include "config/nm-nbsd.h"
|
||||
|
||||
|
||||
/* Support for StackGhost cookies. */
|
||||
|
||||
#include "target.h"
|
||||
|
||||
#define NATIVE_XFER_WCOOKIE sparc_xfer_wcookie
|
||||
extern LONGEST sparc_xfer_wcookie (struct target_ops *ops,
|
||||
enum target_object object,
|
||||
const char *annex,
|
||||
void *readbuf, const void *writebuf,
|
||||
ULONGEST offset, LONGEST len);
|
||||
|
||||
#endif /* nm-nbsd.h */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* Target-vector operations for controlling Unix child processes, for GDB.
|
||||
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
|
||||
2000, 2002, 2003 Free Software Foundation, Inc.
|
||||
2000, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
Contributed by Cygnus Support.
|
||||
|
||||
@ -585,6 +585,13 @@ child_xfer_partial (struct target_ops *ops, enum target_object object,
|
||||
return NATIVE_XFER_AUXV (ops, object, annex, readbuf, writebuf,
|
||||
offset, len);
|
||||
|
||||
case TARGET_OBJECT_WCOOKIE:
|
||||
#ifndef NATIVE_XFER_WCOOKIE
|
||||
#define NATIVE_XFER_WCOOKIE(OPS,OBJECT,ANNEX,WRITEBUF,READBUF,OFFSET,LEN) (-1)
|
||||
#endif
|
||||
return NATIVE_XFER_WCOOKIE (ops, object, annex, readbuf, writebuf,
|
||||
offset, len);
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -141,13 +141,21 @@ sparc_fetch_instruction (CORE_ADDR pc)
|
||||
ULONGEST
|
||||
sparc_fetch_wcookie (void)
|
||||
{
|
||||
/* FIXME: kettenis/20040131: We should fetch the cookie from the
|
||||
target. For now, return zero, which is right for targets without
|
||||
StackGhost. */
|
||||
return 0;
|
||||
}
|
||||
struct target_ops *ops = ¤t_target;
|
||||
char buf[8];
|
||||
int len;
|
||||
|
||||
len = target_read_partial (ops, TARGET_OBJECT_WCOOKIE, NULL, buf, 0, 8);
|
||||
if (len == -1)
|
||||
return 0;
|
||||
|
||||
/* We should have either an 32-bit or an 64-bit cookie. */
|
||||
gdb_assert (len == 4 || len == 8);
|
||||
|
||||
return extract_unsigned_integer (buf, len);
|
||||
}
|
||||
|
||||
|
||||
/* Return the contents if register REGNUM as an address. */
|
||||
|
||||
static CORE_ADDR
|
||||
|
@ -228,6 +228,8 @@ enum target_object
|
||||
TARGET_OBJECT_UNWIND_TABLE,
|
||||
/* Transfer auxilliary vector. */
|
||||
TARGET_OBJECT_AUXV,
|
||||
/* StackGhost cookie. See "sparc-tdep.c". */
|
||||
TARGET_OBJECT_WCOOKIE
|
||||
|
||||
/* Possible future objects: TARGET_OBJECT_FILE, TARGET_OBJECT_PROC, ... */
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user