Canonicalize CIE fde_encoding at interning.
authorRoland McGrath <roland@redhat.com>
Wed, 16 Jun 2010 10:11:57 +0000 (03:11 -0700)
committerRoland McGrath <roland@redhat.com>
Wed, 16 Jun 2010 10:11:57 +0000 (03:11 -0700)
libdw/ChangeLog
libdw/cie.c

index e0e4c55..f974e96 100644 (file)
@@ -1,5 +1,8 @@
 2010-06-16  Roland McGrath  <roland@redhat.com>
 
+       * cie.c (intern_new_cie): Canonicalize DW_EH_PE_absptr FDE encoding to
+       either DW_EH_PE_udata8 or DW_EH_PE_udata4.
+
        * encoded-value.h (read_encoded_value): Handle DW_EH_PE_indirect.
        Don't assume DW_EH_PE_aligned refers to native address size.
 
index 08752a6..7c93f55 100644 (file)
@@ -1,5 +1,5 @@
 /* CIE 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
@@ -53,6 +53,7 @@
 
 #include "cfi.h"
 #include "encoded-value.h"
+#include <assert.h>
 #include <search.h>
 #include <stdlib.h>
 
@@ -135,6 +136,29 @@ intern_new_cie (Dwarf_CFI *cache, Dwarf_Off offset, const Dwarf_CIE *info)
       break;
     }
 
+  if ((cie->fde_encoding & 0x0f) == DW_EH_PE_absptr)
+    {
+      /* Canonicalize encoding to a specific size.  */
+      assert (DW_EH_PE_absptr == 0);
+
+      /* XXX should get from dwarf_next_cfi with v4 header.  */
+      uint_fast8_t address_size
+       = cache->e_ident[EI_CLASS] == ELFCLASS32 ? 4 : 8;
+      switch (address_size)
+       {
+       case 8:
+         cie->fde_encoding |= DW_EH_PE_udata8;
+         break;
+       case 4:
+         cie->fde_encoding |= DW_EH_PE_udata4;
+         break;
+       default:
+         free (cie);
+         __libdw_seterrno (DWARF_E_INVALID_DWARF);
+         return NULL;
+       }
+    }
+
   /* Save the initial instructions to be played out into initial state.  */
   cie->initial_instructions = info->initial_instructions;
   cie->initial_instructions_end = info->initial_instructions_end;