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