On Aug  5, 2016, Jason Merrill <ja...@redhat.com> wrote:

> On Sat, Jul 23, 2016 at 10:30 AM, Alexandre Oliva <aol...@redhat.com> wrote:
>> With this patch, when we can't emit a DW_AT_const_value, we emit each
>> "member" of the pointer to member function "record" as a
>> DW_OP_stack_value DW_OP_piece, as long as the referenced member
>> function is output in the same translation unit, otherwise we'd get
>> relocations to external symbols, something to avoid in debug sections.

> I wonder if it would make sense to use weak references...

Hmm...  That certainly wouldn't avoid the relocation, but if the problem
is just the possibility that the symbol is undefined, that would work.
OTOH, it would hide the error one would expect out of a hard reference
in the same translation unit.  Could we ever have a weak reference in
debug info without a corresponding hard reference in the same
translation unit?  We'd have to take that into account.  I'll think
about it some more and maybe give that a shot.

>> +                 if (pos > offset)
>> +                   {
>> +                     ret1 = new_loc_descr (DW_OP_piece, pos - offset, 0);
>> +                     add_loc_descr (&ret, ret1);
>> +                     offset = pos;
>> +                   }

> This seems like it will emit a DW_OP_piece with nothing before it,
> which I think is invalid DWARF.

If so, there'd be a long-standing bug in the DW_OP examples in the DWARF
standard:

  DW_OP_reg0 DW_OP_piece 4 DW_OP_piece 4 DW_OP_fbreg -12 DW_OP_piece 4
    A twelve byte value whose first four bytes reside in register zero,
    whose middle four bytes are unavailable (perhaps due to
    optimization), and whose last four bytes are in memory, 12 bytes
    before the frame base.

However, this use seems consistent with the description of DW_OP_piece,
that says it takes an operand that describes the size of the preceding
simple location description.  An empty location description is-a simple
location description.

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer

Reply via email to