This is the mail archive of the mailing list for the elfutils 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: [PATCH] Handle GNU extension opcodes in dwarf_getlocation

On Wed, Oct 10, 2012 at 09:39:49AM +0200, Mark Wielaard wrote:
> Thanks for double checking. Adding Jakub to CC, see below.
> On Wed, 2012-10-10 at 08:56 +0200, Petr Machata wrote:
> > Jan Kratochvil <> writes:
> > > On Tue, 09 Oct 2012 22:50:20 +0200, Petr Machata wrote:
> > >> Mark Wielaard <> writes:
> > >> > Do you happen to know where
> > >> > DW_OP_GNU_reinterpret is described, I assumed it was part of
> > >> > but it isn't in there.
> > >> 
> > >> No, it isn't, I didn't find it anywhere else but in elfutils.  It's not
> > >> even in my test binary, only DW_OP_GNU_convert is.
> > >
> > > DW_OP_GNU_convert is handled by GDB:
> > 
> > As well as DW_OP_GNU_reinterpret, great:
> > 
> > 	.byte	0xf7	# DW_OP_GNU_convert
> > 	.uleb128 0x29
> > 	.byte	0xf9	# DW_OP_GNU_reinterpret
> > 	.uleb128 0x37
> > 
> > So yeah, they both have the same arguments.
> OK, and I just found gcc/dwarf2out.c does indeed seem to generate it.
> But I am not fully clear on why convert cannot always be used.
> Jakub, is there a "official" description for DW_OP_GNU_reinterpret?
> And/Or is there a newer document describing the typed DWARF stack
> extensions?

DW_OP_GNU_convert is conversion, i.e. C (outertype) expr
or C++ static_cast<outertype> (expr).  So if say outertype is double
and inner type is untyped or some integer, the operation is convert an
integer on the stack into double, 1 becomes 1.0 etc.

DW_OP_GNU_reinterpret is type puning, -fno-strict-aliasing
*(outertype *)&expr or ((union { innertype i; outertype o; }){.i = expr}).o
or {( outertype o; innertype i = expr; memcpy (&o, &i, sizeof (o)); o; })
kind of operation, you use the same bits but change the type of them
in the DWARF stack.  Valid code should only use it when innertype and
outertype have the same number of bits.  On little endian, 1
DW_OP_GNU_reinterpret converted to float will become __FLT_DENORM_MIN__,
0x40000000 will become 2.0f.

Both of these ops have just one operand, uleb128 DIE reference (DIE offset
relative to start of the current CU) of the DW_TAG_base_type to
convert/reinterpret to.


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