EH_CIE_OR_FDE_TYPE_ID = EH_CIE_TYPE_ID | EH_FDE_TYPE_ID
 };
 
-static const gdb_byte *decode_frame_entry (struct comp_unit *unit,
+static const gdb_byte *decode_frame_entry (struct gdbarch *gdbarch,
+                                          struct comp_unit *unit,
                                           const gdb_byte *start,
                                           int eh_frame_p,
                                           dwarf2_cie_table &cie_table,
    Return NULL if invalid input, otherwise the next byte to be processed.  */
 
 static const gdb_byte *
-decode_frame_entry_1 (struct comp_unit *unit, const gdb_byte *start,
+decode_frame_entry_1 (struct gdbarch *gdbarch,
+                     struct comp_unit *unit, const gdb_byte *start,
                      int eh_frame_p,
                       dwarf2_cie_table &cie_table,
                       dwarf2_fde_table *fde_table,
                       enum eh_frame_type entry_type)
 {
-  struct gdbarch *gdbarch = get_objfile_arch (unit->objfile);
   const gdb_byte *buf, *end;
   ULONGEST length;
   unsigned int bytes_read;
       fde->cie = find_cie (cie_table, cie_pointer);
       if (fde->cie == NULL)
        {
-         decode_frame_entry (unit, unit->dwarf_frame_buffer + cie_pointer,
+         decode_frame_entry (gdbarch, unit,
+                             unit->dwarf_frame_buffer + cie_pointer,
                              eh_frame_p, cie_table, fde_table,
                              EH_CIE_TYPE_ID);
          fde->cie = find_cie (cie_table, cie_pointer);
    expect an FDE or a CIE.  */
 
 static const gdb_byte *
-decode_frame_entry (struct comp_unit *unit, const gdb_byte *start,
+decode_frame_entry (struct gdbarch *gdbarch,
+                   struct comp_unit *unit, const gdb_byte *start,
                    int eh_frame_p,
                    dwarf2_cie_table &cie_table,
                     dwarf2_fde_table *fde_table,
 
   while (1)
     {
-      ret = decode_frame_entry_1 (unit, start, eh_frame_p,
+      ret = decode_frame_entry_1 (gdbarch, unit, start, eh_frame_p,
                                  cie_table, fde_table, entry_type);
       if (ret != NULL)
        break;
   dwarf2_cie_table cie_table;
   dwarf2_fde_table fde_table;
 
+  struct gdbarch *gdbarch = get_objfile_arch (objfile);
+
   /* Build a minimal decoding of the DWARF2 compilation unit.  */
   std::unique_ptr<comp_unit> unit (new comp_unit (objfile));
 
            {
              frame_ptr = unit->dwarf_frame_buffer;
              while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size)
-               frame_ptr = decode_frame_entry (unit.get (), frame_ptr, 1,
+               frame_ptr = decode_frame_entry (gdbarch, unit.get (),
+                                               frame_ptr, 1,
                                                cie_table, &fde_table,
                                                EH_CIE_OR_FDE_TYPE_ID);
            }
        {
          frame_ptr = unit->dwarf_frame_buffer;
          while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size)
-           frame_ptr = decode_frame_entry (unit.get (), frame_ptr, 0,
+           frame_ptr = decode_frame_entry (gdbarch, unit.get (), frame_ptr, 0,
                                            cie_table, &fde_table,
                                            EH_CIE_OR_FDE_TYPE_ID);
        }