This is the mail archive of the gdb-patches@sourceware.org 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]

[rfc] Remove mips/tm-linux.h


While working on mips64-linux more today, I decided to remove its
DEPRECATED_TM_FILE setting.  The problem was that it overrode
IN_SOLIB_DYNSYM_RESOLVE_CODE, which isn't a gdbarch method; it lives
in the solib_ops instead.

The reason for this is that lazy binding stubs live in .text or
.MIPS.stubs, at least for some versions of mips-linux, instead of the
traditional ".plt" name.  So, I added a way to override the svr4 solib
ops specifically for this target:

+/* Set the solib operations for GDBARCH to NEW_OPS.  */
+
+extern void set_solib_ops (struct gdbarch *gdbarch,
+			   struct target_so_ops *new_ops);

Ulrich, I copied you because I suspect current_target_so_ops is on
your plan of attack somewhere.  Does this look reasonable?  If every
target did this, we could remove current_target_so_ops.

Tested on mips64-linux, all three ABIs, no change in results.

-- 
Daniel Jacobowitz
CodeSourcery

2007-05-01  Daniel Jacobowitz  <dan@codesourcery.com>

	* config/mips/linux.mt (DEPRECATED_TM_FILE): Delete.
	* config/mips/tm-linux.h: Delete.
	* mips-linux-tdep.c (mips_svr4_so_ops): New.
	(mips_linux_in_dynsym_resolve_code): Make static.  Use
	svr4_in_dynsym_resolve_code.
	(mips_linux_init_abi): Initialize mips_svr4_so_ops.  Call
	set_solib_ops.
	* solib-svr4.c (svr4_in_dynsym_resolve_code, svr4_so_ops): Make
	global.
	* solib-svr4.h (svr4_so_ops, svr4_in_dynsym_resolve_code): Declare.
	* Makefile.in (mips-linux-tdep.o): Update.
	* solib.c (set_solib_ops): New.
	(current_target_so_ops): Update comment.
	* solib.h (set_solib_ops): New prototype.

---
 Makefile.in            |    2 +-
 config/mips/linux.mt   |    1 -
 config/mips/tm-linux.h |   29 -----------------------------
 mips-linux-tdep.c      |   18 ++++++++++++++++--
 solib-svr4.c           |    4 ++--
 solib-svr4.h           |    7 +++++++
 solib.c                |   12 +++++++++++-
 solib.h                |    6 ++++++
 8 files changed, 43 insertions(+), 36 deletions(-)

Index: gdb/config/mips/linux.mt
===================================================================
--- gdb.orig/config/mips/linux.mt	2007-05-01 09:16:13.000000000 -0400
+++ gdb/config/mips/linux.mt	2007-05-01 09:16:45.000000000 -0400
@@ -1,7 +1,6 @@
 # Target: Linux/MIPS
 TDEPFILES= mips-tdep.o mips-linux-tdep.o corelow.o \
 	solib.o solib-svr4.o symfile-mem.o
-DEPRECATED_TM_FILE= tm-linux.h
 
 SIM_OBS = remote-sim.o
 SIM = ../sim/mips/libsim.a
Index: gdb/config/mips/tm-linux.h
===================================================================
--- gdb.orig/config/mips/tm-linux.h	2007-05-01 09:16:11.000000000 -0400
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,29 +0,0 @@
-/* Target-dependent definitions for GNU/Linux MIPS.
-
-   Copyright 2001, 2002, 2004, 2007 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.  */
-
-#ifndef TM_MIPSLINUX_H
-#define TM_MIPSLINUX_H
-
-#undef IN_SOLIB_DYNSYM_RESOLVE_CODE
-#define IN_SOLIB_DYNSYM_RESOLVE_CODE(PC) mips_linux_in_dynsym_resolve_code (PC)
-int mips_linux_in_dynsym_resolve_code (CORE_ADDR pc);
-
-#endif /* TM_MIPSLINUX_H */
Index: gdb/mips-linux-tdep.c
===================================================================
--- gdb.orig/mips-linux-tdep.c	2007-05-01 09:16:05.000000000 -0400
+++ gdb/mips-linux-tdep.c	2007-05-01 10:29:30.000000000 -0400
@@ -34,9 +34,13 @@
 #include "tramp-frame.h"
 #include "gdbtypes.h"
 #include "solib.h"
+#include "solib-svr4.h"
+#include "solist.h"
 #include "symtab.h"
 #include "mips-linux-tdep.h"
 
+static struct target_so_ops mips_svr4_so_ops;
+
 /* Figure out where the longjmp will land.
    We expect the first arg to be a pointer to the jmp_buf structure
    from which we extract the pc (MIPS_LINUX_JB_PC) that we will land
@@ -595,12 +599,12 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc,
 /* Return non-zero iff PC belongs to the dynamic linker resolution
    code or to a stub.  */
 
-int
+static int
 mips_linux_in_dynsym_resolve_code (CORE_ADDR pc)
 {
   /* Check whether PC is in the dynamic linker.  This also checks
      whether it is in the .plt section, which MIPS does not use.  */
-  if (in_solib_dynsym_resolve_code (pc))
+  if (svr4_in_dynsym_resolve_code (pc))
     return 1;
 
   /* Pattern match for the stub.  It would be nice if there were a
@@ -1038,6 +1042,16 @@ mips_linux_init_abi (struct gdbarch_info
   /* Enable TLS support.  */
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
                                              svr4_fetch_objfile_link_map);
+
+  /* Initialize this lazily, to avoid an initialization order
+     dependency on solib-svr4.c's _initialize routine.  */
+  if (mips_svr4_so_ops.in_dynsym_resolve_code == NULL)
+    {
+      mips_svr4_so_ops = svr4_so_ops;
+      mips_svr4_so_ops.in_dynsym_resolve_code
+	= mips_linux_in_dynsym_resolve_code;
+    }
+  set_solib_ops (gdbarch, &mips_svr4_so_ops);
 }
 
 void
Index: gdb/solib-svr4.c
===================================================================
--- gdb.orig/solib-svr4.c	2007-05-01 09:25:36.000000000 -0400
+++ gdb/solib-svr4.c	2007-05-01 09:26:13.000000000 -0400
@@ -901,7 +901,7 @@ static CORE_ADDR interp_text_sect_high;
 static CORE_ADDR interp_plt_sect_low;
 static CORE_ADDR interp_plt_sect_high;
 
-static int
+int
 svr4_in_dynsym_resolve_code (CORE_ADDR pc)
 {
   return ((pc >= interp_text_sect_low && pc < interp_text_sect_high)
@@ -1556,7 +1556,7 @@ svr4_lp64_fetch_link_map_offsets (void)
 }
 
 
-static struct target_so_ops svr4_so_ops;
+struct target_so_ops svr4_so_ops;
 
 extern initialize_file_ftype _initialize_svr4_solib; /* -Wmissing-prototypes */
 
Index: gdb/solib-svr4.h
===================================================================
--- gdb.orig/solib-svr4.h	2007-05-01 09:25:41.000000000 -0400
+++ gdb/solib-svr4.h	2007-05-01 09:26:59.000000000 -0400
@@ -23,6 +23,9 @@
 #define SOLIB_SVR4_H
 
 struct objfile;
+struct target_so_ops;
+
+extern struct target_so_ops svr4_so_ops;
 
 /* Critical offsets and sizes which describe struct r_debug and
    struct link_map on SVR4-like targets.  All offsets and sizes are
@@ -81,4 +84,8 @@ extern struct link_map_offsets *(*legacy
 extern struct link_map_offsets *svr4_ilp32_fetch_link_map_offsets (void);
 extern struct link_map_offsets *svr4_lp64_fetch_link_map_offsets (void);
 
+/* Return 1 if PC lies in the dynamic symbol resolution code of the
+   SVR4 run time loader.  */
+int svr4_in_dynsym_resolve_code (CORE_ADDR pc);
+
 #endif /* solib-svr4.h */
Index: gdb/Makefile.in
===================================================================
--- gdb.orig/Makefile.in	2007-05-01 10:13:20.000000000 -0400
+++ gdb/Makefile.in	2007-05-01 10:13:27.000000000 -0400
@@ -2347,7 +2347,7 @@ mips-linux-tdep.o: mips-linux-tdep.c $(d
 	$(solib_svr4_h) $(osabi_h) $(mips_tdep_h) $(gdb_string_h) \
 	$(gdb_assert_h) $(frame_h) $(regcache_h) $(trad_frame_h) \
 	$(tramp_frame_h) $(gdbtypes_h) $(solib_h) $(symtab_h) \
-	$(mips_linux_tdep_h)
+	$(mips_linux_tdep_h) $(solist_h) $(solib_svr4_h)
 mipsnbsd-nat.o: mipsnbsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
 	$(target_h) $(mips_tdep_h) $(mipsnbsd_tdep_h) $(inf_ptrace_h)
 mipsnbsd-tdep.o: mipsnbsd-tdep.c $(defs_h) $(gdbcore_h) $(regcache_h) \
Index: gdb/solib.c
===================================================================
--- gdb.orig/solib.c	2007-05-01 10:18:21.000000000 -0400
+++ gdb/solib.c	2007-05-01 10:24:27.000000000 -0400
@@ -67,11 +67,21 @@ solib_ops (struct gdbarch *gdbarch)
   struct target_so_ops **ops = gdbarch_data (gdbarch, solib_data);
   return *ops;
 }
+
+/* Set the solib operations for GDBARCH to NEW_OPS.  */
+
+void
+set_solib_ops (struct gdbarch *gdbarch, struct target_so_ops *new_ops)
+{
+  struct target_so_ops **ops = gdbarch_data (gdbarch, solib_data);
+  *ops = new_ops;
+}
 
 
 /* external data declarations */
 
-/* FIXME: gdbarch needs to control this variable */
+/* FIXME: gdbarch needs to control this variable, or else every
+   configuration needs to call set_solib_ops.  */
 struct target_so_ops *current_target_so_ops;
 
 /* local data declarations */
Index: gdb/solib.h
===================================================================
--- gdb.orig/solib.h	2007-05-01 10:19:38.000000000 -0400
+++ gdb/solib.h	2007-05-01 10:28:29.000000000 -0400
@@ -26,6 +26,7 @@
 /* Forward decl's for prototypes */
 struct so_list;
 struct target_ops;
+struct target_so_ops;
 
 /* Called when we free all symtabs, to free the shared library information
    as well. */
@@ -57,4 +58,9 @@ extern int in_solib_dynsym_resolve_code 
 
 extern void no_shared_libraries (char *ignored, int from_tty);
 
+/* Set the solib operations for GDBARCH to NEW_OPS.  */
+
+extern void set_solib_ops (struct gdbarch *gdbarch,
+			   struct target_so_ops *new_ops);
+
 #endif /* SOLIB_H */


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