From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28229 invoked by alias); 7 Jan 2010 13:09:26 -0000 Received: (qmail 28023 invoked by uid 22791); 7 Jan 2010 13:09:25 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Jan 2010 13:09:21 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 0A0B9CB022C; Thu, 7 Jan 2010 14:09:19 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5UYS0xTNwcoC; Thu, 7 Jan 2010 14:09:18 +0100 (CET) Received: from chinon.act-europe.fr (chinon.act-europe.fr [10.10.0.182]) by mel.act-europe.fr (Postfix) with ESMTP id E6BCECB01D7; Thu, 7 Jan 2010 14:09:18 +0100 (CET) Received: by chinon.act-europe.fr (Postfix, from userid 1038) id B37B1D8B87; Thu, 7 Jan 2010 14:09:18 +0100 (CET) Date: Thu, 07 Jan 2010 13:09:00 -0000 From: Tristan Gingold To: gdb-patches@sourceware.org Cc: kevinb@redhat.com Subject: [RFA] Fix has_section_at_zero for separate debug files Message-ID: <20100107130918.GA11037@chinon.act-europe.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i 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: 2010-01/txt/msg00135.txt.bz2 Hi, this patch reconsiders the approach taken in http://sourceware.org/ml/gdb-patches/2009-06/msg00116.html The new problem is that has_section_at_zero is now wrongly cleared. This happens when the separate debug file is a relocatable file (such as on Darwin) which may have a function at address 0. If its backlink (ie the executable) has no section at 0 (which is the rule), one or more symbols disappear in the symtab. Because a separate debug file may be completely unrelated (in terms of mapping) from its backlink, we shouldn't try to copy the has_section_at_zero. Instead, we also consider SEC_ALLOC sections to set has_section_at_zero. This makes sense because you may perfectly have the bss at zero. No regression on GNU Linux i386. I have also checked this patch which a tiny program having a section at 0 and run in qemu. (I cc: Kevin Buettner, the author of the previous approach). Tristan. 2010-01-07 Tristan Gingold * dwarf2read.c (dwarf2_locate_sections): Also consider SEC_ALLOC sections to set has_section_at_zero. (dwarf2_psymtab_to_symtab): Do not copy has_section_at_zero from backlink for separate debug file. --- gdb/dwarf2read.c | 15 +-------------- 1 files changed, 1 insertions(+), 14 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 7623035..7dbe02f 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1258,7 +1258,7 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr) dwarf2_per_objfile->types.size = bfd_get_section_size (sectp); } - if ((bfd_get_section_flags (abfd, sectp) & SEC_LOAD) + if ((bfd_get_section_flags (abfd, sectp) & (SEC_LOAD | SEC_ALLOC)) && bfd_section_vma (abfd, sectp) == 0) dwarf2_per_objfile->has_section_at_zero = 1; } @@ -2994,19 +2994,6 @@ dwarf2_psymtab_to_symtab (struct partial_symtab *pst) dwarf2_per_objfile = objfile_data (pst->objfile, dwarf2_objfile_data_key); - /* If this psymtab is constructed from a debug-only objfile, the - has_section_at_zero flag will not necessarily be correct. We - can get the correct value for this flag by looking at the data - associated with the (presumably stripped) associated objfile. */ - if (pst->objfile->separate_debug_objfile_backlink) - { - struct dwarf2_per_objfile *dpo_backlink - = objfile_data (pst->objfile->separate_debug_objfile_backlink, - dwarf2_objfile_data_key); - dwarf2_per_objfile->has_section_at_zero - = dpo_backlink->has_section_at_zero; - } - psymtab_to_symtab_1 (pst); /* Finish up the debug error message. */ -- 1.6.5.rc2