Commit | Line | Data |
---|---|---|
3af9a47b | 1 | /* PowerPC traceback table support for BFD. |
82704155 | 2 | Copyright (C) 1993-2019 Free Software Foundation, Inc. |
3af9a47b NC |
3 | |
4 | This file is part of BFD, the Binary File Descriptor library. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
cd123cb7 | 8 | the Free Software Foundation; either version 3 of the License, or |
3af9a47b NC |
9 | (at your option) any later version. |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
68ffbac6 | 17 | along with this program; if not, write to the Free Software |
cd123cb7 NC |
18 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
19 | MA 02110-1301, USA. */ | |
3af9a47b | 20 | |
cd123cb7 NC |
21 | |
22 | /* Originally written by Ira Ruben, 06/28/93. */ | |
3af9a47b NC |
23 | |
24 | /* This is a compiler independent representation of the AIX Version 3 traceback table (in | |
25 | sys/debug.h), which occurs, usually, one per procedure (routine). The table is marked by | |
26 | a multiple of 4 32-bit word of zeroes in the instruction space. The traceback table is | |
27 | also referred to as "procedure-end table". | |
68ffbac6 | 28 | |
3af9a47b NC |
29 | The AIX traceback table representation on which this header is based is defined as a |
30 | series of bit field struct specifications. Bit fields are compiler dependent! Thus, | |
31 | the definitions presented here follow the original header and the existing documentation | |
32 | (such as it is), but define the fields as BIT MASKS and other macros. The mask names, | |
68ffbac6 | 33 | however, where chosen as the original field names to give some compatibility with the |
3af9a47b NC |
34 | original header and to agree with the documentation. */ |
35 | ||
36 | #ifndef __TRACEBACK__ | |
37 | #define __TRACEBACK__ | |
38 | ||
39 | #define TB_C 0U /* C */ | |
40 | #define TB_FORTRAN 1U /* FORTRAN */ | |
41 | #define TB_PASCAL 2U /* Pascal */ | |
42 | #define TB_ADA 3U /* ADA */ | |
43 | #define TB_PL1 4U /* PL1 */ | |
44 | #define TB_BASIC 5U /* Basic */ | |
45 | #define TB_LISP 6U /* Lisp */ | |
46 | #define TB_COBOL 7U /* eCobol */ | |
47 | #define TB_MODULA2 8U /* Modula2 */ | |
48 | #define TB_CPLUSPLUS 9U /* C++ */ | |
49 | #define TB_RPG 10U /* RPG */ | |
50 | #define TB_PL8 11U /* PL8 */ | |
51 | #define TB_ASM 12U /* Asm */ | |
68ffbac6 | 52 | |
116c20d2 | 53 | /* Flags 1. */ |
3af9a47b NC |
54 | |
55 | #define TB_GLOBALLINK 0x80U /* Routine is Global Linkage. */ | |
56 | #define TB_is_eprol 0x40U /* Out-of-line prolog or epilog routine. */ | |
57 | #define TB_HAS_TBOFF 0x20U /* tb_offset set (extension field). */ | |
58 | #define TB_INT_PROC 0x10U /* Internal leaf routine. */ | |
59 | #define TB_HAS_CTL 0x08U /* Has controlled automatic storage. */ | |
60 | #define TB_TOCLESS 0X04U /* Routine has no TOC. */ | |
68ffbac6 | 61 | #define TB_FP_PRESENT 0x02U /* Routine has floating point ops. */ |
3af9a47b | 62 | #define TB_LOG_ABORT 0x01U /* fp_present && log/abort compiler opt. */ |
68ffbac6 | 63 | |
116c20d2 | 64 | /* Flags 2. */ |
3af9a47b NC |
65 | |
66 | #define TB_INT_HNDL 0x80U /* Routine is an interrupt handler. */ | |
67 | #define TB_NAME_PRESENT 0x40U /* Name_len/name set (extension field). */ | |
68 | #define TB_USES_ALLOCA 0x20U /* Uses alloca() to allocate storage. */ | |
69 | #define TB_CL_DIS_inv 0x1CU /* On-condition directives (see below). */ | |
70 | #define TB_SAVES_CR 0x02U /* Routine saves the CR. */ | |
71 | #define TB_SAVES_LR 0x01U /* Routine saves the LR. */ | |
68ffbac6 | 72 | |
116c20d2 | 73 | /* cl_dis_inv "on condition" settings: */ |
68ffbac6 | 74 | |
3af9a47b NC |
75 | #define TB_CL_DIS_INV(x) (((x) & cl_dis_inv) >> 2U) |
76 | ||
77 | #define TB_WALK_ONCOND 0U /* Walk stack without restoring state. */ | |
78 | #define TB_DISCARD_ONCOND 1U /* Walk stack and discard. */ | |
79 | #define TB_INVOKE_ONCOND 2U /* Invoke a specific system routine. */ | |
68ffbac6 | 80 | |
116c20d2 | 81 | /* Flags 3. */ |
3af9a47b NC |
82 | |
83 | #define TB_STORES_BC 0x80U /* Routine saves frame ptr of caller. */ | |
84 | #define TB_SPARE2 0X40U /* Spare bit. */ | |
85 | #define TB_FPR_SAVED 0x3fU /* Number of FPRs saved (max of 32). */ | |
86 | /* (Last reg saved is ALWAYS fpr31). */ | |
87 | ||
88 | #define TB_NUM_FPR_SAVED(x) ((x) & fpr_saved) | |
68ffbac6 | 89 | |
116c20d2 | 90 | /* Flags 4. */ |
3af9a47b NC |
91 | |
92 | #define TB_HAS_VEC_INFO 0x80U /* Routine uses vectors. */ | |
93 | #define TB_SPARE3 0X40U /* Spare bit. */ | |
94 | #define TB_GPR_SAVED 0x3fU /* Number of GPRs saved (max of 32). */ | |
95 | /* (Last reg saved is ALWAYS gpr31). */ | |
96 | ||
97 | #define TB_NUM_GPR_SAVED(x) ((x) & gpr_saved) | |
68ffbac6 | 98 | |
116c20d2 | 99 | /* Flags 5. */ |
3af9a47b NC |
100 | |
101 | #define TB_FLOATPARAMS 0xfeU /* Number of floating point parameters. */ | |
102 | #define TB_PARAMSONSTK 0X01U /* All parameters are on the stack. */ | |
68ffbac6 | 103 | |
3af9a47b NC |
104 | #define TB_NUM_FLOATPARAMS(X) (((x) & floatparams) >> 1U) |
105 | ||
116c20d2 | 106 | /* Traceback_table (fixed portion). */ |
3af9a47b NC |
107 | |
108 | struct traceback_table | |
109 | { | |
110 | /* Traceback table layout (fixed portion): */ | |
111 | ||
112 | unsigned char version; /* Traceback format version. */ | |
113 | unsigned char lang; /* Language indicators: */ | |
114 | unsigned char flags1; /* Flag bits #1: */ | |
115 | unsigned char flags2; /* Flag bits #2: */ | |
116 | unsigned char flags3; /* Flag bits #3: */ | |
117 | unsigned char flags4; /* Flag bits #4: */ | |
118 | unsigned char fixedparams; /* Number of fixed point parameters. */ | |
119 | unsigned char flags5; /* Flag bits #5: */ | |
120 | }; | |
121 | ||
122 | /* traceback_table (optional) extensions. */ | |
123 | ||
124 | /* Optional portions exist independently in the order presented below, | |
125 | not as a structure or a union. Whether or not portions exist is | |
126 | determinable from bit-fields within the fixed portion above. */ | |
127 | ||
128 | /* The following is present only if fixedparams or floatparams are non | |
129 | zero and it immediately follows the fixed portion of the traceback | |
130 | table... */ | |
131 | ||
132 | /* Order and type encoding of parameters: */ | |
133 | struct traceback_table_fixedparams | |
134 | { | |
68ffbac6 | 135 | unsigned long paraminfo; |
3af9a47b NC |
136 | }; |
137 | ||
138 | /* Left-justified bit-encoding as follows: */ | |
139 | #define FIXED_PARAM 0 /* '0' ==> fixed param (1 gpr or word). */ | |
140 | #define SPFP_PARAM 2 /* '10' ==> single-precision float param. */ | |
141 | #define DPFP_PARAM 3 /* '11' ==> double-precision float param. */ | |
142 | ||
143 | #define PARAM_ENCODING(x, bit) /* Yields xxx_PARAM as a function of "bit". */ \ | |
144 | ((((x)&(1UL<<(31UL-(bit++))))==0UL) /* Values 0:31 (left-to-right). "bit" is */ \ | |
145 | ? FIXED_PARAM /* an L-value that's left incremented to */ \ | |
146 | : ((((x)&(1UL<<(31UL-(bit++))))==0)/* the next bit position for the next */ \ | |
147 | ? SPFP_PARAM /* parameter. This will be 1 or 2 bit */ \ | |
148 | : DPFP_PARAM)) /* positions later. */ | |
149 | ||
150 | /* The following is present only if has_tboff (in flags1) in fixed part is present... */ | |
151 | ||
152 | /* Offset from start of code to TracebackTbl. */ | |
153 | struct traceback_table_tboff | |
154 | { | |
155 | unsigned long tb_offset; | |
156 | }; | |
157 | ||
158 | /* The following is present only if int_hndl (in flags2) in fixed part is present ... */ | |
159 | ||
160 | /* What interrupts are handled by the routine. */ | |
161 | struct traceback_table_interrupts | |
162 | { | |
163 | long hand_mask; | |
164 | }; | |
165 | ||
166 | /* The following are present only if has_ctl (in flags1) in fixed part is present... */ | |
167 | ||
168 | /* Controlled automatic storage info: */ | |
169 | struct traceback_table_anchors | |
170 | { | |
68ffbac6 | 171 | unsigned long ctl_info; /* Number of controlled automatic anchors. */ |
3af9a47b NC |
172 | long ctl_info_disp[1]; /* Array of stack displacements where each. */ |
173 | }; /* Anchor is located (array STARTS here). */ | |
174 | ||
175 | /* The following are present only if name_present (in flags2) in fixed | |
176 | part is present... */ | |
177 | ||
178 | /* Routine name: */ | |
179 | struct traceback_table_routine | |
180 | { | |
181 | unsigned short name_len; /* Length of name that follows. */ | |
182 | char name[1]; /* Name starts here (NOT null terminated). */ | |
183 | }; | |
184 | ||
185 | /* The following are present only if uses_alloca (in flags2) in fixed | |
186 | part is present... */ | |
187 | ||
188 | /* Register auto storage when alloca() is used. */ | |
189 | struct traceback_table_alloca | |
190 | { | |
191 | char alloca_reg; | |
192 | }; | |
193 | ||
194 | /* The following are present only if has_vec_info (in flags4) in fixed | |
195 | part is present... */ | |
196 | ||
197 | /* Vector info: */ | |
198 | struct traceback_table_vector | |
199 | { | |
200 | unsigned char vec_flags1; /* Vec info bits #1: */ | |
201 | ||
202 | #define TB_VR_SAVED 0xFCU /* Number of saved vector registers. */ | |
203 | #define TB_SAVES_VRSAVE 0x02U /* Saves VRsave. */ | |
204 | #define TB_HAS_VARARGS 0x01U /* Routine has a variable argument list. */ | |
205 | ||
206 | #define TB_NUM_VR_SAVED(x) (((x) & TB_VR_SAVED) >> 2U) | |
68ffbac6 | 207 | |
3af9a47b NC |
208 | unsigned char vec_flags2; /* Vec info bits #2: */ |
209 | ||
210 | #define TB_VECTORPARAMS 0xfeU /* Number of vector parameters. */ | |
211 | #define TB_VEC_PRESENT 0x01U /* Routine uses at least one vec instr. */ | |
68ffbac6 | 212 | |
3af9a47b NC |
213 | #define VECPARAMS(x) (((x) & TB_VECTORPARAMS) >> 1U) |
214 | }; | |
215 | ||
216 | #endif |