This is the mail archive of the binutils@sourceware.org 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]

Fix crash in readelf


When there are no location or range lists in a .debug_info section the
loc_offsets/range_offsets pointer is NULL (it happened here with some
corrupted debug info).  Committed as obvious.

Andreas.

2006-10-10  Andreas Schwab  <schwab@suse.de>

	* dwarf.c (display_debug_loc): Don't dereference loc_offsets when
	there are no location lists.
	(display_debug_ranges): Similar for range_lists.

--- binutils/dwarf.c.~1.7.~	2006-08-09 10:51:13.000000000 +0200
+++ binutils/dwarf.c	2006-10-10 12:40:29.000000000 +0200
@@ -2315,7 +2315,8 @@ display_debug_loc (struct dwarf_section 
     error (_("No location lists in .debug_info section!\n"));
 
   /* DWARF sections under Mach-O have non-zero addresses.  */
-  if (debug_information [first].loc_offsets [0] != section->address)
+  if (debug_information [first].num_loc_offsets > 0
+      && debug_information [first].loc_offsets [0] != section->address)
     warn (_("Location lists in %s section start at 0x%lx\n"),
 	  section->name, debug_information [first].loc_offsets [0]);
 
@@ -2686,7 +2687,8 @@ display_debug_ranges (struct dwarf_secti
     error (_("No range lists in .debug_info section!\n"));
 
   /* DWARF sections under Mach-O have non-zero addresses.  */
-  if (debug_information [first].range_lists [0] != section->address)
+  if (debug_information [first].num_range_lists > 0
+      && debug_information [first].range_lists [0] != section->address)
     warn (_("Range lists in %s section start at 0x%lx\n"),
 	  section->name, debug_information [first].range_lists [0]);
 

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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