Blame sysdeps/arm/unwind.h

Packit 6c4009
/* Header file for the ARM EABI unwinder
Packit 6c4009
   Copyright (C) 2003-2018 Free Software Foundation, Inc.
Packit 6c4009
   Contributed by Paul Brook
Packit 6c4009
Packit 6c4009
   This file is free software; you can redistribute it and/or modify it
Packit 6c4009
   under the terms of the GNU General Public License as published by the
Packit 6c4009
   Free Software Foundation; either version 2, or (at your option) any
Packit 6c4009
   later version.
Packit 6c4009
Packit 6c4009
   In addition to the permissions in the GNU General Public License, the
Packit 6c4009
   Free Software Foundation gives you unlimited permission to link the
Packit 6c4009
   compiled version of this file into combinations with other programs,
Packit 6c4009
   and to distribute those combinations without any restriction coming
Packit 6c4009
   from the use of this file.  (The General Public License restrictions
Packit 6c4009
   do apply in other respects; for example, they cover modification of
Packit 6c4009
   the file, and distribution when not linked into a combine
Packit 6c4009
   executable.)
Packit 6c4009
Packit 6c4009
   This file is distributed in the hope that it will be useful, but
Packit 6c4009
   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU General Public License
Packit 6c4009
   along with this program.  If not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
/* Language-independent unwinder header public defines.  This contains both
Packit 6c4009
   ABI defined objects, and GNU support routines.  */
Packit 6c4009
Packit 6c4009
#ifndef UNWIND_ARM_H
Packit 6c4009
#define UNWIND_ARM_H
Packit 6c4009
Packit 6c4009
#define __ARM_EABI_UNWINDER__ 1
Packit 6c4009
Packit 6c4009
#ifdef __cplusplus
Packit 6c4009
extern "C" {
Packit 6c4009
#endif
Packit 6c4009
  typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
Packit 6c4009
  typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
Packit 6c4009
  typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
Packit 6c4009
  typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
Packit 6c4009
  typedef _Unwind_Word _uw;
Packit 6c4009
  typedef unsigned _uw64 __attribute__((mode(__DI__)));
Packit 6c4009
  typedef unsigned _uw16 __attribute__((mode(__HI__)));
Packit 6c4009
  typedef unsigned _uw8 __attribute__((mode(__QI__)));
Packit 6c4009
Packit 6c4009
  typedef enum
Packit 6c4009
    {
Packit 6c4009
      _URC_OK = 0,       /* operation completed successfully */
Packit 6c4009
      _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
Packit 6c4009
      _URC_END_OF_STACK = 5,
Packit 6c4009
      _URC_HANDLER_FOUND = 6,
Packit 6c4009
      _URC_INSTALL_CONTEXT = 7,
Packit 6c4009
      _URC_CONTINUE_UNWIND = 8,
Packit 6c4009
      _URC_FAILURE = 9   /* unspecified failure of some kind */
Packit 6c4009
    }
Packit 6c4009
  _Unwind_Reason_Code;
Packit 6c4009
Packit 6c4009
  typedef enum
Packit 6c4009
    {
Packit 6c4009
      _US_VIRTUAL_UNWIND_FRAME = 0,
Packit 6c4009
      _US_UNWIND_FRAME_STARTING = 1,
Packit 6c4009
      _US_UNWIND_FRAME_RESUME = 2,
Packit 6c4009
      _US_ACTION_MASK = 3,
Packit 6c4009
      _US_FORCE_UNWIND = 8,
Packit 6c4009
      _US_END_OF_STACK = 16
Packit 6c4009
    }
Packit 6c4009
  _Unwind_State;
Packit 6c4009
Packit 6c4009
  /* Provided only for for compatibility with existing code.  */
Packit 6c4009
  typedef int _Unwind_Action;
Packit 6c4009
#define _UA_SEARCH_PHASE	1
Packit 6c4009
#define _UA_CLEANUP_PHASE	2
Packit 6c4009
#define _UA_HANDLER_FRAME	4
Packit 6c4009
#define _UA_FORCE_UNWIND	8
Packit 6c4009
#define _UA_END_OF_STACK	16
Packit 6c4009
#define _URC_NO_REASON 	_URC_OK
Packit 6c4009
Packit 6c4009
  typedef struct _Unwind_Control_Block _Unwind_Control_Block;
Packit 6c4009
  typedef struct _Unwind_Context _Unwind_Context;
Packit 6c4009
  typedef _uw _Unwind_EHT_Header;
Packit 6c4009
Packit 6c4009
Packit 6c4009
  /* UCB: */
Packit 6c4009
Packit 6c4009
  struct _Unwind_Control_Block
Packit 6c4009
    {
Packit 6c4009
#ifdef _LIBC
Packit 6c4009
      /* For the benefit of code which assumes this is a scalar.  All
Packit 6c4009
	 glibc ever does is clear it.  */
Packit 6c4009
      _uw64 exception_class;
Packit 6c4009
#else
Packit 6c4009
      char exception_class[8];
Packit 6c4009
#endif
Packit 6c4009
      void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *);
Packit 6c4009
      /* Unwinder cache, private fields for the unwinder's use */
Packit 6c4009
      struct
Packit 6c4009
	{
Packit 6c4009
	  _uw reserved1;  /* Forced unwind stop fn, 0 if not forced */
Packit 6c4009
	  _uw reserved2;  /* Personality routine address */
Packit 6c4009
	  _uw reserved3;  /* Saved callsite address */
Packit 6c4009
	  _uw reserved4;  /* Forced unwind stop arg */
Packit 6c4009
	  _uw reserved5;
Packit 6c4009
	}
Packit 6c4009
      unwinder_cache;
Packit 6c4009
      /* Propagation barrier cache (valid after phase 1): */
Packit 6c4009
      struct
Packit 6c4009
	{
Packit 6c4009
	  _uw sp;
Packit 6c4009
	  _uw bitpattern[5];
Packit 6c4009
	}
Packit 6c4009
      barrier_cache;
Packit 6c4009
      /* Cleanup cache (preserved over cleanup): */
Packit 6c4009
      struct
Packit 6c4009
	{
Packit 6c4009
	  _uw bitpattern[4];
Packit 6c4009
	}
Packit 6c4009
      cleanup_cache;
Packit 6c4009
      /* Pr cache (for pr's benefit): */
Packit 6c4009
      struct
Packit 6c4009
	{
Packit 6c4009
	  _uw fnstart;			/* function start address */
Packit 6c4009
	  _Unwind_EHT_Header *ehtp;	/* pointer to EHT entry header word */
Packit 6c4009
	  _uw additional;		/* additional data */
Packit 6c4009
	  _uw reserved1;
Packit 6c4009
	}
Packit 6c4009
      pr_cache;
Packit 6c4009
      long long int :0;	/* Force alignment to 8-byte boundary */
Packit 6c4009
    };
Packit 6c4009
Packit 6c4009
  /* Virtual Register Set*/
Packit 6c4009
Packit 6c4009
  typedef enum
Packit 6c4009
    {
Packit 6c4009
      _UVRSC_CORE = 0,      /* integer register */
Packit 6c4009
      _UVRSC_VFP = 1,       /* vfp */
Packit 6c4009
      _UVRSC_FPA = 2,       /* fpa */
Packit 6c4009
      _UVRSC_WMMXD = 3,     /* Intel WMMX data register */
Packit 6c4009
      _UVRSC_WMMXC = 4      /* Intel WMMX control register */
Packit 6c4009
    }
Packit 6c4009
  _Unwind_VRS_RegClass;
Packit 6c4009
Packit 6c4009
  typedef enum
Packit 6c4009
    {
Packit 6c4009
      _UVRSD_UINT32 = 0,
Packit 6c4009
      _UVRSD_VFPX = 1,
Packit 6c4009
      _UVRSD_FPAX = 2,
Packit 6c4009
      _UVRSD_UINT64 = 3,
Packit 6c4009
      _UVRSD_FLOAT = 4,
Packit 6c4009
      _UVRSD_DOUBLE = 5
Packit 6c4009
    }
Packit 6c4009
  _Unwind_VRS_DataRepresentation;
Packit 6c4009
Packit 6c4009
  typedef enum
Packit 6c4009
    {
Packit 6c4009
      _UVRSR_OK = 0,
Packit 6c4009
      _UVRSR_NOT_IMPLEMENTED = 1,
Packit 6c4009
      _UVRSR_FAILED = 2
Packit 6c4009
    }
Packit 6c4009
  _Unwind_VRS_Result;
Packit 6c4009
Packit 6c4009
  /* Frame unwinding state.  */
Packit 6c4009
  typedef struct
Packit 6c4009
    {
Packit 6c4009
      /* The current word (bytes packed msb first).  */
Packit 6c4009
      _uw data;
Packit 6c4009
      /* Pointer to the next word of data.  */
Packit 6c4009
      _uw *next;
Packit 6c4009
      /* The number of bytes left in this word.  */
Packit 6c4009
      _uw8 bytes_left;
Packit 6c4009
      /* The number of words pointed to by ptr.  */
Packit 6c4009
      _uw8 words_left;
Packit 6c4009
    }
Packit 6c4009
  __gnu_unwind_state;
Packit 6c4009
Packit 6c4009
  typedef _Unwind_Reason_Code (*personality_routine) (_Unwind_State,
Packit 6c4009
      _Unwind_Control_Block *, _Unwind_Context *);
Packit 6c4009
Packit 6c4009
  _Unwind_VRS_Result _Unwind_VRS_Set(_Unwind_Context *, _Unwind_VRS_RegClass,
Packit 6c4009
                                     _uw, _Unwind_VRS_DataRepresentation,
Packit 6c4009
                                     void *);
Packit 6c4009
Packit 6c4009
  _Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *, _Unwind_VRS_RegClass,
Packit 6c4009
                                     _uw, _Unwind_VRS_DataRepresentation,
Packit 6c4009
                                     void *);
Packit 6c4009
Packit 6c4009
  _Unwind_VRS_Result _Unwind_VRS_Pop(_Unwind_Context *, _Unwind_VRS_RegClass,
Packit 6c4009
                                     _uw, _Unwind_VRS_DataRepresentation);
Packit 6c4009
Packit 6c4009
Packit 6c4009
  /* Support functions for the PR.  */
Packit 6c4009
#define _Unwind_Exception _Unwind_Control_Block
Packit 6c4009
  typedef char _Unwind_Exception_Class[8];
Packit 6c4009
Packit 6c4009
  void * _Unwind_GetLanguageSpecificData (_Unwind_Context *);
Packit 6c4009
  _Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *);
Packit 6c4009
Packit 6c4009
  /* These two should never be used.  */
Packit 6c4009
  _Unwind_Ptr _Unwind_GetDataRelBase (_Unwind_Context *);
Packit 6c4009
  _Unwind_Ptr _Unwind_GetTextRelBase (_Unwind_Context *);
Packit 6c4009
Packit 6c4009
  /* Interface functions: */
Packit 6c4009
  _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Control_Block *ucbp);
Packit 6c4009
  void __attribute__((noreturn)) _Unwind_Resume(_Unwind_Control_Block *ucbp);
Packit 6c4009
  _Unwind_Reason_Code _Unwind_Resume_or_Rethrow (_Unwind_Control_Block *ucbp);
Packit 6c4009
Packit 6c4009
  typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
Packit 6c4009
       (int, _Unwind_Action, _Unwind_Exception_Class,
Packit 6c4009
	_Unwind_Control_Block *, struct _Unwind_Context *, void *);
Packit 6c4009
  _Unwind_Reason_Code _Unwind_ForcedUnwind (_Unwind_Control_Block *,
Packit 6c4009
					    _Unwind_Stop_Fn, void *);
Packit 6c4009
  _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
Packit 6c4009
  void _Unwind_Complete(_Unwind_Control_Block *ucbp);
Packit 6c4009
  void _Unwind_DeleteException (_Unwind_Exception *);
Packit 6c4009
Packit 6c4009
  _Unwind_Reason_Code __gnu_unwind_frame (_Unwind_Control_Block *,
Packit 6c4009
					  _Unwind_Context *);
Packit 6c4009
  _Unwind_Reason_Code __gnu_unwind_execute (_Unwind_Context *,
Packit 6c4009
					    __gnu_unwind_state *);
Packit 6c4009
Packit 6c4009
  /* Decode an R_ARM_TARGET2 relocation.  */
Packit 6c4009
  static inline _Unwind_Word
Packit 6c4009
  _Unwind_decode_target2 (_Unwind_Word ptr)
Packit 6c4009
    {
Packit 6c4009
      _Unwind_Word tmp;
Packit 6c4009
Packit 6c4009
      tmp = *(_Unwind_Word *) ptr;
Packit 6c4009
      /* Zero values are always NULL.  */
Packit 6c4009
      if (!tmp)
Packit 6c4009
	return 0;
Packit 6c4009
Packit 6c4009
#if defined(linux) || defined(__NetBSD__)
Packit 6c4009
      /* Pc-relative indirect.  */
Packit 6c4009
      tmp += ptr;
Packit 6c4009
      tmp = *(_Unwind_Word *) tmp;
Packit 6c4009
#elif defined(__symbian__)
Packit 6c4009
      /* Absolute pointer.  Nothing more to do.  */
Packit 6c4009
#else
Packit 6c4009
      /* Pc-relative pointer.  */
Packit 6c4009
      tmp += ptr;
Packit 6c4009
#endif
Packit 6c4009
      return tmp;
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  static inline _Unwind_Word
Packit 6c4009
  _Unwind_GetGR (_Unwind_Context *context, int regno)
Packit 6c4009
    {
Packit 6c4009
      _uw val;
Packit 6c4009
      _Unwind_VRS_Get (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val;;
Packit 6c4009
      return val;
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  /* Return the address of the instruction, not the actual IP value.  */
Packit 6c4009
#define _Unwind_GetIP(context) \
Packit 6c4009
  (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
Packit 6c4009
Packit 6c4009
  static inline void
Packit 6c4009
  _Unwind_SetGR (_Unwind_Context *context, int regno, _Unwind_Word val)
Packit 6c4009
    {
Packit 6c4009
      _Unwind_VRS_Set (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val;;
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  /* The dwarf unwinder doesn't understand arm/thumb state.  We assume the
Packit 6c4009
     landing pad uses the same instruction set as the call site.  */
Packit 6c4009
#define _Unwind_SetIP(context, val) \
Packit 6c4009
  _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1))
Packit 6c4009
Packit 6c4009
typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
Packit 6c4009
     (struct _Unwind_Context *, void *);
Packit 6c4009
Packit 6c4009
extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
Packit 6c4009
Packit 6c4009
#ifdef __cplusplus
Packit 6c4009
}   /* extern "C" */
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#endif /* defined UNWIND_ARM_H */