1 /* Subroutines needed for unwinding stack frames for exception handling. */
2 /* Copyright (C) 1997-2020 Free Software Foundation, Inc.
3 Contributed by Jason Merrill <jason@cygnus.com>.
5 This file is part of the GNU C Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <https://www.gnu.org/licenses/>. */
26 struct dwarf_fde
*array __flexarr
;
38 struct dwarf_fde
*single
;
39 struct dwarf_fde
**array
;
40 struct fde_vector
*sort
;
45 unsigned long sorted
: 1;
46 unsigned long from_array
: 1;
47 unsigned long mixed_encoding
: 1;
48 unsigned long encoding
: 8;
49 /* ??? Wish there was an easy way to detect a 64-bit host here;
50 we've got 32 bits left to play with... */
51 unsigned long count
: 21;
56 #ifdef DWARF2_OBJECT_END_PTR_EXTENSION
64 /* This is the original definition of struct object. While the struct
65 itself was opaque to users, they did know how large it was, and
66 allocate one statically in crtbegin for each DSO. Keep this around
67 so that we're aware of the static size limitations for the new struct. */
72 struct dwarf_fde
*fde_begin
;
73 struct dwarf_fde
**fde_array
;
75 struct old_object
*next
;
86 extern void __register_frame_info_bases (void *, struct object
*,
88 extern void __register_frame_info (void *, struct object
*);
89 extern void __register_frame (void *);
90 extern void __register_frame_info_table_bases (void *, struct object
*,
92 extern void __register_frame_info_table (void *, struct object
*);
93 extern void __register_frame_table (void *);
94 extern void *__deregister_frame_info (void *);
95 extern void *__deregister_frame_info_bases (void *);
96 extern void __deregister_frame (void *);
99 typedef int sword
__attribute__ ((mode (SI
)));
100 typedef unsigned int uword
__attribute__ ((mode (SI
)));
101 typedef unsigned int uaddr
__attribute__ ((mode (pointer
)));
102 typedef int saddr
__attribute__ ((mode (pointer
)));
103 typedef unsigned char ubyte
;
106 CIE - Common Information Element
107 FDE - Frame Descriptor Element
109 There is one per function, and it describes where the function code
110 is located, and what the register lifetimes and stack layout are
113 The data structures are defined in the DWARF specification, although
114 not in a very readable way (see LITERATURE).
116 Every time an exception is thrown, the code needs to locate the FDE
117 for the current function, and starts to look for exception regions
118 from that FDE. This works in a two-level search:
119 a) in a linear search, find the shared image (i.e. DLL) containing
121 b) using the FDE table for that shared object, locate the FDE using
122 binary search (which requires the sorting). */
124 /* The first few fields of a CIE. The CIE_id field is 0 for a CIE,
125 to distinguish it from a valid FDE. FDEs are aligned to an addressing
126 unit boundary, but the fields within are unaligned. */
132 unsigned char augmentation __flexarr
;
133 } __attribute__ ((packed
, aligned (__alignof__ (void *))));
135 /* The first few fields of an FDE. */
140 unsigned char pc_begin __flexarr
;
141 } __attribute__ ((packed
, aligned (__alignof__ (void *))));
143 typedef struct dwarf_fde fde
;
145 /* Locate the CIE for a given FDE. */
147 static inline struct dwarf_cie
*
148 get_cie (struct dwarf_fde
*f
)
150 return (void *)&f
->CIE_delta
- f
->CIE_delta
;
156 return (fde
*) ((char *) f
+ f
->length
+ sizeof (f
->length
));
159 extern fde
* _Unwind_Find_FDE (void *, struct dwarf_eh_bases
*);
162 last_fde (struct object
*obj
__attribute__ ((__unused__
)), fde
*f
)
164 #ifdef DWARF2_OBJECT_END_PTR_EXTENSION
165 return (char *)f
== obj
->fde_end
|| f
->length
== 0;
167 return f
->length
== 0;