Hi David,

> The bug in readelf (I think) is at the end of display_debug_frames() in
> dwarf.c (binutils directory).
> 
> The frame_display_row call is a bit odd if all that exist are nops and
> results in the rax output

I am currently testing out the attached patch.  I am not sure however if
it is doing the right thing by just silently ignoring DW_CFA_NOPs.  Maybe
it should issue an interpretation along the lines of:

     LOC           CFA      ra      
  0000000000020480 nop      -

What do you think ?

Cheers
  Nick
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 770fa6b..282e069 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -5780,6 +5780,7 @@ display_debug_frames (struct dwarf_section *section,
       unsigned int encoded_ptr_size = saved_eh_addr_size;
       unsigned int offset_size;
       unsigned int initial_length_size;
+      bfd_boolean all_nops;
 
       saved_start = start;
 
@@ -6213,6 +6214,8 @@ display_debug_frames (struct dwarf_section *section,
 	  start = tmp;
 	}
 
+      all_nops = TRUE;
+
       /* Now we know what registers are used, make a second pass over
 	 the chunk, this time actually printing out the info.  */
 
@@ -6231,6 +6234,10 @@ display_debug_frames (struct dwarf_section *section,
 	  if (op & 0xc0)
 	    op &= 0xc0;
 
+	  /* Make a note if something other than DW_CFA_nop happens.  */
+	  if (op != DW_CFA_nop)
+	    all_nops = FALSE;
+
 	  /* Warning: if you add any more cases to this switch, be
 	     sure to add them to the corresponding switch above.  */
 	  switch (op)
@@ -6661,7 +6668,8 @@ display_debug_frames (struct dwarf_section *section,
 	    }
 	}
 
-      if (do_debug_frames_interp)
+      /* Interpret the CFA - as long as it is not completely full of NOPs.  */
+      if (do_debug_frames_interp && ! all_nops)
 	frame_display_row (fc, &need_col_headers, &max_regs);
 
       start = block_end;
_______________________________________________
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org

Reply via email to