This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add support for FR-V FDPIC executables


I've just committed the patch below.

It adds support for detecting FDPIC (shared library ABI) executables. 
It also adds two fake registers which are used by the upcoming FR-V
shared library support.  These fake registers occupy unused slots and
do not affect existing clients of the FR-V (remote protocol) register
layout.

	* Makefile.in (elf_frv_h, frv_tdep_h): Define.
	(frv-tdep.o): Update dependencies.
	* frv-tdep.h: New file.
	* frv-tdep.c (elf-bfd.h, elf/frv.h, osabi.h, frv-tdep.h): Include.
	(fdpic_loadmap_exec_regnum, fdpic_loadmap_interp_regnum): New
	constants.
	(struct gdbarch_tdep): Add new member ``frv_abi''.
	(frv_abi, frv_fdpic_loadmap_addresses, set_variant_abi_fdpic): New
	functions.
	(new_variant): Set ``frv_abi'' field.
	(gdb_arch_init): Detect FDPIC executables.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.518
diff -u -p -r1.518 Makefile.in
--- Makefile.in	28 Feb 2004 18:04:36 -0000	1.518
+++ Makefile.in	13 Mar 2004 00:05:30 -0000
@@ -569,6 +569,7 @@ elf_reloc_macros_h =	$(INCLUDE_DIR)/elf/
 elf_sh_h =	$(INCLUDE_DIR)/elf/sh.h
 elf_arm_h =	$(INCLUDE_DIR)/elf/arm.h $(elf_reloc_macros_h)
 elf_bfd_h =	$(BFD_SRC)/elf-bfd.h
+elf_frv_h =	$(INCLUDE_DIR)/elf/frv.h $(elf_reloc_macros_h)
 libaout_h =	$(BFD_SRC)/libaout.h
 libbfd_h =	$(BFD_SRC)/libbfd.h
 remote_sim_h =	$(INCLUDE_DIR)/gdb/remote-sim.h
@@ -658,6 +659,7 @@ f_lang_h = f-lang.h
 frame_base_h = frame-base.h
 frame_h = frame.h
 frame_unwind_h = frame-unwind.h $(frame_h)
+frv_tdep_h = frv-tdep.h
 gdbarch_h = gdbarch.h
 gdb_assert_h = gdb_assert.h
 gdbcmd_h = gdbcmd.h $(command_h) $(ui_out_h)
@@ -1769,6 +1771,7 @@ frv-tdep.o: frv-tdep.c $(defs_h) $(gdb_s
 	$(arch_utils_h) $(regcache_h) $(frame_h) $(frame_unwind_h) \
 	$(frame_base_h) $(trad_frame_h) $(dis_asm_h) $(gdb_assert_h) \
 	$(sim_regno_h) $(gdb_sim_frv_h) $(opcodes_frv_desc_h) $(symtab_h)
+	$(elf_bfd_h) $(elf_frv_h) $(osabi_h) $(frv_tdep_h)
 f-typeprint.o: f-typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) $(symtab_h) \
 	$(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) $(target_h) \
 	$(f_lang_h) $(gdb_string_h)
Index: frv-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/frv-tdep.c,v
retrieving revision 1.72
diff -u -p -r1.72 frv-tdep.c
--- frv-tdep.c	17 Feb 2004 15:21:21 -0000	1.72
+++ frv-tdep.c	13 Mar 2004 00:05:30 -0000
@@ -34,6 +34,10 @@
 #include "gdb/sim-frv.h"
 #include "opcodes/frv-desc.h"	/* for the H_SPR_... enums */
 #include "symtab.h"
+#include "elf-bfd.h"
+#include "elf/frv.h"
+#include "osabi.h"
+#include "frv-tdep.h"
 
 extern void _initialize_frv_tdep (void);
 
@@ -69,6 +73,8 @@ enum {
   psr_regnum = 129,
   ccr_regnum = 130,
   cccr_regnum = 131,
+  fdpic_loadmap_exec_regnum = 132,
+  fdpic_loadmap_interp_regnum = 133,
   tbr_regnum = 135,
   brr_regnum = 136,
   dbar0_regnum = 137,
@@ -129,6 +135,9 @@ struct frv_unwind_cache		/* was struct f
    Fortran.  */
 struct gdbarch_tdep
 {
+  /* Which ABI is in use?  */
+  enum frv_abi frv_abi;
+
   /* How many general-purpose registers does this variant have?  */
   int num_gprs;
 
@@ -147,6 +156,41 @@ struct gdbarch_tdep
 
 #define CURRENT_VARIANT (gdbarch_tdep (current_gdbarch))
 
+/* Return the FR-V ABI associated with GDBARCH.  */
+enum frv_abi
+frv_abi (struct gdbarch *gdbarch)
+{
+  return gdbarch_tdep (gdbarch)->frv_abi;
+}
+
+/* Fetch the interpreter and executable loadmap addresses (for shared
+   library support) for the FDPIC ABI.  Return 0 if successful, -1 if
+   not.  (E.g, -1 will be returned if the ABI isn't the FDPIC ABI.)  */
+int
+frv_fdpic_loadmap_addresses (struct gdbarch *gdbarch, CORE_ADDR *interp_addr,
+                             CORE_ADDR *exec_addr)
+{
+  if (frv_abi (gdbarch) != FRV_ABI_FDPIC)
+    return -1;
+  else
+    {
+      if (interp_addr != NULL)
+	{
+	  ULONGEST val;
+	  regcache_cooked_read_unsigned (current_regcache,
+					 fdpic_loadmap_interp_regnum, &val);
+	  *interp_addr = val;
+	}
+      if (exec_addr != NULL)
+	{
+	  ULONGEST val;
+	  regcache_cooked_read_unsigned (current_regcache,
+					 fdpic_loadmap_exec_regnum, &val);
+	  *exec_addr = val;
+	}
+      return 0;
+    }
+}
 
 /* Allocate a new variant structure, and set up default values for all
    the fields.  */
@@ -160,6 +204,7 @@ new_variant (void)
   var = xmalloc (sizeof (*var));
   memset (var, 0, sizeof (*var));
   
+  var->frv_abi = FRV_ABI_EABI;
   var->num_gprs = 64;
   var->num_fprs = 64;
   var->num_hw_watchpoints = 0;
@@ -238,6 +283,13 @@ set_variant_num_fprs (struct gdbarch_tde
     }
 }
 
+static void
+set_variant_abi_fdpic (struct gdbarch_tdep *var)
+{
+  var->frv_abi = FRV_ABI_FDPIC;
+  var->register_names[fdpic_loadmap_exec_regnum] = xstrdup ("loadmap_exec");
+  var->register_names[fdpic_loadmap_interp_regnum] = xstrdup ("loadmap_interp");
+}
 
 static const char *
 frv_register_name (int reg)
@@ -1276,6 +1328,7 @@ frv_gdbarch_init (struct gdbarch_info in
 {
   struct gdbarch *gdbarch;
   struct gdbarch_tdep *var;
+  int elf_flags = 0;
 
   /* Check to see if we've already built an appropriate architecture
      object for this executable.  */
@@ -1305,7 +1358,14 @@ frv_gdbarch_init (struct gdbarch_info in
       /* Never heard of this variant.  */
       return 0;
     }
-  
+
+  /* Extract the ELF flags, if available.  */
+  if (info.abfd && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
+    elf_flags = elf_elfheader (info.abfd)->e_flags;
+
+  if (elf_flags & EF_FRV_FDPIC)
+    set_variant_abi_fdpic (var);
+
   gdbarch = gdbarch_alloc (&info, var);
 
   set_gdbarch_short_bit (gdbarch, 16);
Index: frv-tdep.h
===================================================================
RCS file: frv-tdep.h
diff -N frv-tdep.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ frv-tdep.h	13 Mar 2004 00:05:30 -0000
@@ -0,0 +1,35 @@
+/* Architecture-dependent code for the Fujitsu FR-V, for GDB, the GNU Debugger.
+   Copyright 2004 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* Enumerate the possible ABIs for FR-V.  */
+enum frv_abi
+  {
+    FRV_ABI_EABI,
+    FRV_ABI_FDPIC
+  };
+
+/* Return the FR-V ABI associated with GDBARCH.  */
+enum frv_abi frv_abi (struct gdbarch *gdbarch);
+
+/* Fetch the interpreter and executable loadmap addresses (for shared
+   library support) for the FDPIC ABI.  Return 0 if successful, -1 if
+   not.  (E.g, -1 will be returned if the ABI isn't the FDPIC ABI.)  */
+int frv_fdpic_loadmap_addresses (struct gdbarch *gdbarch,
+                                 CORE_ADDR *interp_addr, CORE_ADDR *exec_addr);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]