This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH]: Extend SVR4 shlib debug changes to SH3 and other targets
- To: gdb-patches at sourceware dot cygnus dot com, kevinb at cygnus dot com
- Subject: [PATCH]: Extend SVR4 shlib debug changes to SH3 and other targets
- From: Michael Snyder <msnyder at cygnus dot com>
- Date: Mon, 30 Oct 2000 17:02:01 -0800 (PST)
This change moves the definition of SVR4_SHARED_LIBS into
config/tm-linux.h, so that it will affect all linuxen.
I then add a new file config/sh/tm-linux.h which includes
config/tm-linux.h (as well as sh/tm-sh.h). Finally I add
target-specific definitions of fetch_link_map_offsets, so
that shared libraries can be cross-debugged.
2000-10-30 Michael Snyder <msnyder@cleaver.cygnus.com>
* config/sh/tm-linux.h: New file. Include generic tm-linux.h,
plus tm-sh.h, then define SVR4_FETCH_LINK_MAP_OFFSETS to use
the sh target function instead of the default link map offsets.
* config/sh/sh.mt: Add solib.o and solib-svr4.o to TDEPFILES.
Use sh/tm-linux.h instead of sh/tm-sh.h.
* sh-tdep.c (sh_linux_svr4_fetch_link_map_offsets):
New function. Construct target-specific link map offsets.
* i386-linux-tdep.c (i386_linux_svr4_fetch_link_map_offsets:
New function. Construct target-specific link map offsets.
* config/i386/tm-linux.h: Use above function instead of default.
2000-10-30 Michael Snyder <msnyder@cleaver.cygnus.com>
* config/i386/tm-linux.h: Remove definition of SVR4_SHARED_LIBS,
and inclusion of solib.h. Move up into ../tm-linux.h.
config/tm-linux.h: Define SVR4_SHARED_LIBS, include solib.h.
Index: config/sh/sh.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/sh/sh.mt,v
retrieving revision 1.1.1.1
diff -c -3 -p -r1.1.1.1 sh.mt
*** sh.mt 1999/04/16 01:34:25 1.1.1.1
--- sh.mt 2000/10/31 00:57:12
***************
*** 1,6 ****
# Target: Hitachi Super-H with ICE and simulator
! TDEPFILES= sh-tdep.o monitor.o sh3-rom.o remote-e7000.o ser-e7kpc.o dsrec.o
! TM_FILE= tm-sh.h
SIM_OBS = remote-sim.o
SIM = ../sim/sh/libsim.a
--- 1,6 ----
# Target: Hitachi Super-H with ICE and simulator
! TDEPFILES= sh-tdep.o monitor.o sh3-rom.o remote-e7000.o ser-e7kpc.o dsrec.o solib.o solib-svr4.o
! TM_FILE= tm-linux.h
SIM_OBS = remote-sim.o
SIM = ../sim/sh/libsim.a
Index: sh-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.c,v
retrieving revision 1.14
diff -c -3 -p -r1.14 sh-tdep.c
*** sh-tdep.c 2000/07/31 16:25:36 1.14
--- sh-tdep.c 2000/10/31 00:57:12
***************
*** 39,44 ****
--- 39,46 ----
#include "arch-utils.h"
#include "floatformat.h"
+ #include "solib-svr4.h"
+
#undef XMALLOC
#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
*************** sh_do_registers_info (int regnum, int fp
*** 1797,1802 ****
--- 1799,1848 ----
}
}
}
+
+ #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 gdbarch_init_ftype sh_gdbarch_init;
Index: i386-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-linux-tdep.c,v
retrieving revision 1.2
diff -c -3 -p -r1.2 i386-linux-tdep.c
*** i386-linux-tdep.c 2000/08/29 23:31:10 1.2
--- i386-linux-tdep.c 2000/10/31 00:57:12
***************
*** 27,32 ****
--- 27,33 ----
#include "symtab.h"
#include "symfile.h"
#include "objfiles.h"
+ #include "solib-svr4.h" /* for struct link_map_offsets */
/* Recognizing signal handler frames. */
*************** i386_linux_skip_solib_resolver (CORE_ADD
*** 372,374 ****
--- 373,417 ----
return 0;
}
+
+ /* 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 *
+ i386_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;
+ }
+
Index: config/i386/tm-linux.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/tm-linux.h,v
retrieving revision 1.8
diff -c -3 -p -r1.8 tm-linux.h
*** tm-linux.h 2000/08/10 17:04:33 1.8
--- tm-linux.h 2000/10/31 00:57:12
***************
*** 30,35 ****
--- 30,39 ----
#include "i386/tm-i386.h"
#include "tm-linux.h"
+ /* Use target_specific function to define link map offsets. */
+ extern struct link_map_offsets *i386_linux_svr4_fetch_link_map_offsets (void);
+ #define SVR4_FETCH_LINK_MAP_OFFSETS() i386_linux_svr4_fetch_link_map_offsets ()
+
/* FIXME: kettenis/2000-03-26: We should get rid of this last piece of
Linux-specific `long double'-support code, probably by adding code
to valprint.c:print_floating() to recognize various extended
Index: config/tm-linux.h
===================================================================
RCS file: /cvs/src/src/gdb/config/tm-linux.h,v
retrieving revision 1.1.1.1
diff -c -3 -p -r1.1.1.1 tm-linux.h
*** tm-linux.h 1999/12/07 03:56:08 1.1.1.1
--- tm-linux.h 2000/10/31 00:57:12
***************
*** 34,36 ****
--- 34,42 ----
/* We need this file for the SOLIB_TRAMPOLINE stuff. */
#include "tm-sysv4.h"
+
+ /* We define this if link.h is available, because with ELF we use SVR4 style
+ shared libraries. FIXME: move up into config/tm-linux.h? */
+
+ #define SVR4_SHARED_LIBS
+ #include "solib.h" /* Support for shared libraries. */
[and here is sh/tm-linux.h]
/* Target-specific definitions for Linux running on a Hitachi Super-H.
Copyright (C) 2000 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. */
/* Pull in Linux generic defs */
#include "tm-linux.h"
/* 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 ()