mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 04:00:07 +08:00
Fix location list offset address dump under DW_AT_location (dwarf-5)
For clang compiled objects with dwarf-5, location list offset address dump under DW_AT_location is corrected, where DW_FORM_loclistx is used. While dumping the location list offset, the address dumped is wrong where it was refering to .debug_addr instead of .debug_loclists * dwarf.c (fetch_indexed_value): Add base_address as parameter and use it to access the section offset. (read_and_display_attr_value): Handle DW_FORM_loclistx form separately. Pass loclists_base to fetch_indexed_value().
This commit is contained in:

committed by
Alok Kumar Sharma

parent
0d8fb090a7
commit
2d1388e73c
@ -838,7 +838,8 @@ fetch_indexed_addr (dwarf_vma offset, uint32_t num_bytes)
|
|||||||
|
|
||||||
static dwarf_vma
|
static dwarf_vma
|
||||||
fetch_indexed_value (dwarf_vma idx,
|
fetch_indexed_value (dwarf_vma idx,
|
||||||
enum dwarf_section_display_enum sec_enum)
|
enum dwarf_section_display_enum sec_enum,
|
||||||
|
dwarf_vma base_address)
|
||||||
{
|
{
|
||||||
struct dwarf_section *section = &debug_displays [sec_enum].section;
|
struct dwarf_section *section = &debug_displays [sec_enum].section;
|
||||||
|
|
||||||
@ -863,8 +864,12 @@ fetch_indexed_value (dwarf_vma idx,
|
|||||||
|
|
||||||
dwarf_vma offset = idx * pointer_size;
|
dwarf_vma offset = idx * pointer_size;
|
||||||
|
|
||||||
/* Offsets are biased by the size of the section header. */
|
/* Offsets are biased by the size of the section header
|
||||||
offset += bias;
|
or base address. */
|
||||||
|
if (sec_enum == loclists)
|
||||||
|
offset += base_address;
|
||||||
|
else
|
||||||
|
offset += bias;
|
||||||
|
|
||||||
if (offset + pointer_size > section->size)
|
if (offset + pointer_size > section->size)
|
||||||
{
|
{
|
||||||
@ -2808,13 +2813,23 @@ read_and_display_attr_value (unsigned long attribute,
|
|||||||
|
|
||||||
if (do_wide)
|
if (do_wide)
|
||||||
/* We have already displayed the form name. */
|
/* We have already displayed the form name. */
|
||||||
printf (_("%c(index: 0x%s): %s"), delimiter,
|
if (form == DW_FORM_loclistx)
|
||||||
dwarf_vmatoa ("x", uvalue),
|
printf (_("%c(index: 0x%s): %s"), delimiter,
|
||||||
dwarf_vmatoa ("x", fetch_indexed_addr (offset, pointer_size)));
|
dwarf_vmatoa ("x", uvalue),
|
||||||
|
dwarf_vmatoa ("x", debug_info_p->loc_offsets [uvalue]));
|
||||||
|
else
|
||||||
|
printf (_("%c(index: 0x%s): %s"), delimiter,
|
||||||
|
dwarf_vmatoa ("x", uvalue),
|
||||||
|
dwarf_vmatoa ("x", fetch_indexed_addr (offset, pointer_size)));
|
||||||
else
|
else
|
||||||
printf (_("%c(addr_index: 0x%s): %s"), delimiter,
|
if (form == DW_FORM_loclistx)
|
||||||
dwarf_vmatoa ("x", uvalue),
|
printf (_("%c(addr_index: 0x%s): %s"), delimiter,
|
||||||
dwarf_vmatoa ("x", fetch_indexed_addr (offset, pointer_size)));
|
dwarf_vmatoa ("x", uvalue),
|
||||||
|
dwarf_vmatoa ("x", debug_info_p->loc_offsets [uvalue]));
|
||||||
|
else
|
||||||
|
printf (_("%c(addr_index: 0x%s): %s"), delimiter,
|
||||||
|
dwarf_vmatoa ("x", uvalue),
|
||||||
|
dwarf_vmatoa ("x", fetch_indexed_addr (offset, pointer_size)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2898,9 +2913,8 @@ read_and_display_attr_value (unsigned long attribute,
|
|||||||
lmax, sizeof (*debug_info_p->have_frame_base));
|
lmax, sizeof (*debug_info_p->have_frame_base));
|
||||||
debug_info_p->max_loc_offsets = lmax;
|
debug_info_p->max_loc_offsets = lmax;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (form == DW_FORM_loclistx)
|
if (form == DW_FORM_loclistx)
|
||||||
uvalue = fetch_indexed_value (uvalue, loclists);
|
uvalue = fetch_indexed_value (num, loclists, debug_info_p->loclists_base);
|
||||||
else if (this_set != NULL)
|
else if (this_set != NULL)
|
||||||
uvalue += this_set->section_offsets [DW_SECT_LOC];
|
uvalue += this_set->section_offsets [DW_SECT_LOC];
|
||||||
|
|
||||||
@ -2969,7 +2983,7 @@ read_and_display_attr_value (unsigned long attribute,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (form == DW_FORM_rnglistx)
|
if (form == DW_FORM_rnglistx)
|
||||||
uvalue = fetch_indexed_value (uvalue, rnglists);
|
uvalue = fetch_indexed_value (uvalue, rnglists, 0);
|
||||||
|
|
||||||
debug_info_p->range_lists [num] = uvalue;
|
debug_info_p->range_lists [num] = uvalue;
|
||||||
debug_info_p->num_range_lists++;
|
debug_info_p->num_range_lists++;
|
||||||
|
Reference in New Issue
Block a user