From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3722 invoked by alias); 20 Jun 2009 00:17:20 -0000 Received: (qmail 3713 invoked by uid 22791); 20 Jun 2009 00:17:20 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 20 Jun 2009 00:17:13 +0000 Received: (qmail 15202 invoked from network); 20 Jun 2009 00:17:11 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 20 Jun 2009 00:17:11 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [patch] solib-svr4.c - allow reading linkmap info from core without executable Date: Sat, 20 Jun 2009 00:17:00 -0000 User-Agent: KMail/1.9.10 Cc: Aleksandar Ristovski References: <200906191600.43923.pedro@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200906200118.00802.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-06/txt/msg00524.txt.bz2 On Friday 19 June 2009 17:03:24, Aleksandar Ristovski wrote: >=20 > Yes, it works: Okay, I've applied it, as below. > (gdb) info shared > =A0From =A0 =A0 =A0 =A0To =A0 =A0 =A0 =A0 =A0Syms Read =A0 Shared Object = Library > 0x4cb3e470 =A00x4cb58844 =A0No =A0 =A0 =A0 =A0 =A0/lib/libm.so.6 > 0x4ca18dd0 =A00x4cafe490 =A0No =A0 =A0 =A0 =A0 =A0/lib/libc.so.6 > 0x4c9e5880 =A00x4c9fa8ef =A0No =A0 =A0 =A0 =A0 =A0/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. --=20 Pedro Alves 2009-06-20 Aleksandar Ristovski Pedro Alves * 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =20 /* 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") =3D=3D NULL) + if (exec_bfd && bfd_get_section_by_name (exec_bfd, ".dynamic") =3D=3D NU= LL) return 0; =20 return extract_typed_address (so->lm_info->lm + lmo->l_prev_offset, @@ -600,9 +600,13 @@ scan_dyntag (int dyntag, bfd *abfd, CORE =20 if (abfd =3D=3D NULL) return 0; + + if (bfd_get_flavour (abfd) !=3D bfd_target_elf_flavour) + return 0; + arch_size =3D bfd_get_arch_size (abfd); if (arch_size =3D=3D -1) - return 0; + return 0; =20 /* Find the start address of the .dynamic section. */ sect =3D 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. */ =20 if (info->debug_base =3D=3D 0 && svr4_have_link_map_offsets ()) - { - if (exec_bfd !=3D NULL - && bfd_get_flavour (exec_bfd) =3D=3D bfd_target_elf_flavour) - info->debug_base =3D elf_locate_base (); - } + info->debug_base =3D elf_locate_base (); return info->debug_base; } =20