[commit] [patch] Fix error code from __libdw_find_fde

Jan Kratochvil jan.kratochvil at redhat.com
Mon Oct 8 21:36:23 UTC 2012


On Mon, 08 Oct 2012 21:50:12 +0200, Roland McGrath wrote:
> I don't know why I ever had 'unlikely' on 'fde != NULL'.
> That should have been 'likely' or nothing.
> And don't repeat that test, just use a nested if.

Thereore checked in with these changes, IIUC it was implicitly approved.


Thanks,
Jan


commit 07f3507442cb3f913000844025ca139925afe110
Author: Jan Kratochvil <jan.kratochvil at redhat.com>
Date:   Mon Oct 8 23:34:35 2012 +0200

    libdw/
    fde.c (__libdw_find_fde): Change <fde != NULL> to likely.  Return
    DWARF_E_NO_MATCH if .eh_frame_hdr points to FDE which is too short for searched
    PC.
    
    Signed-off-by: Jan Kratochvil <jan.kratochvil at redhat.com>

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index cc45d59..0d2d5f1 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,11 @@
 2012-10-08  Jan Kratochvil  <jan.kratochvil at redhat.com>
 
+	* fde.c (__libdw_find_fde): Change <fde != NULL> to likely.  Return
+	DWARF_E_NO_MATCH if .eh_frame_hdr points to FDE which is too short for
+	searched PC.
+
+2012-10-08  Jan Kratochvil  <jan.kratochvil at redhat.com>
+
 	* dwarf_getlocation.c (__libdw_intern_expression) <cfap>: Make new
 	loclist element DW_OP_call_frame_cfa before decoding the opcodes.
 	Remove the later DW_OP_call_frame_cfa push to RESULT.
diff --git a/libdw/fde.c b/libdw/fde.c
index bde0c99..32c77b0 100644
--- a/libdw/fde.c
+++ b/libdw/fde.c
@@ -229,12 +229,17 @@ __libdw_find_fde (Dwarf_CFI *cache, Dwarf_Addr address)
       if (offset == (Dwarf_Off) -1l)
 	goto no_match;
       struct dwarf_fde *fde = __libdw_fde_by_offset (cache, offset);
-      if (unlikely (fde != NULL)
-	  /* Sanity check the address range.  */
-	  && unlikely (address < fde->start || address >= fde->end))
+      if (likely (fde != NULL))
 	{
-	  __libdw_seterrno (DWARF_E_INVALID_DWARF);
-	  return NULL;
+	  /* Sanity check the address range.  */
+	  if (unlikely (address < fde->start))
+	    {
+	      __libdw_seterrno (DWARF_E_INVALID_DWARF);
+	      return NULL;
+	    }
+	  /* .eh_frame_hdr does not indicate length covered by FDE.  */
+	  if (unlikely (address >= fde->end))
+	    goto no_match;
 	}
       return fde;
     }


More information about the elfutils-devel mailing list