* coff-h8300.c (h8300_reloc16_extra_cases): Make name a const
[deliverable/binutils-gdb.git] / gdb / rs6000-tdep.c
index e715399c45d10dc10fe30832f6c204dffecee1da..85b01e34d126b63c996f9166cd2b59691173016d 100644 (file)
@@ -1,5 +1,5 @@
 /* Target-dependent code for GDB, the GNU debugger.
-   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995
+   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -26,11 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "gdbcore.h"
 #include "symfile.h"
 #include "objfiles.h"
-
 #include "xcoffsolib.h"
 
-#include <a.out.h>
-
 extern struct obstack frame_cache_obstack;
 
 extern int errno;
@@ -49,19 +46,16 @@ static struct sstep_breaks {
 
 /* Static function prototypes */
 
-static CORE_ADDR
-find_toc_address PARAMS ((CORE_ADDR pc));
+static CORE_ADDR find_toc_address PARAMS ((CORE_ADDR pc));
 
-static CORE_ADDR
-branch_dest PARAMS ((int opcode, int instr, CORE_ADDR pc, CORE_ADDR safety));
+static CORE_ADDR branch_dest PARAMS ((int opcode, int instr, CORE_ADDR pc,
+                                     CORE_ADDR safety));
 
-static void
-frame_get_cache_fsr PARAMS ((struct frame_info *fi,
-                            struct rs6000_framedata *fdatap));
+static void frame_get_cache_fsr PARAMS ((struct frame_info *fi,
+                                        struct rs6000_framedata *fdatap));
+
+/* Calculate the destination of a branch/jump.  Return -1 if not a branch.  */
 
-/*
- * Calculate the destination of a branch/jump.  Return -1 if not a branch.
- */
 static CORE_ADDR
 branch_dest (opcode, instr, pc, safety)
      int opcode;
@@ -641,12 +635,12 @@ pop_frame ()
    its argumets will be passed by gdb. */
 
 void
-fix_call_dummy(dummyname, pc, fun, nargs, type)
-  char *dummyname;
-  CORE_ADDR pc;
-  CORE_ADDR fun;
-  int nargs;                                   /* not used */
-  int type;                                    /* not used */
+fix_call_dummy (dummyname, pc, fun, nargs, type)
+     char *dummyname;
+     CORE_ADDR pc;
+     CORE_ADDR fun;
+     int nargs;                                        /* not used */
+     int type;                                 /* not used */
 {
 #define        TOC_ADDR_OFFSET         20
 #define        TARGET_ADDR_OFFSET      28
@@ -675,12 +669,13 @@ fix_call_dummy(dummyname, pc, fun, nargs, type)
   *(int*)((char*)dummyname + TARGET_ADDR_OFFSET+4) = ii;
 }
 
-/* Pass the arguments in either registers, or in the stack. In RS6000, the first
-   eight words of the argument list (that might be less than eight parameters if
-   some parameters occupy more than one word) are passed in r3..r11 registers.
-   float and double parameters are passed in fpr's, in addition to that. Rest of
-   the parameters if any are passed in user stack. There might be cases in which
-   half of the parameter is copied into registers, the other half is pushed into
+/* Pass the arguments in either registers, or in the stack. In RS6000,
+   the first eight words of the argument list (that might be less than
+   eight parameters if some parameters occupy more than one word) are
+   passed in r3..r11 registers.  float and double parameters are
+   passed in fpr's, in addition to that. Rest of the parameters if any
+   are passed in user stack. There might be cases in which half of the
+   parameter is copied into registers, the other half is pushed into
    stack.
 
    If the function is returning a structure, then the return address is passed
@@ -689,18 +684,19 @@ fix_call_dummy(dummyname, pc, fun, nargs, type)
 
 CORE_ADDR
 push_arguments (nargs, args, sp, struct_return, struct_addr)
-  int nargs;
-  value_ptr *args;
-  CORE_ADDR sp;
-  int struct_return;
-  CORE_ADDR struct_addr;
+     int nargs;
+     value_ptr *args;
+     CORE_ADDR sp;
+     int struct_return;
+     CORE_ADDR struct_addr;
 {
   int ii, len;
   int argno;                                   /* current argument number */
   int argbytes;                                        /* current argument byte */
   char tmp_buffer [50];
-  value_ptr arg;
   int f_argno = 0;                             /* current floating point argno */
+  value_ptr arg;
+  struct type *type;
 
   CORE_ADDR saved_sp, pc;
 
@@ -720,9 +716,10 @@ push_arguments (nargs, args, sp, struct_return, struct_addr)
   for (argno=0, argbytes=0; argno < nargs && ii<8; ++ii) {
 
     arg = args[argno];
-    len = TYPE_LENGTH (VALUE_TYPE (arg));
+    type = check_typedef (VALUE_TYPE (arg));
+    len = TYPE_LENGTH (type);
 
-    if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FLT) {
+    if (TYPE_CODE (type) == TYPE_CODE_FLT) {
 
       /* floating point arguments are passed in fpr's, as well as gpr's.
          There are 13 fpr's reserved for passing parameters. At this point
@@ -774,7 +771,6 @@ ran_out_of_registers_for_arguments:
 
   if ((argno < nargs) || argbytes) {
     int space = 0, jj;
-    value_ptr val;
 
     if (argbytes) {
       space += ((len - argbytes + 3) & -4);
@@ -784,7 +780,7 @@ ran_out_of_registers_for_arguments:
       jj = argno;
 
     for (; jj < nargs; ++jj) {
-      val = args[jj];
+      value_ptr val = args[jj];
       space += ((TYPE_LENGTH (VALUE_TYPE (val))) + 3) & -4;
     }
 
@@ -813,11 +809,12 @@ ran_out_of_registers_for_arguments:
     for (; argno < nargs; ++argno) {
 
       arg = args[argno];
-      len = TYPE_LENGTH (VALUE_TYPE (arg));
+      type = check_typedef (VALUE_TYPE (arg));
+      len = TYPE_LENGTH (type);
 
 
       /* float types should be passed in fpr's, as well as in the stack. */
-      if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FLT && f_argno < 13) {
+      if (TYPE_CODE (type) == TYPE_CODE_FLT && f_argno < 13) {
 
         if (len > 8)
           printf_unfiltered (
@@ -853,9 +850,9 @@ ran_out_of_registers_for_arguments:
 
 void
 extract_return_value (valtype, regbuf, valbuf)
-  struct type *valtype;
-  char regbuf[REGISTER_BYTES];
-  char *valbuf;
+     struct type *valtype;
+     char regbuf[REGISTER_BYTES];
+     char *valbuf;
 {
   int offset = 0;
 
@@ -905,7 +902,7 @@ CORE_ADDR rs6000_struct_return_address;
 
 CORE_ADDR
 skip_trampoline_code (pc)
-CORE_ADDR pc;
+     CORE_ADDR pc;
 {
   register unsigned int ii, op;
   CORE_ADDR solib_target_pc;
@@ -936,8 +933,8 @@ CORE_ADDR pc;
   return pc;
 }
 
-
 /* Determines whether the function FI has a frame on the stack or not.  */
+
 int
 frameless_function_invocation (fi)
      struct frame_info *fi;
@@ -964,6 +961,7 @@ frameless_function_invocation (fi)
 }
 
 /* Return the PC saved in a frame */
+
 unsigned long
 frame_saved_pc (fi)
      struct frame_info *fi;
@@ -1212,12 +1210,13 @@ add_text_to_loadinfo (textaddr, dataaddr)
 }
 
 
-/* Note that this assumes that the "textorg" and "dataorg" elements
-   of a member of this array are correlated with the "toc_offset"
-   element of the same member.  This is taken care of because the loops
-   which assign the former (in xcoff_relocate_symtab or xcoff_relocate_core)
-   and the latter (in scan_xcoff_symtab, via vmap_symtab, in vmap_ldinfo
-   or xcoff_relocate_core) traverse the same objfiles in the same order.  */
+/* Note that this assumes that the "textorg" and "dataorg" elements of
+   a member of this array are correlated with the "toc_offset" element
+   of the same member.  This is taken care of because the loops which
+   assign the former (in xcoff_relocate_symtab or xcoff_relocate_core)
+   and the latter (in scan_xcoff_symtab, via vmap_symtab, in
+   vmap_ldinfo or xcoff_relocate_core) traverse the same objfiles in
+   the same order.  */
 
 static CORE_ADDR
 find_toc_address (pc)
@@ -1269,6 +1268,22 @@ gdb_print_insn_powerpc (memaddr, info)
 void
 _initialize_rs6000_tdep ()
 {
+#ifndef ELF_OBJECT_FORMAT
+  {
+    extern void (*xcoff_add_toc_to_loadinfo_hook) PARAMS ((unsigned long));
+    extern void (*xcoff_init_loadinfo_hook) PARAMS ((void));
+
+    /* Initialize hook in xcoffread for recording the toc offset value
+       of a symbol table into the ldinfo structure, for native rs6000
+       config. */
+    xcoff_add_toc_to_loadinfo_hook = &xcoff_add_toc_to_loadinfo;
+
+    /* Initialize hook in xcoffread for calling xcoff_init_loadinfo in
+       a native rs6000 config. */
+    xcoff_init_loadinfo_hook = &xcoff_init_loadinfo;
+  }
+#endif /* ELF_OBJECT_FORMAT */
+
   /* FIXME, this should not be decided via ifdef. */
 #ifdef GDB_TARGET_POWERPC
   tm_print_insn = gdb_print_insn_powerpc;
This page took 0.027738 seconds and 4 git commands to generate.