aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib-svr4.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2009-12-01 22:46:15 +0000
committerJoseph Myers <joseph@codesourcery.com>2009-12-01 22:46:15 +0000
commitde18c1d81e0722779ce942110fb271e94db9635b (patch)
tree9e9c8edb06dd77c05617f2d55ba4c7c5bdc6789a /gdb/solib-svr4.c
parent16af530a6fd6d33174ae322fb1739bcbcbeaf96d (diff)
downloadgdb-de18c1d81e0722779ce942110fb271e94db9635b.zip
gdb-de18c1d81e0722779ce942110fb271e94db9635b.tar.gz
gdb-de18c1d81e0722779ce942110fb271e94db9635b.tar.bz2
* gcore.c: Include solib.h.
(gcore_create_callback): Call solib_keep_data_in_core when considering not saving memory in core file. * solib-svr4.c (svr4_keep_data_in_core): New. (_initialize_svr4_solib): Initialize svr4_so_ops.keep_data_in_core. * solib.c (solib_keep_data_in_core): New. * solib.h (solib_keep_data_in_core): Declare. * solist.h (struct target_so_ops): Add keep_data_in_core.
Diffstat (limited to 'gdb/solib-svr4.c')
-rw-r--r--gdb/solib-svr4.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 21055f6..4bc459c 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -866,6 +866,50 @@ solib_svr4_r_ldsomap (struct svr4_info *info)
ptr_type);
}
+/* On Solaris systems with some versions of the dynamic linker,
+ ld.so's l_name pointer points to the SONAME in the string table
+ rather than into writable memory. So that GDB can find shared
+ libraries when loading a core file generated by gcore, ensure that
+ memory areas containing the l_name string are saved in the core
+ file. */
+
+static int
+svr4_keep_data_in_core (CORE_ADDR vaddr, unsigned long size)
+{
+ struct svr4_info *info;
+ CORE_ADDR ldsomap;
+ struct so_list *new;
+ struct cleanup *old_chain;
+ struct link_map_offsets *lmo;
+ CORE_ADDR lm_name;
+
+ info = get_svr4_info ();
+
+ info->debug_base = 0;
+ locate_base (info);
+ if (!info->debug_base)
+ return 0;
+
+ ldsomap = solib_svr4_r_ldsomap (info);
+ if (!ldsomap)
+ return 0;
+
+ lmo = svr4_fetch_link_map_offsets ();
+ new = XZALLOC (struct so_list);
+ old_chain = make_cleanup (xfree, new);
+ new->lm_info = xmalloc (sizeof (struct lm_info));
+ make_cleanup (xfree, new->lm_info);
+ new->lm_info->l_addr = (CORE_ADDR)-1;
+ new->lm_info->lm_addr = ldsomap;
+ new->lm_info->lm = xzalloc (lmo->link_map_size);
+ make_cleanup (xfree, new->lm_info->lm);
+ read_memory (ldsomap, new->lm_info->lm, lmo->link_map_size);
+ lm_name = LM_NAME (new);
+ do_cleanups (old_chain);
+
+ return (lm_name >= vaddr && lm_name < vaddr + size);
+}
+
/*
LOCAL FUNCTION
@@ -1918,4 +1962,5 @@ _initialize_svr4_solib (void)
svr4_so_ops.bfd_open = solib_bfd_open;
svr4_so_ops.lookup_lib_global_symbol = elf_lookup_lib_symbol;
svr4_so_ops.same = svr4_same;
+ svr4_so_ops.keep_data_in_core = svr4_keep_data_in_core;
}