1 /* Subroutines needed for unwinding stack frames for exception handling. */
2 /* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
4 Contributed by Jason Merrill <jason@cygnus.com>.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
13 In addition to the permissions in the GNU General Public License, the
14 Free Software Foundation gives you unlimited permission to link the
15 compiled version of this file into combinations with other programs,
16 and to distribute those combinations without any restriction coming
17 from the use of this file. (The General Public License restrictions
18 do apply in other respects; for example, they cover modification of
19 the file, and distribution when not linked into a combine
22 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
23 WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 You should have received a copy of the GNU General Public License
28 along with GCC; see the file COPYING. If not, write to the Free
29 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
32 #ifndef GCC_UNWIND_DW2_FDE_H
33 #define GCC_UNWIND_DW2_FDE_H
37 const void *orig_data;
39 const struct dwarf_fde *array[];
48 const struct dwarf_fde *single;
49 struct dwarf_fde **array;
50 struct fde_vector *sort;
55 unsigned long sorted : 1;
56 unsigned long from_array : 1;
57 unsigned long mixed_encoding : 1;
58 unsigned long encoding : 8;
59 /* ??? Wish there was an easy way to detect a 64-bit host here;
60 we've got 32 bits left to play with... */
61 unsigned long count : 21;
66 #ifdef DWARF2_OBJECT_END_PTR_EXTENSION
73 /* This is the original definition of struct object. While the struct
74 itself was opaque to users, they did know how large it was, and
75 allocate one statically in crtbegin for each DSO. Keep this around
76 so that we're aware of the static size limitations for the new struct. */
81 struct dwarf_fde *fde_begin;
82 struct dwarf_fde **fde_array;
84 struct old_object *next;
95 extern void __register_frame_info_bases (const void *, struct object *,
97 extern void __register_frame_info (const void *, struct object *);
98 extern void __register_frame (void *);
99 extern void __register_frame_info_table_bases (void *, struct object *,
101 extern void __register_frame_info_table (void *, struct object *);
102 extern void __register_frame_table (void *);
103 extern void *__deregister_frame_info (const void *);
104 extern void *__deregister_frame_info_bases (const void *);
105 extern void __deregister_frame (void *);
108 typedef int sword __attribute__ ((mode (SI)));
109 typedef unsigned int uword __attribute__ ((mode (SI)));
110 typedef unsigned int uaddr __attribute__ ((mode (pointer)));
111 typedef int saddr __attribute__ ((mode (pointer)));
112 typedef unsigned char ubyte;
115 CIE - Common Information Element
116 FDE - Frame Descriptor Element
118 There is one per function, and it describes where the function code
119 is located, and what the register lifetimes and stack layout are
122 The data structures are defined in the DWARF specification, although
123 not in a very readable way (see LITERATURE).
125 Every time an exception is thrown, the code needs to locate the FDE
126 for the current function, and starts to look for exception regions
127 from that FDE. This works in a two-level search:
128 a) in a linear search, find the shared image (i.e. DLL) containing
130 b) using the FDE table for that shared object, locate the FDE using
131 binary search (which requires the sorting). */
133 /* The first few fields of a CIE. The CIE_id field is 0 for a CIE,
134 to distinguish it from a valid FDE. FDEs are aligned to an addressing
135 unit boundary, but the fields within are unaligned. */
141 unsigned char augmentation[];
142 } __attribute__ ((packed, aligned (__alignof__ (void *))));
144 /* The first few fields of an FDE. */
149 unsigned char pc_begin[];
150 } __attribute__ ((packed, aligned (__alignof__ (void *))));
152 typedef struct dwarf_fde fde;
154 /* Locate the CIE for a given FDE. */
156 static inline const struct dwarf_cie *
157 get_cie (const struct dwarf_fde *f)
159 return (void *)&f->CIE_delta - f->CIE_delta;
162 static inline const fde *
163 next_fde (const fde *f)
165 return (const fde *) ((char *) f + f->length + sizeof (f->length));
168 extern const fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);
171 last_fde (struct object *obj __attribute__ ((__unused__)), const fde *f)
173 #ifdef DWARF2_OBJECT_END_PTR_EXTENSION
174 return (char *)f == obj->fde_end || f->length == 0;
176 return f->length == 0;
180 #endif /* unwind-dw2-fde.h */