This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
patch for binutils/readelf.c, 3 more dwarf2 fixes
- To: binutils@sourceware.cygnus.com
- Subject: patch for binutils/readelf.c, 3 more dwarf2 fixes
- From: Jim Wilson <wilson@cygnus.com>
- Date: Thu, 26 Aug 1999 20:30:06 -0700
- cc: wilson@cygnus.com, nickc@cygnus.com
This fixes 3 more readelf dwarf2 bugs.
1) Readelf is printing the wrong values for standard opcode args, due to an
off by one error.
2) Readelf is decoding arange sections wrong, because it isn't skipping the
required alignment padding before the address/length pairs.
3) Readelf is stopping when seeing a zero address instead of a zero address/
length pair, which means sections starting at zero aren't being printed.
Thu Aug 26 20:21:48 1999 Jim Wilson <wilson@cygnus.com>
* readelf.c (display_debug_lines): Use i-1 not i in standard_opcodes
access.
(display_debug_aranges): New local excess. Use for calculating padding
and add that into ranges. Break from loop only if length is also 0.
Index: readelf.c
===================================================================
RCS file: /cvs/cvsfiles/devo/binutils/readelf.c,v
retrieving revision 1.85
diff -p -r1.85 readelf.c
*** readelf.c 1999/08/26 03:52:31 1.85
--- readelf.c 1999/08/27 03:21:32
*************** display_debug_lines (section, start, fil
*** 4279,4285 ****
printf (_("\n Opcodes:\n"));
for (i = 1; i < info.li_opcode_base; i++)
! printf (_(" Opcode %d has %d args\n"), i, standard_opcodes[i]);
/* Display the contents of the Directory table. */
data = standard_opcodes + info.li_opcode_base - 1;
--- 4279,4285 ----
printf (_("\n Opcodes:\n"));
for (i = 1; i < info.li_opcode_base; i++)
! printf (_(" Opcode %d has %d args\n"), i, standard_opcodes[i - 1]);
/* Display the contents of the Directory table. */
data = standard_opcodes + info.li_opcode_base - 1;
*************** display_debug_aranges (section, start, f
*** 5770,5775 ****
--- 5771,5777 ----
unsigned char * ranges;
unsigned long length;
unsigned long address;
+ int excess;
external = (DWARF2_External_ARange *) start;
*************** display_debug_aranges (section, start, f
*** 5789,5806 ****
ranges = start + sizeof (* external);
for (;;)
{
address = byte_get (ranges, arange.ar_pointer_size);
- if (address == 0)
- break;
-
ranges += arange.ar_pointer_size;
length = byte_get (ranges, arange.ar_pointer_size);
ranges += arange.ar_pointer_size;
printf (" %8.8lx %lu\n", address, length);
}
--- 5791,5814 ----
ranges = start + sizeof (* external);
+ /* Must pad to an alignment boundary that is twice the pointer size. */
+ excess = sizeof (*external) % (2 * arange.ar_pointer_size);
+ if (excess)
+ ranges += (2 * arange.ar_pointer_size) - excess;
+
for (;;)
{
address = byte_get (ranges, arange.ar_pointer_size);
ranges += arange.ar_pointer_size;
length = byte_get (ranges, arange.ar_pointer_size);
ranges += arange.ar_pointer_size;
+
+ /* A pair of zeros marks the end of the list. */
+ if (address == 0 && length == 0)
+ break;
printf (" %8.8lx %lu\n", address, length);
}