This is the mail archive of the elfutils-devel@sourceware.org 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] libdw: fix offset for sig8 lookup in dwarf_formref_die


On 01/14/2015 11:47 AM, Mark Wielaard wrote:
> On Wed, 2015-01-14 at 09:26 -0500, Jason P. Leasure wrote:
>> The type_offset of a type unit header is relative to the beginning
>> of the type unit header.
>>
>> Signed-off-by: Jason P. Leasure <jpleasu@super.org>
>> ---
>>   libdw/dwarf_formref_die.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libdw/dwarf_formref_die.c b/libdw/dwarf_formref_die.c
>> index 63f6697..8b92e22 100644
>> --- a/libdw/dwarf_formref_die.c
>> +++ b/libdw/dwarf_formref_die.c
>> @@ -95,7 +95,7 @@ dwarf_formref_die (attr, result)
>>   
>>         datap = cu->dbg->sectiondata[IDX_debug_types]->d_buf;
>>         size = cu->dbg->sectiondata[IDX_debug_types]->d_size;
>> -      offset = cu->type_offset;
>> +      offset = cu->start + cu->type_offset;
> Thanks, I believe this is correct. I am surprised we didn't encounter
> this earlier. Do you happen to have a testcase for it?
>
> Cheers,
>
> Mark

Sorry, I don't have a good testcase, but you can generate a binary with 
two type units in the debug_types section using:

   echo 'struct A{ struct B {} x;};int main(){A a;return 0;}' | g++ -x 
c++  -g -fdebug-types-section  -

to see the global die offsets:

   dwarfdump -Gi ./a.out


Jason


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