mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 14:49:38 +08: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:
@ -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) \
|
$(frame_unwind_h) $(gdbarch_h) $(gdbcore_h) $(osabi_h) $(regcache_h) \
|
||||||
$(solib_svr4_h) $(symtab_h) $(trad_frame_h) $(gdb_assert_h) \
|
$(solib_svr4_h) $(symtab_h) $(trad_frame_h) $(gdb_assert_h) \
|
||||||
$(gdb_string_h) $(sparc_tdep_h)
|
$(gdb_string_h) $(sparc_tdep_h)
|
||||||
sparc-nat.o: sparc-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
|
sparc-nat.o: sparc-nat.c $(defs_h) $(inferior_h) $(regcache_h) $(target_h) \
|
||||||
$(gdb_string_h) $(gdb_wait_h) $(sparc_tdep_h) $(sparc_nat_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-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) \
|
sparcnbsd-tdep.o: sparcnbsd-tdep.c $(defs_h) $(floatformat_h) $(frame_h) \
|
||||||
$(frame_unwind_h) $(gdbcore_h) $(osabi_h) $(regcache_h) $(regset_h) \
|
$(frame_unwind_h) $(gdbcore_h) $(osabi_h) $(regcache_h) $(regset_h) \
|
||||||
|
@ -25,5 +25,17 @@
|
|||||||
|
|
||||||
/* Get generic NetBSD native definitions. */
|
/* Get generic NetBSD native definitions. */
|
||||||
#include "config/nm-nbsd.h"
|
#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 */
|
#endif /* nm-nbsd.h */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* Target-vector operations for controlling Unix child processes, for GDB.
|
/* Target-vector operations for controlling Unix child processes, for GDB.
|
||||||
|
|
||||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
|
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.
|
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,
|
return NATIVE_XFER_AUXV (ops, object, annex, readbuf, writebuf,
|
||||||
offset, len);
|
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:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,9 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "inferior.h"
|
#include "inferior.h"
|
||||||
#include "regcache.h"
|
#include "regcache.h"
|
||||||
|
#include "target.h"
|
||||||
|
|
||||||
|
#include "gdb_assert.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "gdb_string.h"
|
#include "gdb_string.h"
|
||||||
#include <sys/ptrace.h>
|
#include <sys/ptrace.h>
|
||||||
@ -246,8 +248,40 @@ store_inferior_registers (int regnum)
|
|||||||
return;
|
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. */
|
/* Provide a prototype to silence -Wmissing-prototypes. */
|
||||||
void _initialize_sparc_nat (void);
|
void _initialize_sparc_nat (void);
|
||||||
|
|
||||||
|
@ -141,13 +141,21 @@ sparc_fetch_instruction (CORE_ADDR pc)
|
|||||||
ULONGEST
|
ULONGEST
|
||||||
sparc_fetch_wcookie (void)
|
sparc_fetch_wcookie (void)
|
||||||
{
|
{
|
||||||
/* FIXME: kettenis/20040131: We should fetch the cookie from the
|
struct target_ops *ops = ¤t_target;
|
||||||
target. For now, return zero, which is right for targets without
|
char buf[8];
|
||||||
StackGhost. */
|
int len;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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. */
|
/* Return the contents if register REGNUM as an address. */
|
||||||
|
|
||||||
static CORE_ADDR
|
static CORE_ADDR
|
||||||
|
@ -228,6 +228,8 @@ enum target_object
|
|||||||
TARGET_OBJECT_UNWIND_TABLE,
|
TARGET_OBJECT_UNWIND_TABLE,
|
||||||
/* Transfer auxilliary vector. */
|
/* Transfer auxilliary vector. */
|
||||||
TARGET_OBJECT_AUXV,
|
TARGET_OBJECT_AUXV,
|
||||||
|
/* StackGhost cookie. See "sparc-tdep.c". */
|
||||||
|
TARGET_OBJECT_WCOOKIE
|
||||||
|
|
||||||
/* Possible future objects: TARGET_OBJECT_FILE, TARGET_OBJECT_PROC, ... */
|
/* Possible future objects: TARGET_OBJECT_FILE, TARGET_OBJECT_PROC, ... */
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user