This is the mail archive of the mailing list for the binutils 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]

[patch] Fix readelf display of 8-byte values

In binutils/dwarf.c, read_and_display_attr_value(), the handling of
ref8 and data8 forms uses dwarf_vmatoa for the first 4 bytes, but uses
printf to format the second 4 bytes:

    case DW_FORM_ref8:
    case DW_FORM_data8:
      if (!do_loc)
	  uvalue = byte_get (data, 4);
	  printf (" 0x%s", dwarf_vmatoa ("x", uvalue));
	  printf (" 0x%lx", (unsigned long) byte_get (data + 4, 4));
      if ((do_loc || do_debug_loc || do_debug_ranges)
	  && num_debug_info_entries == 0)
	  if (sizeof (uvalue) == 8)
	    uvalue = byte_get (data, 8);
	    error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n"));
      data += 8;

Is this an oversight, or intentional? If simply an oversight, I'd like
to fix it; if it's intentional, I'd like to understand what the
rationale is so I don't break it.

What I'd like to do here is print something that at least looks like
an 8-byte value rather than two 4-byte values (in the wrong order for
little-endian machines), and do the same for ref_sig8 instead of what
it does now, which is print an array of 8 one-byte values. It seems
that the only mechanism dwarf.c code has to determine the ELF file's
byte order is to call byte_get, but byte_get is unable to return a
full 8-byte value when compiled in 32-bit mode. What would you think
about adding two new functions, byte_get_high and byte_get_low, to
elfcomm.c, which would return the high 32 bits and the low 32 bits,
respectively, of a 64-bit value? Then perhaps a dwarf_vmatoa64() could
format the two halves as a single hex number.

A patch for what I've suggested is attached. Comments?



2012-02-08  Cary Coutant  <>

	* dwarf.c (dwarf_vmatoa64): New function.
	(read_and_display_attr_value): Print 8-byte forms as single hex
	(process_debug_info): Print type signatures as single hex numbers.
	* elfcomm.c (byte_get_high, byte_get_low): New functions.
	* elfcomm.h (byte_get_high, byte_get_low): New functions.

Attachment: binutils-data8-patch.txt
Description: Text document

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