public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Fix crash in readelf
@ 2006-10-10 10:46 Andreas Schwab
  0 siblings, 0 replies; only message in thread
From: Andreas Schwab @ 2006-10-10 10:46 UTC (permalink / raw)
  To: binutils

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."

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-10-10 10:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-10 10:46 Fix crash in readelf Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).