patch for binutils bfd/dwarf2.c

Nathan Tallent eraxxon@alumni.rice.edu
Thu Sep 19 15:54:00 GMT 2002


What follows is a patch for binutils bfd/dwarf2.c.
-Nathan Tallent


Description:
------------
The support for non-standard IRIX64 compilation unit length fields had a
bug.  For such binaries, dwarf2_find_nearest_line is normally called 
with the addr_size parameter set to 8.  However, this function is 
sometimes called with the addr_size parameter set to 0 (which defaults 
to an address size of 4 bytes).

Consider a case where we want to look up a virtual memory address with 
no debugging information.  The generic mips_elf_find_nearest_line tries
dwarf2_find_nearest_line(addr_size = 8).  When this (correctly) returns
nothing, it enters a 'panic mode' and tries elf_find_nearest_line to 
make sure there really is no symbolic infomation.  But this latter 
function simply calls dwarf2_find_nearest_line(addr_size = 4).
dwarf2_find_nearest_line(addr_size = 4) then attempts to find the symbol 
by reading some more compilation units.  But it can't read them 
correctly because it assumed the wrong address size.  Consequently, it 
records that these compilation units have errors and they are never read 
again -- and no symbolic information in these compilation units can ever 
be found.

Testing and testcases:
----------------------
I have run the binutils regression tests with and without my changes and
the results are the same.

Our tests: We are using bintuils as the binary reader for a program
that performs source code structure recovery on binaries from a number 
of different platforms.  (We esp. focus on loop recovery for scientific
programs.) This program is also a cross-tool and we have successfully
tested these changes (and a number of others to follow eventually) on a
number of different binaries (from GNU and non-GNU compilers) and
platforms.

hosts (all of which are enabled on each platform)
   mips64-sgi-irix6
   alpha-*-linux-gnu, alpha-*-osf
   sparc32-*-elf, sparc64-*-solaris2
   i386-*-linux-gnu
   ia64-*-linux-gnu


ChangeLog:
----------

2002-09-19  Nathan Tallent  <eraxxon@alumni.rice.edu>

	* dwarf2.c (_bfd_dwarf2_find_nearest_line): Update to correctly
	read (non-standard) 64-bit DWARF2 formats (e.g. IRIX64).

Patch: bfd/dwarf2.c
(created with 'cvs diff -c3p' against cvs repository on 9/16/02)
------

Index: dwarf2.c
===================================================================
RCS file: /cvs/src/src/bfd/dwarf2.c,v
retrieving revision 1.33
diff -c -3 -p -r1.33 dwarf2.c
*** dwarf2.c	17 Jul 2002 12:17:18 -0000	1.33
--- dwarf2.c	16 Sep 2002 20:09:30 -0000
*************** _bfd_dwarf2_find_nearest_line (abfd, sec
*** 1907,1912 ****
--- 1907,1919 ----
   	      length = read_8_bytes (abfd, stash->info_ptr + 4);
   	      stash->info_ptr += 8;
   	    }
+ 	  else if (length == 0)
+ 	    {
+ 	      /* Handle (non-standard) 64-bit DWARF2 formats.  */
+ 	      offset_size = 8;
+ 	      length = read_4_bytes (abfd, stash->info_ptr + 4);
+ 	      stash->info_ptr += 4;
+ 	    }
   	}
         else
   	length = read_8_bytes (abfd, stash->info_ptr);




More information about the Binutils mailing list