[PATCH 05/10] libdwfl: Flag an error if CIE return_address_register is invalid.

Mark Wielaard mark@klomp.org
Tue Jun 16 22:25:34 GMT 2020


If the CIE return address register is invalid (unknown) for the
architecture immediately flag an error and return.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdwfl/ChangeLog      | 5 +++++
 libdwfl/frame_unwind.c | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 44b3ece7..5a3d566f 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2020-06-16  Mark Wielaard  <mark@klomp.org>
+
+	* frame_unwind.c (handle_cfi): Flag an error if
+	return_address_register is invalid.
+
 2020-06-16  Mark Wielaard  <mark@klomp.org>
 
 	* linux-kernel-modules.c (try_kernel_name): Don't try other
diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c
index d7dfa5a9..bdceeb3e 100644
--- a/libdwfl/frame_unwind.c
+++ b/libdwfl/frame_unwind.c
@@ -562,7 +562,11 @@ handle_cfi (Dwfl_Frame *state, Dwarf_Addr pc, Dwarf_CFI *cfi, Dwarf_Addr bias)
   /* The return register is special for setting the unwound->pc_state.  */
   unsigned ra = frame->fde->cie->return_address_register;
   bool ra_set = false;
-  ebl_dwarf_to_regno (ebl, &ra);
+  if (! ebl_dwarf_to_regno (ebl, &ra))
+    {
+      __libdwfl_seterrno (DWFL_E_INVALID_REGISTER);
+      return;
+    }
 
   for (unsigned regno = 0; regno < nregs; regno++)
     {
-- 
2.18.4



More information about the Elfutils-devel mailing list