Root/
Source at commit 1129 created 12 years 11 months ago. By meklort, Change options.o so that it reloads the system config as well. Also change it so that it uses that config for variables (NOTE: if the calue exists in chameleonConfig, it's used instead. | |
---|---|
1 | /* -*- mode: C; c-basic-offset: 4; tab-width: 4 -*-␊ |
2 | *␊ |
3 | * Copyright (c) 2008-2009 Apple Inc. All rights reserved.␊ |
4 | *␊ |
5 | * @APPLE_LICENSE_HEADER_START@␊ |
6 | *␊ |
7 | * This file contains Original Code and/or Modifications of Original Code␊ |
8 | * as defined in and that are subject to the Apple Public Source License␊ |
9 | * Version 2.0 (the 'License'). You may not use this file except in␊ |
10 | * compliance with the License. Please obtain a copy of the License at␊ |
11 | * http://www.opensource.apple.com/apsl/ and read it before using this␊ |
12 | * file.␊ |
13 | *␊ |
14 | * The Original Code and all software distributed under the License are␊ |
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.␊ |
19 | * Please see the License for the specific language governing rights and␊ |
20 | * limitations under the License.␊ |
21 | *␊ |
22 | * @APPLE_LICENSE_HEADER_END@␊ |
23 | */␊ |
24 | ␊ |
25 | ␊ |
26 | #ifndef __COMPACT_UNWIND_ENCODING__␊ |
27 | #define __COMPACT_UNWIND_ENCODING__␊ |
28 | ␊ |
29 | #include <stdint.h>␊ |
30 | ␊ |
31 | ␊ |
32 | // ␊ |
33 | // Each final linked mach-o image has an optional __TEXT, __unwind_info section.␊ |
34 | // This section is much smaller and faster to use than the __eh_frame section.␊ |
35 | //␊ |
36 | ␊ |
37 | ␊ |
38 | ␊ |
39 | //␊ |
40 | // Compilers usually emit standard Dwarf FDEs. The linker recognizes standard FDEs and␊ |
41 | // synthesizes a matching compact_unwind_encoding_t and adds it to the __unwind_info table.␊ |
42 | // It is also possible for the compiler to emit __unwind_info entries for functions that ␊ |
43 | // have different unwind requirements at different ranges in the function.␊ |
44 | //␊ |
45 | typedef uint32_t compact_unwind_encoding_t;␊ |
46 | ␊ |
47 | ␊ |
48 | ␊ |
49 | //␊ |
50 | // The __unwind_info section is laid out for an efficient two level lookup.␊ |
51 | // The header of the section contains a coarse index that maps function address␊ |
52 | // to the page (4096 byte block) containing the unwind info for that function. ␊ |
53 | //␊ |
54 | ␊ |
55 | #define UNWIND_SECTION_VERSION 1␊ |
56 | struct unwind_info_section_header␊ |
57 | {␊ |
58 | uint32_t version; // UNWIND_SECTION_VERSION␊ |
59 | uint32_t commonEncodingsArraySectionOffset;␊ |
60 | uint32_t commonEncodingsArrayCount;␊ |
61 | uint32_t personalityArraySectionOffset;␊ |
62 | uint32_t personalityArrayCount;␊ |
63 | uint32_t indexSectionOffset;␊ |
64 | uint32_t indexCount;␊ |
65 | // compact_unwind_encoding_t[]␊ |
66 | // uintptr_t personalities[]␊ |
67 | // unwind_info_section_header_index_entry[]␊ |
68 | // unwind_info_section_header_lsda_index_entry[]␊ |
69 | };␊ |
70 | ␊ |
71 | struct unwind_info_section_header_index_entry ␊ |
72 | {␊ |
73 | uint32_t functionOffset;␊ |
74 | uint32_t secondLevelPagesSectionOffset; // section offset to start of regular or compress page␊ |
75 | uint32_t lsdaIndexArraySectionOffset; // section offset to start of lsda_index array for this range␊ |
76 | };␊ |
77 | ␊ |
78 | struct unwind_info_section_header_lsda_index_entry ␊ |
79 | {␊ |
80 | uint32_t functionOffset;␊ |
81 | uint32_t lsdaOffset;␊ |
82 | };␊ |
83 | ␊ |
84 | //␊ |
85 | // There are two kinds of second level index pages: regular and compressed.␊ |
86 | // A compressed page can hold up to 1021 entries, but it cannot be used␊ |
87 | // if too many different encoding types are used. The regular page holds␊ |
88 | // 511 entries. ␊ |
89 | //␊ |
90 | ␊ |
91 | struct unwind_info_regular_second_level_entry ␊ |
92 | {␊ |
93 | uint32_t functionOffset;␊ |
94 | compact_unwind_encoding_t encoding;␊ |
95 | };␊ |
96 | ␊ |
97 | #define UNWIND_SECOND_LEVEL_REGULAR 2␊ |
98 | struct unwind_info_regular_second_level_page_header␊ |
99 | {␊ |
100 | uint32_t kind; // UNWIND_SECOND_LEVEL_REGULAR␊ |
101 | uint16_t entryPageOffset;␊ |
102 | uint16_t entryCount;␊ |
103 | // entry array␊ |
104 | };␊ |
105 | ␊ |
106 | #define UNWIND_SECOND_LEVEL_COMPRESSED 3␊ |
107 | struct unwind_info_compressed_second_level_page_header␊ |
108 | {␊ |
109 | uint32_t kind; // UNWIND_SECOND_LEVEL_COMPRESSED␊ |
110 | uint16_t entryPageOffset;␊ |
111 | uint16_t entryCount;␊ |
112 | uint16_t encodingsPageOffset;␊ |
113 | uint16_t encodingsCount;␊ |
114 | // 32-bit entry array ␊ |
115 | // encodings array␊ |
116 | };␊ |
117 | ␊ |
118 | #define UNWIND_INFO_COMPRESSED_ENTRY_FUNC_OFFSET(entry) (entry & 0x00FFFFFF)␊ |
119 | #define UNWIND_INFO_COMPRESSED_ENTRY_ENCODING_INDEX(entry) ((entry >> 24) & 0xFF)␊ |
120 | ␊ |
121 | ␊ |
122 | ␊ |
123 | // architecture independent bits␊ |
124 | enum {␊ |
125 | UNWIND_IS_NOT_FUNCTION_START = 0x80000000,␊ |
126 | UNWIND_HAS_LSDA = 0x40000000,␊ |
127 | UNWIND_PERSONALITY_MASK = 0x30000000,␊ |
128 | };␊ |
129 | ␊ |
130 | ␊ |
131 | // x86_64␊ |
132 | //␊ |
133 | // 1-bit: start␊ |
134 | // 1-bit: has lsda␊ |
135 | // 2-bit: personality index␊ |
136 | //␊ |
137 | // 4-bits: 0=old, 1=rbp based, 2=stack-imm, 3=stack-ind, 4=dwarf␊ |
138 | // rbp based:␊ |
139 | // 15-bits (5*3-bits per reg) register permutation␊ |
140 | // 8-bits for stack offset␊ |
141 | // frameless:␊ |
142 | // 8-bits stack size␊ |
143 | // 3-bits stack adjust␊ |
144 | // 3-bits register count␊ |
145 | // 10-bits register permutation␊ |
146 | //␊ |
147 | enum {␊ |
148 | UNWIND_X86_64_MODE_MASK = 0x0F000000,␊ |
149 | UNWIND_X86_64_MODE_COMPATIBILITY = 0x00000000,␊ |
150 | UNWIND_X86_64_MODE_RBP_FRAME = 0x01000000,␊ |
151 | UNWIND_X86_64_MODE_STACK_IMMD = 0x02000000,␊ |
152 | UNWIND_X86_64_MODE_STACK_IND = 0x03000000,␊ |
153 | UNWIND_X86_64_MODE_DWARF = 0x04000000,␊ |
154 | ␊ |
155 | UNWIND_X86_64_RBP_FRAME_REGISTERS = 0x00007FFF,␊ |
156 | UNWIND_X86_64_RBP_FRAME_OFFSET = 0x00FF0000,␊ |
157 | ␊ |
158 | UNWIND_X86_64_FRAMELESS_STACK_SIZE = 0x00FF0000,␊ |
159 | UNWIND_X86_64_FRAMELESS_STACK_ADJUST = 0x0000E000,␊ |
160 | UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT = 0x00001C00,␊ |
161 | UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF,␊ |
162 | ␊ |
163 | UNWIND_X86_64_DWARF_SECTION_OFFSET = 0x03FFFFFF,␊ |
164 | };␊ |
165 | ␊ |
166 | enum {␊ |
167 | UNWIND_X86_64_REG_NONE = 0,␊ |
168 | UNWIND_X86_64_REG_RBX = 1,␊ |
169 | UNWIND_X86_64_REG_R12 = 2,␊ |
170 | UNWIND_X86_64_REG_R13 = 3,␊ |
171 | UNWIND_X86_64_REG_R14 = 4,␊ |
172 | UNWIND_X86_64_REG_R15 = 5,␊ |
173 | UNWIND_X86_64_REG_RBP = 6,␊ |
174 | };␊ |
175 | ␊ |
176 | ␊ |
177 | // x86␊ |
178 | //␊ |
179 | // 1-bit: start␊ |
180 | // 1-bit: has lsda␊ |
181 | // 2-bit: personality index␊ |
182 | //␊ |
183 | // 4-bits: 0=old, 1=ebp based, 2=stack-imm, 3=stack-ind, 4=dwarf␊ |
184 | // ebp based:␊ |
185 | // 15-bits (5*3-bits per reg) register permutation␊ |
186 | // 8-bits for stack offset␊ |
187 | // frameless:␊ |
188 | // 8-bits stack size␊ |
189 | // 3-bits stack adjust␊ |
190 | // 3-bits register count␊ |
191 | // 10-bits register permutation␊ |
192 | //␊ |
193 | enum {␊ |
194 | UNWIND_X86_MODE_MASK = 0x0F000000,␊ |
195 | UNWIND_X86_MODE_COMPATIBILITY = 0x00000000,␊ |
196 | UNWIND_X86_MODE_EBP_FRAME = 0x01000000,␊ |
197 | UNWIND_X86_MODE_STACK_IMMD = 0x02000000,␊ |
198 | UNWIND_X86_MODE_STACK_IND = 0x03000000,␊ |
199 | UNWIND_X86_MODE_DWARF = 0x04000000,␊ |
200 | ␊ |
201 | UNWIND_X86_EBP_FRAME_REGISTERS = 0x00007FFF,␊ |
202 | UNWIND_X86_EBP_FRAME_OFFSET = 0x00FF0000,␊ |
203 | ␊ |
204 | UNWIND_X86_FRAMELESS_STACK_SIZE = 0x00FF0000,␊ |
205 | UNWIND_X86_FRAMELESS_STACK_ADJUST = 0x0000E000,␊ |
206 | UNWIND_X86_FRAMELESS_STACK_REG_COUNT = 0x00001C00,␊ |
207 | UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF,␊ |
208 | ␊ |
209 | UNWIND_X86_DWARF_SECTION_OFFSET = 0x03FFFFFF,␊ |
210 | };␊ |
211 | ␊ |
212 | enum {␊ |
213 | UNWIND_X86_REG_NONE = 0,␊ |
214 | UNWIND_X86_REG_EBX = 1,␊ |
215 | UNWIND_X86_REG_ECX = 2,␊ |
216 | UNWIND_X86_REG_EDX = 3,␊ |
217 | UNWIND_X86_REG_EDI = 4,␊ |
218 | UNWIND_X86_REG_ESI = 5,␊ |
219 | UNWIND_X86_REG_EBP = 6,␊ |
220 | };␊ |
221 | ␊ |
222 | ␊ |
223 | #endif␊ |
224 | ␊ |
225 |