Automatic date update in version.in
[binutils-gdb.git] / gdb / auxv.c
index 012f27b92c9a74e3c9772987412edc6b47350902..fff34ff80cd8b013adcc50095990f93e060aed60 100644 (file)
@@ -1,6 +1,6 @@
 /* Auxiliary vector support for GDB, the GNU debugger.
 
-   Copyright (C) 2004-2014 Free Software Foundation, Inc.
+   Copyright (C) 2004-2015 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "command.h"
 #include "inferior.h"
 #include "valprint.h"
-#include "gdb_assert.h"
 #include "gdbcore.h"
 #include "observer.h"
 #include "filestuff.h"
+#include "objfiles.h"
 
 #include "auxv.h"
 #include "elf/common.h"
@@ -35,8 +35,9 @@
 #include <fcntl.h>
 
 
-/* This function handles access via /proc/PID/auxv, which is a common
-   method for native targets.  */
+/* Implement the to_xfer_partial target_ops method.  This function
+   handles access via /proc/PID/auxv, which is a common method for
+   native targets.  */
 
 static enum target_xfer_status
 procfs_xfer_auxv (gdb_byte *readbuf,
@@ -84,7 +85,7 @@ ld_so_xfer_auxv (gdb_byte *readbuf,
                 ULONGEST offset,
                 ULONGEST len, ULONGEST *xfered_len)
 {
-  struct minimal_symbol *msym;
+  struct bound_minimal_symbol msym;
   CORE_ADDR data_address, pointer_address;
   struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
   size_t ptr_size = TYPE_LENGTH (ptr_type);
@@ -94,17 +95,17 @@ ld_so_xfer_auxv (gdb_byte *readbuf,
   size_t block;
 
   msym = lookup_minimal_symbol ("_dl_auxv", NULL, NULL);
-  if (msym == NULL)
+  if (msym.minsym == NULL)
     return TARGET_XFER_E_IO;
 
-  if (MSYMBOL_SIZE (msym) != ptr_size)
+  if (MSYMBOL_SIZE (msym.minsym) != ptr_size)
     return TARGET_XFER_E_IO;
 
   /* POINTER_ADDRESS is a location where the `_dl_auxv' variable
      resides.  DATA_ADDRESS is the inferior value present in
      `_dl_auxv', therefore the real inferior AUXV address.  */
 
-  pointer_address = SYMBOL_VALUE_ADDRESS (msym);
+  pointer_address = BMSYMBOL_VALUE_ADDRESS (msym);
 
   /* The location of the _dl_auxv symbol may no longer be correct if
      ld.so runs at a different address than the one present in the
@@ -215,8 +216,8 @@ ld_so_xfer_auxv (gdb_byte *readbuf,
   return TARGET_XFER_OK;
 }
 
-/* This function is called like a to_xfer_partial hook, but must be
-   called with TARGET_OBJECT_AUXV.  It handles access to AUXV.  */
+/* Implement the to_xfer_partial target_ops method for
+   TARGET_OBJECT_AUXV.  It handles access to AUXV.  */
 
 enum target_xfer_status
 memory_xfer_auxv (struct target_ops *ops,
@@ -253,7 +254,7 @@ memory_xfer_auxv (struct target_ops *ops,
    Return 0 if *READPTR is already at the end of the buffer.
    Return -1 if there is insufficient buffer for a whole entry.
    Return 1 if an entry was read into *TYPEP and *VALP.  */
-static int
+int
 default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
                   gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
@@ -285,13 +286,13 @@ int
 target_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
                   gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
-  struct target_ops *t;
+  struct gdbarch *gdbarch = target_gdbarch();
+
+  if (gdbarch_auxv_parse_p (gdbarch))
+    return gdbarch_auxv_parse (gdbarch, readptr, endptr, typep, valp);
 
-  for (t = ops; t != NULL; t = t->beneath)
-    if (t->to_auxv_parse != NULL)
-      return t->to_auxv_parse (t, readptr, endptr, typep, valp);
-  
-  return default_auxv_parse (ops, readptr, endptr, typep, valp);
+  return current_target.to_auxv_parse (&current_target, readptr, endptr,
+                                      typep, valp);
 }