This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: about PR gdb/10002 (extern optimized out symbols print: Address of symbol is unknown)


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
<optimized out> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]