[PATCH] sh_linux_svr4_fetch_link_map_offsets fixups for sh/sh64

Paul Mundt lethal@linux-sh.org
Sun Jul 4 13:20:00 GMT 2004


Current CVS fails to build when targetted for sh-linux (or in this case,
sh2eb-linux) due to both sh-tdep.c and sh64-tdep.c defining their own
versions of sh_linux_svr4_fetch_link_map_offsets():

gcc -g -O2       \
        -o gdb gdb.o libgdb.a \
          ../sim/sh/libsim.a ../bfd/libbfd.a ../readline/libreadline.a ../opcodes/libopcodes.a  ../libiberty/libiberty.a    ../libgui/src/libgui.a -L/home/lethal/build/tc/build-gnu/itcl/itcl -litcl3.2 -L/home/lethal/build/tc/build-gnu/itcl/itk -litk3.2 -L/home/lethal/build/tc/build-gnu/tk/unix -ltk8.4 -Wl,-rpath,/opt/tc/sh2eb-linux/lib -L/home/lethal/build/tc/build-gnu/tcl/unix -ltcl8.4   -L/usr/X11R6/lib -lX11 -ldl  -lieee -lm -lncurses -ltermcap -lm  ../libiberty/libiberty.a  -ldl -rdynamic
libgdb.a(sh64-tdep.o)(.text+0x3434): In function `sh_linux_svr4_fetch_link_map_offsets':
/home/lethal/devel/cvs/gnu/gdb/sh64-tdep.c:2755: multiple definition of `sh_linux_svr4_fetch_link_map_offsets'
libgdb.a(sh-tdep.o)(.text+0x2c28):/home/lethal/devel/cvs/gnu/gdb/sh-tdep.c:1843: first defined here
collect2: ld returned 1 exit status
make[1]: *** [gdb] Error 1
make[1]: Leaving directory `/home/lethal/build/tc/build-gnu/gdb'
make: *** [all-gdb] Error 2

After looking over both of these, they're exactly the same. However, when
I removed one copy and then ran gdb it complained about not having a
GNU/Linux OSABI registered. Since it doesn't seem likely that we want
sh_linux_xxx() routines literring the top-level tdep, I've moved this
into sh-linux-tdep.c and setup a GNU/Linux OSABI registration.

sh64-linux should still work fine with this, though I've only done a
build for sh2eb-linux. Though since sh-tdep.c is the caller of
sh64_gdbarch_init() and the OSABI hooks bfd_arch_sh, it doesn't seem
like anything should be visibly broken.

 Makefile.in          |    3 ++
 config/sh/linux.mt   |    4 ++
 config/sh/tm-linux.h |    4 --
 sh-linux-tdep.c      |   73 +++++++++++++++++++++++++++++++++++++++++++++++++++
 sh-tdep.c            |   44 ------------------------------
 sh64-tdep.c          |   44 ------------------------------
 6 files changed, 79 insertions(+), 93 deletions(-)

Index: gdb/config/sh/linux.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/sh/linux.mt,v
retrieving revision 1.6
diff -u -p -r1.6 linux.mt
--- gdb/config/sh/linux.mt	10 Oct 2003 07:13:11 -0000	1.6
+++ gdb/config/sh/linux.mt	4 Jul 2004 13:07:20 -0000
@@ -1,5 +1,7 @@
 # Target: Renesas Super-H running GNU/Linux
-TDEPFILES= sh-tdep.o sh64-tdep.o monitor.o sh3-rom.o remote-e7000.o ser-e7kpc.o dsrec.o solib.o solib-svr4.o solib-legacy.o
+TDEPFILES= sh-tdep.o sh-linux-tdep.o sh64-tdep.o monitor.o \
+	   sh3-rom.o remote-e7000.o ser-e7kpc.o dsrec.o \
+	   solib.o solib-svr4.o solib-legacy.o
 TM_FILE= tm-linux.h
 
 SIM_OBS = remote-sim.o
Index: gdb/config/sh/tm-linux.h
===================================================================
RCS file: /cvs/src/src/gdb/config/sh/tm-linux.h,v
retrieving revision 1.5
diff -u -p -r1.5 tm-linux.h
--- gdb/config/sh/tm-linux.h	10 Oct 2003 07:13:11 -0000	1.5
+++ gdb/config/sh/tm-linux.h	4 Jul 2004 13:07:30 -0000
@@ -26,7 +26,3 @@
 /* Pull in sh-target defs */
 #include "sh/tm-sh.h"
 
-/* Use target_specific function to define link map offsets.  */
-extern struct link_map_offsets *sh_linux_svr4_fetch_link_map_offsets (void);
-#define SVR4_FETCH_LINK_MAP_OFFSETS() sh_linux_svr4_fetch_link_map_offsets ()
-
Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.594
diff -u -p -r1.594 Makefile.in
--- gdb/Makefile.in	3 Jul 2004 15:14:47 -0000	1.594
+++ gdb/Makefile.in	4 Jul 2004 13:08:03 -0000
@@ -1398,6 +1398,7 @@ ALLDEPFILES = \
 	s390-tdep.c s390-nat.c \
 	ser-go32.c ser-pipe.c ser-tcp.c \
 	sh-tdep.c sh64-tdep.c shnbsd-tdep.c shnbsd-nat.c \
+	sh-linux-tdep.c \
 	solib.c solib-irix.c solib-svr4.c solib-sunos.c \
 	sparc-linux-tdep.c sparc-nat.c sparc-sol2-nat.c sparc-sol2-tdep.c \
 	sparc-tdep.c sparc-sol2-nat.c sparc-sol2-tdep.c sparc64-linux-nat.c \
@@ -2368,6 +2369,8 @@ sh-tdep.o: sh-tdep.c $(defs_h) $(frame_h
 	$(gdb_assert_h) $(arch_utils_h) $(floatformat_h) $(regcache_h) \
 	$(doublest_h) $(osabi_h) $(sh_tdep_h) $(elf_bfd_h) $(solib_svr4_h) \
 	$(elf_sh_h) $(gdb_sim_sh_h)
+sh-linux-tdep.o: sh-linux-tdep.c $(defs_h) $(gdbarch_h) $(osabi_h) \
+	$(solib_svr4_h) $(sh_tdep_h)
 solib-aix5.o: solib-aix5.c $(defs_h) $(gdb_string_h) $(elf_external_h) \
 	$(symtab_h) $(bfd_h) $(symfile_h) $(objfiles_h) $(gdbcore_h) \
 	$(command_h) $(target_h) $(frame_h) $(gdb_regex_h) $(inferior_h) \
Index: gdb/sh-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.c,v
retrieving revision 1.170
diff -u -p -r1.170 sh-tdep.c
--- gdb/sh-tdep.c	20 Jun 2004 17:18:06 -0000	1.170
+++ gdb/sh-tdep.c	4 Jul 2004 13:08:25 -0000
@@ -1824,50 +1824,6 @@ sh_print_registers_info (struct gdbarch 
     }
 }
 
-#ifdef SVR4_SHARED_LIBS
-
-/* Fetch (and possibly build) an appropriate link_map_offsets structure
-   for native i386 linux targets using the struct offsets defined in
-   link.h (but without actual reference to that file).
-
-   This makes it possible to access i386-linux shared libraries from
-   a gdb that was not built on an i386-linux host (for cross debugging).
-   */
-
-struct link_map_offsets *
-sh_linux_svr4_fetch_link_map_offsets (void)
-{
-  static struct link_map_offsets lmo;
-  static struct link_map_offsets *lmp = 0;
-
-  if (lmp == 0)
-    {
-      lmp = &lmo;
-
-      lmo.r_debug_size = 8;	/* 20 not actual size but all we need */
-
-      lmo.r_map_offset = 4;
-      lmo.r_map_size = 4;
-
-      lmo.link_map_size = 20;	/* 552 not actual size but all we need */
-
-      lmo.l_addr_offset = 0;
-      lmo.l_addr_size = 4;
-
-      lmo.l_name_offset = 4;
-      lmo.l_name_size = 4;
-
-      lmo.l_next_offset = 12;
-      lmo.l_next_size = 4;
-
-      lmo.l_prev_offset = 16;
-      lmo.l_prev_size = 4;
-    }
-
-  return lmp;
-}
-#endif /* SVR4_SHARED_LIBS */
-
 static int
 sh_dsp_register_sim_regno (int nr)
 {
Index: gdb/sh64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh64-tdep.c,v
retrieving revision 1.29
diff -u -p -r1.29 sh64-tdep.c
--- gdb/sh64-tdep.c	20 Jun 2004 17:18:06 -0000	1.29
+++ gdb/sh64-tdep.c	4 Jul 2004 13:08:55 -0000
@@ -2736,50 +2736,6 @@ sh64_do_registers_info (int regnum, int 
    sh_compact_do_registers_info (regnum, fpregs);
 }
 
-#ifdef SVR4_SHARED_LIBS
-
-/* Fetch (and possibly build) an appropriate link_map_offsets structure
-   for native i386 linux targets using the struct offsets defined in
-   link.h (but without actual reference to that file).
-
-   This makes it possible to access i386-linux shared libraries from
-   a gdb that was not built on an i386-linux host (for cross debugging).
-   */
-
-struct link_map_offsets *
-sh_linux_svr4_fetch_link_map_offsets (void)
-{
-  static struct link_map_offsets lmo;
-  static struct link_map_offsets *lmp = 0;
-
-  if (lmp == 0)
-    {
-      lmp = &lmo;
-
-      lmo.r_debug_size = 8;	/* 20 not actual size but all we need */
-
-      lmo.r_map_offset = 4;
-      lmo.r_map_size   = 4;
-
-      lmo.link_map_size = 20;	/* 552 not actual size but all we need */
-
-      lmo.l_addr_offset = 0;
-      lmo.l_addr_size   = 4;
-
-      lmo.l_name_offset = 4;
-      lmo.l_name_size   = 4;
-
-      lmo.l_next_offset = 12;
-      lmo.l_next_size   = 4;
-
-      lmo.l_prev_offset = 16;
-      lmo.l_prev_size   = 4;
-    }
-
-    return lmp;
-}
-#endif /* SVR4_SHARED_LIBS */
-
 gdbarch_init_ftype sh64_gdbarch_init;
 
 struct gdbarch *
--- /dev/null	2004-02-23 16:02:56.000000000 -0500
+++ gdb/sh-linux-tdep.c	2004-07-04 08:48:27.000000000 -0400
@@ -0,0 +1,73 @@
+/* Target-dependent code for GNU/Linux Renesas SuperH.
+
+   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.  */
+
+#include "defs.h"
+#include "gdbarch.h"
+#include "osabi.h"
+#include "solib-svr4.h"
+
+#include "sh-tdep.h"
+
+static struct link_map_offsets *
+sh_linux_svr4_fetch_link_map_offsets (void)
+{
+  static struct link_map_offsets lmo;
+  static struct link_map_offsets *lmp = 0;
+
+  if (lmp == 0)
+    {
+      lmp = &lmo;
+
+      lmo.r_debug_size = 8;	/* 20 not actual size but all we need */
+
+      lmo.r_map_offset = 4;
+      lmo.r_map_size = 4;
+
+      lmo.link_map_size = 20;	/* 552 not actual size but all we need */
+
+      lmo.l_addr_offset = 0;
+      lmo.l_addr_size = 4;
+
+      lmo.l_name_offset = 4;
+      lmo.l_name_size = 4;
+
+      lmo.l_next_offset = 12;
+      lmo.l_next_size = 4;
+
+      lmo.l_prev_offset = 16;
+      lmo.l_prev_size = 4;
+    }
+
+  return lmp;
+}
+
+static void
+sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  set_solib_svr4_fetch_link_map_offsets
+    (gdbarch, sh_linux_svr4_fetch_link_map_offsets);
+}
+
+void
+_initialize_sh_linux_tdep (void)
+{
+  gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_LINUX, sh_linux_init_abi);
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20040704/4b83c9fd/attachment.sig>


More information about the Gdb-patches mailing list