From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15312 invoked by alias); 26 Mar 2009 14:15:41 -0000 Received: (qmail 15301 invoked by uid 22791); 26 Mar 2009 14:15:39 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 Mar 2009 14:15:26 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n2QEEe2h009632; Thu, 26 Mar 2009 10:14:40 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n2QEEXal026650; Thu, 26 Mar 2009 10:14:33 -0400 Received: from host0.dyn.jankratochvil.net (sebastian-int.corp.redhat.com [172.16.52.221]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n2QEEcdY016148; Thu, 26 Mar 2009 10:14:39 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id n2QEEYlp016473; Thu, 26 Mar 2009 15:14:37 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.2/Submit) id n2QEEX2X016464; Thu, 26 Mar 2009 15:14:33 +0100 Date: Thu, 26 Mar 2009 14:15:00 -0000 From: Jan Kratochvil To: Paul Pluzhnikov Cc: Joel Brobecker , gdb@sourceware.org Subject: Re: about PR gdb/10002 (extern optimized out symbols print: Address of symbol is unknown) Message-ID: <20090326141433.GA7053@host0.dyn.jankratochvil.net> References: <20090325222600.GI1583@adacore.com> <8ac60eac0903251600v5bfe0808nebdef71c5f45c6cf@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8ac60eac0903251600v5bfe0808nebdef71c5f45c6cf@mail.gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-03/txt/msg00164.txt.bz2 On Thu, 26 Mar 2009 00:00:24 +0100, Paul Pluzhnikov wrote: > depends on compiler's ability to optimize out reference to "missing". If the > compiler couldn't do that, you'd get an unresolved symbol at link time. The target of that code was to produce: <1><55>: Abbrev Number: 4 (DW_TAG_variable) <56> DW_AT_name : (indirect string, offset: 0x66): missing <5c> DW_AT_type : <0x4e> <60> DW_AT_external : 1 <61> DW_AT_declaration : 1 The real test case http://sourceware.org/ml/gdb-patches/2009-03/msg00545.html uses .S for DWARF. This C code was just an easy easy how to arch-independently create a reproducer of the GDB problem for the reader. > > The variable was not "optimized out", but was never linked in. > > Well, the reference to the variable was optimized out. I see now in DWARF3 4.1 point 4: # In a variable entry representing the definition of a variable (that is, with # no DW_AT_declaration attribute) if no location attribute is present [...], # the variable is assumed to exist in the source code but not in the executable # program [...] As there is present DW_AT_declaration the variable is not considered as by DWARF. I overlooked this condition of DWARF so far. Going to close this PR gdb/10002 as invalid I also find now GDB is correct now. Still it is questionable how to reprosent by ELF/DWARF if the other compilation unit would have the variable "missing" optimized out if GCC LTO would find no reference to it. But this is not an actual problem to solve. Thanks, Jan