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