dbghelp/dwarf: Correctly handle attributes according to 32bit or 64bit format.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Eric Pouech 2021-09-11 10:58:59 +02:00 committed by Alexandre Julliard
parent d78c09aa37
commit 8241fe3877
1 changed files with 15 additions and 10 deletions

View File

@ -480,7 +480,7 @@ static void dwarf2_swallow_attribute(dwarf2_traverse_context_t* ctx,
switch (abbrev_attr->form) switch (abbrev_attr->form)
{ {
case DW_FORM_flag_present: step = 0; break; case DW_FORM_flag_present: step = 0; break;
case DW_FORM_ref_addr: case DW_FORM_ref_addr: step = (head->version >= 3) ? head->offset_size : head->word_size; break;
case DW_FORM_addr: step = head->word_size; break; case DW_FORM_addr: step = head->word_size; break;
case DW_FORM_flag: case DW_FORM_flag:
case DW_FORM_data1: case DW_FORM_data1:
@ -488,8 +488,8 @@ static void dwarf2_swallow_attribute(dwarf2_traverse_context_t* ctx,
case DW_FORM_data2: case DW_FORM_data2:
case DW_FORM_ref2: step = 2; break; case DW_FORM_ref2: step = 2; break;
case DW_FORM_data4: case DW_FORM_data4:
case DW_FORM_ref4: case DW_FORM_ref4: step = 4; break;
case DW_FORM_strp: step = 4; break; case DW_FORM_strp: step = head->offset_size; break;
case DW_FORM_data8: case DW_FORM_data8:
case DW_FORM_ref8: step = 8; break; case DW_FORM_ref8: step = 8; break;
case DW_FORM_sdata: case DW_FORM_sdata:
@ -516,6 +516,13 @@ static void dwarf2_fill_attr(const dwarf2_parse_context_t* ctx,
switch (attr->form) switch (attr->form)
{ {
case DW_FORM_ref_addr: case DW_FORM_ref_addr:
if (ctx->head.version >= 3)
attr->u.uvalue = dwarf2_get_addr(data, ctx->head.offset_size);
else
attr->u.uvalue = dwarf2_get_addr(data, ctx->head.word_size);
TRACE("addr<0x%lx>\n", attr->u.uvalue);
break;
case DW_FORM_addr: case DW_FORM_addr:
attr->u.uvalue = dwarf2_get_addr(data, ctx->head.word_size); attr->u.uvalue = dwarf2_get_addr(data, ctx->head.word_size);
TRACE("addr<0x%lx>\n", attr->u.uvalue); TRACE("addr<0x%lx>\n", attr->u.uvalue);
@ -590,12 +597,10 @@ static void dwarf2_fill_attr(const dwarf2_parse_context_t* ctx,
break; break;
case DW_FORM_strp: case DW_FORM_strp:
{ attr->u.string = (const char*)ctx->sections[section_string].address +
ULONG_PTR offset = dwarf2_get_u4(data); dwarf2_get_addr(data, ctx->head.offset_size);
attr->u.string = (const char*)ctx->sections[section_string].address + offset; TRACE("strp<%s>\n", debugstr_a(attr->u.string));
} break;
TRACE("strp<%s>\n", debugstr_a(attr->u.string));
break;
case DW_FORM_block: case DW_FORM_block:
attr->u.block.size = dwarf2_get_leb128_as_unsigned(data, &attr->u.block.ptr); attr->u.block.size = dwarf2_get_leb128_as_unsigned(data, &attr->u.block.ptr);