summaryrefslogtreecommitdiffstats
path: root/libdw/fde.c
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>2010-06-16 03:40:56 -0700
committerRoland McGrath <[email protected]>2010-06-16 11:16:45 -0700
commit3e4b5bbeca8987527c11a1ea048459a7ebd4ab5e (patch)
tree3d50b9a1c32c4c41eac398d9d6bd91b16e26c858 /libdw/fde.c
parent5f4b5089e1e3ca3c696cb420a6e215006691cf95 (diff)
Add new dwarf_cfi_validate_fde call.
Diffstat (limited to 'libdw/fde.c')
-rw-r--r--libdw/fde.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/libdw/fde.c b/libdw/fde.c
index c826114c..5685252b 100644
--- a/libdw/fde.c
+++ b/libdw/fde.c
@@ -1,5 +1,5 @@
/* FDE reading.
- Copyright (C) 2009 Red Hat, Inc.
+ Copyright (C) 2009-2010 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -139,8 +139,9 @@ intern_fde (Dwarf_CFI *cache, const Dwarf_FDE *entry)
return fde;
}
-static struct dwarf_fde *
-fde_by_offset (Dwarf_CFI *cache, Dwarf_Addr address, Dwarf_Off offset)
+struct dwarf_fde *
+internal_function
+__libdw_fde_by_offset (Dwarf_CFI *cache, Dwarf_Off offset)
{
Dwarf_CFI_Entry entry;
Dwarf_Off next_offset;
@@ -167,10 +168,6 @@ fde_by_offset (Dwarf_CFI *cache, Dwarf_Addr address, Dwarf_Off offset)
if (cache->next_offset == offset)
cache->next_offset = next_offset;
- /* Sanity check the address range. */
- if (address < fde->start || address >= fde->end)
- goto invalid;
-
return fde;
}
@@ -254,7 +251,15 @@ __libdw_find_fde (Dwarf_CFI *cache, Dwarf_Addr address)
Dwarf_Off offset = binary_search_fde (cache, address);
if (offset == (Dwarf_Off) -1l)
goto no_match;
- return fde_by_offset (cache, address, offset);
+ 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))
+ {
+ __libdw_seterrno (DWARF_E_INVALID_DWARF);
+ return NULL;
+ }
+ return fde;
}
/* It's not there. Read more CFI entries until we find it. */