aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib-legacy.c
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2001-03-10 06:17:24 +0000
committerKevin Buettner <kevinb@redhat.com>2001-03-10 06:17:24 +0000
commit21479deda01ad5fe23f41c69a46c10b7806ca5fa (patch)
tree1778b3af8b9df4d6a34af9efb6987d306e6d66e2 /gdb/solib-legacy.c
parentd7fa9de08de666af5647be3053c6b3f04996277b (diff)
downloadgdb-21479deda01ad5fe23f41c69a46c10b7806ca5fa.zip
gdb-21479deda01ad5fe23f41c69a46c10b7806ca5fa.tar.gz
gdb-21479deda01ad5fe23f41c69a46c10b7806ca5fa.tar.bz2
Cleanup solib-svr4.c by moving legacy code out to its own file.
Diffstat (limited to 'gdb/solib-legacy.c')
-rw-r--r--gdb/solib-legacy.c127
1 files changed, 127 insertions, 0 deletions
diff --git a/gdb/solib-legacy.c b/gdb/solib-legacy.c
new file mode 100644
index 0000000..29ed014
--- /dev/null
+++ b/gdb/solib-legacy.c
@@ -0,0 +1,127 @@
+/* Provide legacy r_debug and link_map support for SVR4-like native targets.
+ Copyright 2000, 2001
+ 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. */
+
+#define _SYSCALL32 /* for Sparc64 cross Sparc32 */
+#include "defs.h"
+#include "gdbcore.h"
+#include "solib-svr4.h"
+
+#ifdef HAVE_LINK_H
+#include <link.h>
+
+/* Fetch (and possibly build) an appropriate link_map_offsets structure
+ for native targets using struct definitions from link.h. */
+
+static struct link_map_offsets *
+legacy_svr4_fetch_link_map_offsets (void)
+{
+ static struct link_map_offsets lmo;
+ static struct link_map_offsets *lmp = 0;
+#if defined (HAVE_STRUCT_LINK_MAP32)
+ static struct link_map_offsets lmo32;
+ static struct link_map_offsets *lmp32 = 0;
+#endif
+
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
+#endif
+#define fieldsize(TYPE, MEMBER) (sizeof (((TYPE *)0)->MEMBER))
+
+ if (lmp == 0)
+ {
+ lmp = &lmo;
+
+#ifdef SVR4_SHARED_LIBS
+ lmo.r_debug_size = sizeof (struct r_debug);
+
+ lmo.r_map_offset = offsetof (struct r_debug, r_map);
+ lmo.r_map_size = fieldsize (struct r_debug, r_map);
+
+ lmo.link_map_size = sizeof (struct link_map);
+
+ lmo.l_addr_offset = offsetof (struct link_map, l_addr);
+ lmo.l_addr_size = fieldsize (struct link_map, l_addr);
+
+ lmo.l_next_offset = offsetof (struct link_map, l_next);
+ lmo.l_next_size = fieldsize (struct link_map, l_next);
+
+ lmo.l_prev_offset = offsetof (struct link_map, l_prev);
+ lmo.l_prev_size = fieldsize (struct link_map, l_prev);
+
+ lmo.l_name_offset = offsetof (struct link_map, l_name);
+ lmo.l_name_size = fieldsize (struct link_map, l_name);
+#else /* !SVR4_SHARED_LIBS */
+ lmo.link_map_size = sizeof (struct link_map);
+
+ lmo.l_addr_offset = offsetof (struct link_map, lm_addr);
+ lmo.l_addr_size = fieldsize (struct link_map, lm_addr);
+
+ lmo.l_next_offset = offsetof (struct link_map, lm_next);
+ lmo.l_next_size = fieldsize (struct link_map, lm_next);
+
+ lmo.l_name_offset = offsetof (struct link_map, lm_name);
+ lmo.l_name_size = fieldsize (struct link_map, lm_name);
+#endif /* SVR4_SHARED_LIBS */
+ }
+
+#if defined (HAVE_STRUCT_LINK_MAP32)
+ if (lmp32 == 0)
+ {
+ lmp32 = &lmo32;
+
+ lmo32.r_debug_size = sizeof (struct r_debug32);
+
+ lmo32.r_map_offset = offsetof (struct r_debug32, r_map);
+ lmo32.r_map_size = fieldsize (struct r_debug32, r_map);
+
+ lmo32.link_map_size = sizeof (struct link_map32);
+
+ lmo32.l_addr_offset = offsetof (struct link_map32, l_addr);
+ lmo32.l_addr_size = fieldsize (struct link_map32, l_addr);
+
+ lmo32.l_next_offset = offsetof (struct link_map32, l_next);
+ lmo32.l_next_size = fieldsize (struct link_map32, l_next);
+
+ lmo32.l_prev_offset = offsetof (struct link_map32, l_prev);
+ lmo32.l_prev_size = fieldsize (struct link_map32, l_prev);
+
+ lmo32.l_name_offset = offsetof (struct link_map32, l_name);
+ lmo32.l_name_size = fieldsize (struct link_map32, l_name);
+ }
+#endif /* defined (HAVE_STRUCT_LINK_MAP32) */
+
+#if defined (HAVE_STRUCT_LINK_MAP32)
+ if (bfd_get_arch_size (exec_bfd) == 32)
+ return lmp32;
+ else
+#endif
+ return lmp;
+}
+
+#endif /* HAVE_LINK_H */
+
+void
+_initialize_svr4_lm (void)
+{
+#ifdef HAVE_LINK_H
+ legacy_svr4_fetch_link_map_offsets_hook = legacy_svr4_fetch_link_map_offsets;
+#endif /* HAVE_LINK_H */
+}