Commit: Fix readelf/objdump's handling of DW_FORM_ref_addr

Nick Clifton nickc@redhat.com
Tue Oct 27 16:16:41 GMT 2020


Hi Guys,

  My previous patch to workaround the problems handling DW_FORM_ref_addr
  forms in DWARF debug information has proven to be insufficient.  There
  are still cases where the form is decoded improperly, causing
  non-LEB128 data to be read as if it were an LEB128 value.

  So I am applying the attached patch to fix the problem properly by
  actually decoding the form correctly.  The issue with this form is
  that it points to an arbitrary location within the .debug_info
  section, and in order to decode it, it is necessary to have the
  abbreviations associated with whichever CU is associated with the
  referenced location.  All of which means that it is necessary to parse
  all of the abbreviations and all of the CU headers before attempting
  to actually parse the contents of any CU.

  I have gone for simplicity in the algorithms that I have used.  Which
  probably means that they will be slower than they could be.  But that
  can always be fixed by a future patch.

  Tested with a wide variety of different toolchains.
  
Cheers
  Nick

binutils/ChangeLog
2020-10-27  Nick Clifton  <nickc@redhat.com>

	* dwarf.c (struct abbrev_list): New structure.  Used to collect
	lists of abbreviation sets.
	(struct abbrev_map): New structure.  Used to map CU offsets to
	abbreviation offsets.
	(record_abbrev_list): New function.  A new entry to an
	abbreviation list.
	(free_all_abbrevs): Update to free abbreviation lists.
	(new_abbrev_list): New function.  Start a new abbreviation
	list.
	(find_abbrev_list_by_abbrev_offset): New function.
	(find_abbrev_map_by_offset): New function.
	(add_abbrev): Add abbrev_list parameter.
	(add_abbrev_attr): Likewise.
	(process_abbrev_section): Rename to process_abbrev_set and add
	list parameter.
	(get_type_abbrev_from_form): New function.  Attempts to decode the
	forms used by DW_AT_type attributes.
	(get_type_signedness): Display type names if operating in wide
	mode.  Use get_type_abbrev_from_form.
	(read_and_display_attr_value): Use get_type_abbrev_from_form.
	(process_debug_info): Pre-parse the CU headers to collate all the
	abbrevs before starting the main scan.
	(process_debug_abbrev): Do not free any loaded abbrevs.
	(free_debug_memory): Free the abbrev maps.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dwarf.DW_FORM_ref_addr.patch
Type: text/x-patch
Size: 24378 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20201027/02d3856c/attachment-0001.bin>


More information about the Binutils mailing list