This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Common ILP32 and LP64 link map offsets
- From: Mark Kettenis <kettenis at chello dot nl>
- To: gdb-patches at sources dot redhat dot com
- Cc: kevinb at redhat dot com
- Date: Sat, 21 Feb 2004 19:34:48 +0100 (CET)
- Subject: [PATCH] Common ILP32 and LP64 link map offsets
OK, I found myself adding yet another fetch_link_map_offsets that was
basically the same as all the other ones in GDB. Turns out that there
basically two versions of this stuff, on for 32-bit systems and one
for 64-bit systems, with only a few exceptions. The NetBSD folks
already discovered this of course.
I believe this patch is pretty obvious, so I went ahead and committed
it.
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* solib-svr4.h: Update copyright year.
(svr4_ilp32_fetch_link_map_offsets)
(svr4_lp64_fetch_link_map_offsets): New prototype.
* solib-svr4.c: Update copyright year.
(svr4_ilp32_fetch_link_map_offsets)
(svr4_lp64_fetch_link_map_offsets): New function.
Index: solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.40
diff -u -p -r1.40 solib-svr4.c
--- solib-svr4.c 8 Nov 2003 00:13:02 -0000 1.40
+++ solib-svr4.c 21 Feb 2004 18:33:47 -0000
@@ -1,7 +1,8 @@
/* Handle SVR4 shared libraries for GDB, the GNU Debugger.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
- 2000, 2001, 2003 Free Software Foundation, Inc.
+ 2000, 2001, 2003, 2004
+ Free Software Foundation, Inc.
This file is part of GDB.
@@ -1507,6 +1508,77 @@ init_fetch_link_map_offsets (struct gdba
{
return legacy_fetch_link_map_offsets;
}
+
+/* Most OS'es that have SVR4-style ELF dynamic libraries define a
+ `struct r_debug' and a `struct link_map' that are binary compatible
+ with the origional SVR4 implementation. */
+
+/* Fetch (and possibly build) an appropriate `struct link_map_offsets'
+ for an ILP32 SVR4 system. */
+
+struct link_map_offsets *
+svr4_ilp32_fetch_link_map_offsets (void)
+{
+ static struct link_map_offsets lmo;
+ static struct link_map_offsets *lmp = NULL;
+
+ if (lmp == NULL)
+ {
+ lmp = &lmo;
+
+ /* Everything we need is in the first 8 bytes. */
+ lmo.r_debug_size = 8;
+ lmo.r_map_offset = 4;
+ lmo.r_map_size = 4;
+
+ /* Everything we need is in the first 20 bytes. */
+ lmo.link_map_size = 20;
+ 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;
+}
+
+/* Fetch (and possibly build) an appropriate `struct link_map_offsets'
+ for an LP64 SVR4 system. */
+
+struct link_map_offsets *
+svr4_lp64_fetch_link_map_offsets (void)
+{
+ static struct link_map_offsets lmo;
+ static struct link_map_offsets *lmp = NULL;
+
+ if (lmp == NULL)
+ {
+ lmp = &lmo;
+
+ /* Everything we need is in the first 16 bytes. */
+ lmo.r_debug_size = 16;
+ lmo.r_map_offset = 8;
+ lmo.r_map_size = 8;
+
+ /* Everything we need is in the first 40 bytes. */
+ lmo.link_map_size = 40;
+ lmo.l_addr_offset = 0;
+ lmo.l_addr_size = 8;
+ lmo.l_name_offset = 8;
+ lmo.l_name_size = 8;
+ lmo.l_next_offset = 24;
+ lmo.l_next_size = 8;
+ lmo.l_prev_offset = 32;
+ lmo.l_prev_size = 8;
+ }
+
+ return lmp;
+}
+
static struct target_so_ops svr4_so_ops;
Index: solib-svr4.h
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.h,v
retrieving revision 1.5
diff -u -p -r1.5 solib-svr4.h
--- solib-svr4.h 12 Apr 2003 17:41:25 -0000 1.5
+++ solib-svr4.h 21 Feb 2004 18:33:47 -0000
@@ -1,5 +1,6 @@
/* Handle shared libraries for GDB, the GNU Debugger.
- Copyright 2000
+
+ Copyright 2000, 2004
Free Software Foundation, Inc.
This file is part of GDB.
@@ -82,3 +83,8 @@ extern CORE_ADDR svr4_fetch_objfile_link
which is used to fetch link map offsets. It will only be set
by solib-legacy.c, if at all. */
extern struct link_map_offsets *(*legacy_svr4_fetch_link_map_offsets_hook)(void);
+
+/* Fetch (and possibly build) an appropriate `struct link_map_offsets'
+ for ILP32 and LP64 SVR4 systems. */
+extern struct link_map_offsets *svr4_ilp32_fetch_link_map_offsets (void);
+extern struct link_map_offsets *svr4_lp64_fetch_link_map_offsets (void);