patch for binutils/readelf.c, 3 more dwarf2 fixes

Jim Wilson wilson@cygnus.com
Thu Aug 26 20:30:00 GMT 1999


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);
  	}


More information about the Binutils mailing list