Sort sysdeps/powerpc/fpu/libm-test-ulps
[glibc.git] / sysdeps / generic / unwind-dw2-fde.h
blobbc047dd6a2e1b152dc6a45b8eae8af182af03666
1 /* Subroutines needed for unwinding stack frames for exception handling. */
2 /* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 Free Software Foundation, Inc.
4 Contributed by Jason Merrill <jason@cygnus.com>.
6 This file is part of the GNU C Library.
8 The GNU C Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
13 The GNU C Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with the GNU C Library; if not, see
20 <http://www.gnu.org/licenses/>. */
23 struct fde_vector
25 void *orig_data;
26 size_t count;
27 struct dwarf_fde *array __flexarr;
30 #ifdef _LIBC
31 #include <gccframe.h>
32 #else
33 struct object
35 void *pc_begin;
36 void *tbase;
37 void *dbase;
38 union {
39 struct dwarf_fde *single;
40 struct dwarf_fde **array;
41 struct fde_vector *sort;
42 } u;
44 union {
45 struct {
46 unsigned long sorted : 1;
47 unsigned long from_array : 1;
48 unsigned long mixed_encoding : 1;
49 unsigned long encoding : 8;
50 /* ??? Wish there was an easy way to detect a 64-bit host here;
51 we've got 32 bits left to play with... */
52 unsigned long count : 21;
53 } b;
54 size_t i;
55 } s;
57 #ifdef DWARF2_OBJECT_END_PTR_EXTENSION
58 char *fde_end;
59 #endif
61 struct object *next;
63 #endif
65 /* This is the original definition of struct object. While the struct
66 itself was opaque to users, they did know how large it was, and
67 allocate one statically in crtbegin for each DSO. Keep this around
68 so that we're aware of the static size limitations for the new struct. */
69 struct old_object
71 void *pc_begin;
72 void *pc_end;
73 struct dwarf_fde *fde_begin;
74 struct dwarf_fde **fde_array;
75 size_t count;
76 struct old_object *next;
79 struct dwarf_eh_bases
81 void *tbase;
82 void *dbase;
83 void *func;
87 extern void __register_frame_info_bases (void *, struct object *,
88 void *, void *);
89 extern void __register_frame_info (void *, struct object *);
90 extern void __register_frame (void *);
91 extern void __register_frame_info_table_bases (void *, struct object *,
92 void *, void *);
93 extern void __register_frame_info_table (void *, struct object *);
94 extern void __register_frame_table (void *);
95 extern void *__deregister_frame_info (void *);
96 extern void *__deregister_frame_info_bases (void *);
97 extern void __deregister_frame (void *);
100 typedef int sword __attribute__ ((mode (SI)));
101 typedef unsigned int uword __attribute__ ((mode (SI)));
102 typedef unsigned int uaddr __attribute__ ((mode (pointer)));
103 typedef int saddr __attribute__ ((mode (pointer)));
104 typedef unsigned char ubyte;
106 /* Terminology:
107 CIE - Common Information Element
108 FDE - Frame Descriptor Element
110 There is one per function, and it describes where the function code
111 is located, and what the register lifetimes and stack layout are
112 within the function.
114 The data structures are defined in the DWARF specification, although
115 not in a very readable way (see LITERATURE).
117 Every time an exception is thrown, the code needs to locate the FDE
118 for the current function, and starts to look for exception regions
119 from that FDE. This works in a two-level search:
120 a) in a linear search, find the shared image (i.e. DLL) containing
121 the PC
122 b) using the FDE table for that shared object, locate the FDE using
123 binary search (which requires the sorting). */
125 /* The first few fields of a CIE. The CIE_id field is 0 for a CIE,
126 to distinguish it from a valid FDE. FDEs are aligned to an addressing
127 unit boundary, but the fields within are unaligned. */
128 struct dwarf_cie
130 uword length;
131 sword CIE_id;
132 ubyte version;
133 unsigned char augmentation __flexarr;
134 } __attribute__ ((packed, aligned (__alignof__ (void *))));
136 /* The first few fields of an FDE. */
137 struct dwarf_fde
139 uword length;
140 sword CIE_delta;
141 unsigned char pc_begin __flexarr;
142 } __attribute__ ((packed, aligned (__alignof__ (void *))));
144 typedef struct dwarf_fde fde;
146 /* Locate the CIE for a given FDE. */
148 static inline struct dwarf_cie *
149 get_cie (struct dwarf_fde *f)
151 return (void *)&f->CIE_delta - f->CIE_delta;
154 static inline fde *
155 next_fde (fde *f)
157 return (fde *) ((char *) f + f->length + sizeof (f->length));
160 extern fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);
162 static inline int
163 last_fde (struct object *obj __attribute__ ((__unused__)), fde *f)
165 #ifdef DWARF2_OBJECT_END_PTR_EXTENSION
166 return (char *)f == obj->fde_end || f->length == 0;
167 #else
168 return f->length == 0;
169 #endif