This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] solib-svr4.c - allow reading linkmap info from core without executable
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Cc: Aleksandar Ristovski <aristovski at qnx dot com>
- Date: Sat, 20 Jun 2009 01:18:00 +0100
- Subject: Re: [patch] solib-svr4.c - allow reading linkmap info from core without executable
- References: <gvphah$8rh$1@ger.gmane.org> <200906191600.43923.pedro@codesourcery.com> <h1gcsd$6e5$1@ger.gmane.org>
On Friday 19 June 2009 17:03:24, Aleksandar Ristovski wrote:
>
> Yes, it works:
Okay, I've applied it, as below.
> (gdb) info shared
> ?From ? ? ? ?To ? ? ? ? ?Syms Read ? Shared Object Library
> 0x4cb3e470 ?0x4cb58844 ?No ? ? ? ? ?/lib/libm.so.6
> 0x4ca18dd0 ?0x4cafe490 ?No ? ? ? ? ?/lib/libc.so.6
> 0x4c9e5880 ?0x4c9fa8ef ?No ? ? ? ? ?/lib/ld-linux.so.2
^^
^^
IIRC, this is due to only pulling in symbols from shared
libraries automatically if there's an exec_bfd (post_create_inferior).
I think that if we audit all solib-*.c implementations to make sure
they won't crash or do something wild without an exec_bfd, we
could remove that restriction.
--
Pedro Alves
2009-06-20 Aleksandar Ristovski <aristovski@qnx.com>
Pedro Alves <pedro@codesourcery.com>
* solib-svr4.c (IGNORE_FIRST_LINK_MAP_ENTRY): Avoid dereferencing
NULL pointer.
(scan_dyntag): Skip if input bfd isn't elf flavoured.
(locate_base): Call elf_locate_base even without an exec_bfd.
---
gdb/solib-svr4.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
Index: src/gdb/solib-svr4.c
===================================================================
--- src.orig/gdb/solib-svr4.c 2009-06-18 20:55:50.000000000 +0100
+++ src/gdb/solib-svr4.c 2009-06-18 22:25:11.000000000 +0100
@@ -266,7 +266,7 @@ IGNORE_FIRST_LINK_MAP_ENTRY (struct so_l
/* Assume that everything is a library if the dynamic loader was loaded
late by a static executable. */
- if (bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL)
+ if (exec_bfd && bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL)
return 0;
return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset,
@@ -600,9 +600,13 @@ scan_dyntag (int dyntag, bfd *abfd, CORE
if (abfd == NULL)
return 0;
+
+ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
+ return 0;
+
arch_size = bfd_get_arch_size (abfd);
if (arch_size == -1)
- return 0;
+ return 0;
/* Find the start address of the .dynamic section. */
sect = bfd_get_section_by_name (abfd, ".dynamic");
@@ -825,11 +829,7 @@ locate_base (struct svr4_info *info)
though if we don't have some link map offsets to work with. */
if (info->debug_base == 0 && svr4_have_link_map_offsets ())
- {
- if (exec_bfd != NULL
- && bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour)
- info->debug_base = elf_locate_base ();
- }
+ info->debug_base = elf_locate_base ();
return info->debug_base;
}