Commit: readelf: Fix LEB128 decoding errors when computing type signedness

Nick Clifton nickc@redhat.com
Wed Oct 21 16:42:24 GMT 2020


Hi Guys,

  Using readelf or objdump to display the contents of .debug_info
  sections can result in errors like this:

    readelf: /lib64/libstdc++.so.6.0.28: Error: dwarf.c:1918:
      read LEB value is too large to store in destination variable
    readelf: /lib64/libstdc++.so.6.0.28: Error: dwarf.c:1918:
      end of data encountered whilst reading LEB

  I have tracked the cause of this problem down to the code that attempts
  to determined whether a type described in the DWARF information is
  signed or unsigned.  This can involve parsing a DW_FORM_ref_addr
  form, which is something that we do not handle correctly.  (This is a
  known weakness of the code, and will be fixed one day).  The bug
  meant that the code would attempt to interpret an arbitrary sequence
  of bytes as LEB128 values, producing the errors shown above.

  I am applying the attached patch to work around the problem, by
  defaulting to "unsigned" if the type uses DW_FORM_ref_addr.  In
  addition the patch also extends the code for skipping attributes so
  that it can handle DW_FORM_indirect.  (This code is used by the
  get_type_signedness function).

Cheers
  Nick

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

	* dwarf.c (skip_attr_bytes): Accept DWARF versions higher than 4
	when processing the DW_FORM_ref_addr form.
	Skip bytes in DW_FORM_block and DW_FORM_exprloc forms.
	Handle DW_FORM_indirect.
	(get_type_signedness): Allow a limited amount of recursion.
	Do not attempt to decode types that use the DW_FORM_ref_addr form.
	(read_and_display_attr_value): 	Do not attempt to decode types
	that use the DW_FORM_ref_addr form.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.p
Type: application/octet-stream
Size: 3687 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20201021/7331abb3/attachment.obj>


More information about the Binutils mailing list