1*f3e7f55eSRobert Mustacchi /* 2*f3e7f55eSRobert Mustacchi 3*f3e7f55eSRobert Mustacchi Copyright (C) 2000, 2004, 2006 Silicon Graphics, Inc. All Rights Reserved. 4*f3e7f55eSRobert Mustacchi 5*f3e7f55eSRobert Mustacchi This program is free software; you can redistribute it and/or modify it 6*f3e7f55eSRobert Mustacchi under the terms of version 2.1 of the GNU Lesser General Public License 7*f3e7f55eSRobert Mustacchi as published by the Free Software Foundation. 8*f3e7f55eSRobert Mustacchi 9*f3e7f55eSRobert Mustacchi This program is distributed in the hope that it would be useful, but 10*f3e7f55eSRobert Mustacchi WITHOUT ANY WARRANTY; without even the implied warranty of 11*f3e7f55eSRobert Mustacchi MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12*f3e7f55eSRobert Mustacchi 13*f3e7f55eSRobert Mustacchi Further, this software is distributed without any warranty that it is 14*f3e7f55eSRobert Mustacchi free of the rightful claim of any third person regarding infringement 15*f3e7f55eSRobert Mustacchi or the like. Any license provided herein, whether implied or 16*f3e7f55eSRobert Mustacchi otherwise, applies only to this software file. Patent licenses, if 17*f3e7f55eSRobert Mustacchi any, provided herein do not apply to combinations of this program with 18*f3e7f55eSRobert Mustacchi other software, or any other product whatsoever. 19*f3e7f55eSRobert Mustacchi 20*f3e7f55eSRobert Mustacchi You should have received a copy of the GNU Lesser General Public 21*f3e7f55eSRobert Mustacchi License along with this program; if not, write the Free Software 22*f3e7f55eSRobert Mustacchi Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23*f3e7f55eSRobert Mustacchi USA. 24*f3e7f55eSRobert Mustacchi 25*f3e7f55eSRobert Mustacchi Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, 26*f3e7f55eSRobert Mustacchi Mountain View, CA 94043, or: 27*f3e7f55eSRobert Mustacchi 28*f3e7f55eSRobert Mustacchi http://www.sgi.com 29*f3e7f55eSRobert Mustacchi 30*f3e7f55eSRobert Mustacchi For further information regarding this notice, see: 31*f3e7f55eSRobert Mustacchi 32*f3e7f55eSRobert Mustacchi http://oss.sgi.com/projects/GenInfo/NoticeExplan 33*f3e7f55eSRobert Mustacchi 34*f3e7f55eSRobert Mustacchi */ 35*f3e7f55eSRobert Mustacchi 36*f3e7f55eSRobert Mustacchi 37*f3e7f55eSRobert Mustacchi 38*f3e7f55eSRobert Mustacchi /* The dwarf 2.0 standard dictates that only the following 39*f3e7f55eSRobert Mustacchi * fields can be read when an unexpected augmentation string 40*f3e7f55eSRobert Mustacchi * (in the cie) is encountered: CIE length, CIE_id, version and 41*f3e7f55eSRobert Mustacchi * augmentation; FDE: length, CIE pointer, initial location and 42*f3e7f55eSRobert Mustacchi * address range. Unfortunately, with the above restrictions, it 43*f3e7f55eSRobert Mustacchi * is impossible to read the instruction table from a CIE or a FDE 44*f3e7f55eSRobert Mustacchi * when a new augmentation string is encountered. 45*f3e7f55eSRobert Mustacchi * To fix this problem, the following layout is used, if the 46*f3e7f55eSRobert Mustacchi * augmentation string starts with the string "z". 47*f3e7f55eSRobert Mustacchi * CIE FDE 48*f3e7f55eSRobert Mustacchi * length length 49*f3e7f55eSRobert Mustacchi * CIE_id CIE_pointer 50*f3e7f55eSRobert Mustacchi * version initial_location 51*f3e7f55eSRobert Mustacchi * augmentation address_range 52*f3e7f55eSRobert Mustacchi * length_of_augmented_fields (*NEW*) 53*f3e7f55eSRobert Mustacchi * code_alignment_factor Any new fields as necessary 54*f3e7f55eSRobert Mustacchi * data_alignment_factor instruction_table 55*f3e7f55eSRobert Mustacchi * return_address 56*f3e7f55eSRobert Mustacchi * length_of_augmented fields 57*f3e7f55eSRobert Mustacchi * Any new fields as necessary 58*f3e7f55eSRobert Mustacchi * initial_instructions 59*f3e7f55eSRobert Mustacchi * 60*f3e7f55eSRobert Mustacchi * The type of all the old data items are the same as what is 61*f3e7f55eSRobert Mustacchi * described in dwarf 2.0 standard. The length_of_augmented_fields 62*f3e7f55eSRobert Mustacchi * is an LEB128 data item that denotes the size (in bytes) of 63*f3e7f55eSRobert Mustacchi * the augmented fields (not including the size of 64*f3e7f55eSRobert Mustacchi * "length_of_augmented_fields" itself). 65*f3e7f55eSRobert Mustacchi 66*f3e7f55eSRobert Mustacchi * Handling of cie augmentation strings is necessarly a heuristic. 67*f3e7f55eSRobert Mustacchi * See dwarf_frame.c for the currently known augmentation strings. 68*f3e7f55eSRobert Mustacchi 69*f3e7f55eSRobert Mustacchi 70*f3e7f55eSRobert Mustacchi ---START SGI-ONLY COMMENT: 71*f3e7f55eSRobert Mustacchi * SGI-IRIX versions of cie or fde were intended to use "z1", "z2" as the 72*f3e7f55eSRobert Mustacchi * augmenter strings if required for new augmentation. 73*f3e7f55eSRobert Mustacchi * However, that never happened (as of March 2005). 74*f3e7f55eSRobert Mustacchi * 75*f3e7f55eSRobert Mustacchi * The fde's augmented by the string "z" have a new field 76*f3e7f55eSRobert Mustacchi * (signed constant, 4 byte field) 77*f3e7f55eSRobert Mustacchi * called offset_into_exception_tables, following the 78*f3e7f55eSRobert Mustacchi * length_of_augmented field. This field contains an offset 79*f3e7f55eSRobert Mustacchi * into the "_MIPS_eh_region", which describes 80*f3e7f55eSRobert Mustacchi * the IRIX CC exception handling tables. 81*f3e7f55eSRobert Mustacchi ---END SGI-ONLY COMMENT 82*f3e7f55eSRobert Mustacchi 83*f3e7f55eSRobert Mustacchi 84*f3e7f55eSRobert Mustacchi * GNU .eh_frame has an augmentation string of z[RLP]* (gcc 3.4) 85*f3e7f55eSRobert Mustacchi * The similarity to IRIX 'z' (and proposed but never 86*f3e7f55eSRobert Mustacchi * implemented IRIX z1, z2 etc) was confusing things. 87*f3e7f55eSRobert Mustacchi * If the section is .eh_frame then 'z' means GNU exception 88*f3e7f55eSRobert Mustacchi * information 'Augmentation Data' not IRIX 'z'. 89*f3e7f55eSRobert Mustacchi * See The Linux Standard Base Core Specification version 3.0 90*f3e7f55eSRobert Mustacchi */ 91*f3e7f55eSRobert Mustacchi 92*f3e7f55eSRobert Mustacchi #define DW_DEBUG_FRAME_VERSION 1 /* DWARF2 */ 93*f3e7f55eSRobert Mustacchi #define DW_DEBUG_FRAME_VERSION3 3 /* DWARF3 */ 94*f3e7f55eSRobert Mustacchi #define DW_DEBUG_FRAME_VERSION4 4 /* DWARF4 */ 95*f3e7f55eSRobert Mustacchi /* The following is SGI/IRIX specific, and probably no longer 96*f3e7f55eSRobert Mustacchi in use anywhere. */ 97*f3e7f55eSRobert Mustacchi #define DW_DEBUG_FRAME_AUGMENTER_STRING "mti v1" 98*f3e7f55eSRobert Mustacchi 99*f3e7f55eSRobert Mustacchi /* The value of the offset field for Cie's. */ 100*f3e7f55eSRobert Mustacchi #define DW_CIE_OFFSET ~(0x0) 101*f3e7f55eSRobert Mustacchi 102*f3e7f55eSRobert Mustacchi /* The augmentation string may be NULL. */ 103*f3e7f55eSRobert Mustacchi #define DW_EMPTY_STRING "" 104*f3e7f55eSRobert Mustacchi 105*f3e7f55eSRobert Mustacchi #define DW_FRAME_INSTR_OPCODE_SHIFT 6 106*f3e7f55eSRobert Mustacchi #define DW_FRAME_INSTR_OFFSET_MASK 0x3f 107*f3e7f55eSRobert Mustacchi 108*f3e7f55eSRobert Mustacchi /* 109*f3e7f55eSRobert Mustacchi This struct denotes the rule for a register in a row of 110*f3e7f55eSRobert Mustacchi the frame table. In other words, it is one element of 111*f3e7f55eSRobert Mustacchi the table. 112*f3e7f55eSRobert Mustacchi */ 113*f3e7f55eSRobert Mustacchi struct Dwarf_Reg_Rule_s { 114*f3e7f55eSRobert Mustacchi 115*f3e7f55eSRobert Mustacchi /* 116*f3e7f55eSRobert Mustacchi Is a flag indicating whether the rule includes the offset 117*f3e7f55eSRobert Mustacchi field, ie whether the ru_offset field is valid or not. 118*f3e7f55eSRobert Mustacchi Applies only if DW_EXPR_OFFSET or DW_EXPR_VAL_OFFSET. 119*f3e7f55eSRobert Mustacchi It is important, since reg+offset (offset of 0) is different from 120*f3e7f55eSRobert Mustacchi just 'register' since the former means 'read memory at address 121*f3e7f55eSRobert Mustacchi given by the sum of register contents plus offset to get the 122*f3e7f55eSRobert Mustacchi value'. whereas the latter means 'the value is in the register'. 123*f3e7f55eSRobert Mustacchi 124*f3e7f55eSRobert Mustacchi The 'register' numbers are either real registers (ie, table 125*f3e7f55eSRobert Mustacchi columns defined as real registers) or defined entries that are 126*f3e7f55eSRobert Mustacchi not really hardware registers, such as DW_FRAME_SAME_VAL or 127*f3e7f55eSRobert Mustacchi DW_FRAME_CFA_COL. 128*f3e7f55eSRobert Mustacchi 129*f3e7f55eSRobert Mustacchi */ 130*f3e7f55eSRobert Mustacchi Dwarf_Sbyte ru_is_off; 131*f3e7f55eSRobert Mustacchi 132*f3e7f55eSRobert Mustacchi /* DW_EXPR_OFFSET (0, DWARF2) 133*f3e7f55eSRobert Mustacchi DW_EXPR_VAL_OFFSET 1 (dwarf2/3) 134*f3e7f55eSRobert Mustacchi DW_EXPR_EXPRESSION 2 (dwarf2/3) 135*f3e7f55eSRobert Mustacchi DW_EXPR_VAL_EXPRESSION 3 (dwarf2/3) 136*f3e7f55eSRobert Mustacchi See dwarf_frame.h. */ 137*f3e7f55eSRobert Mustacchi Dwarf_Sbyte ru_value_type; 138*f3e7f55eSRobert Mustacchi 139*f3e7f55eSRobert Mustacchi /* Register involved in this rule. */ 140*f3e7f55eSRobert Mustacchi Dwarf_Half ru_register; 141*f3e7f55eSRobert Mustacchi 142*f3e7f55eSRobert Mustacchi /* Offset to add to register, if indicated by ru_is_offset 143*f3e7f55eSRobert Mustacchi and if DW_EXPR_OFFSET or DW_EXPR_VAL_OFFSET. 144*f3e7f55eSRobert Mustacchi If DW_EXPR_EXPRESSION or DW_EXPR_VAL_EXPRESSION 145*f3e7f55eSRobert Mustacchi this is DW_FORM_block block-length, not offset. */ 146*f3e7f55eSRobert Mustacchi Dwarf_Unsigned ru_offset_or_block_len; 147*f3e7f55eSRobert Mustacchi 148*f3e7f55eSRobert Mustacchi /* For DW_EXPR_EXPRESSION DW_EXPR_VAL_EXPRESSION these is set, 149*f3e7f55eSRobert Mustacchi else 0. */ 150*f3e7f55eSRobert Mustacchi Dwarf_Small *ru_block; 151*f3e7f55eSRobert Mustacchi }; 152*f3e7f55eSRobert Mustacchi 153*f3e7f55eSRobert Mustacchi typedef struct Dwarf_Frame_s *Dwarf_Frame; 154*f3e7f55eSRobert Mustacchi 155*f3e7f55eSRobert Mustacchi /* 156*f3e7f55eSRobert Mustacchi This structure represents a row of the frame table. 157*f3e7f55eSRobert Mustacchi Fr_loc is the pc value for this row, and Fr_reg 158*f3e7f55eSRobert Mustacchi contains the rule for each column. 159*f3e7f55eSRobert Mustacchi 160*f3e7f55eSRobert Mustacchi Entry DW_FRAME_CFA_COL of fr_reg was the tradional MIPS 161*f3e7f55eSRobert Mustacchi way of setting CFA. cfa_rule is the new one. 162*f3e7f55eSRobert Mustacchi */ 163*f3e7f55eSRobert Mustacchi struct Dwarf_Frame_s { 164*f3e7f55eSRobert Mustacchi 165*f3e7f55eSRobert Mustacchi /* Pc value corresponding to this row of the frame table. */ 166*f3e7f55eSRobert Mustacchi Dwarf_Addr fr_loc; 167*f3e7f55eSRobert Mustacchi 168*f3e7f55eSRobert Mustacchi /* Rules for all the registers in this row. */ 169*f3e7f55eSRobert Mustacchi struct Dwarf_Reg_Rule_s fr_cfa_rule; 170*f3e7f55eSRobert Mustacchi 171*f3e7f55eSRobert Mustacchi /* fr_reg_count is the the number of 172*f3e7f55eSRobert Mustacchi entries of the fr_reg array. */ 173*f3e7f55eSRobert Mustacchi unsigned long fr_reg_count; 174*f3e7f55eSRobert Mustacchi struct Dwarf_Reg_Rule_s *fr_reg; 175*f3e7f55eSRobert Mustacchi 176*f3e7f55eSRobert Mustacchi Dwarf_Frame fr_next; 177*f3e7f55eSRobert Mustacchi }; 178*f3e7f55eSRobert Mustacchi 179*f3e7f55eSRobert Mustacchi typedef struct Dwarf_Frame_Op_List_s *Dwarf_Frame_Op_List; 180*f3e7f55eSRobert Mustacchi 181*f3e7f55eSRobert Mustacchi /* This is used to chain together Dwarf_Frame_Op structures. */ 182*f3e7f55eSRobert Mustacchi struct Dwarf_Frame_Op_List_s { 183*f3e7f55eSRobert Mustacchi Dwarf_Frame_Op *fl_frame_instr; 184*f3e7f55eSRobert Mustacchi Dwarf_Frame_Op_List fl_next; 185*f3e7f55eSRobert Mustacchi }; 186*f3e7f55eSRobert Mustacchi 187*f3e7f55eSRobert Mustacchi /* See dwarf_frame.c for the heuristics used to set the 188*f3e7f55eSRobert Mustacchi Dwarf_Cie ci_augmentation_type. 189*f3e7f55eSRobert Mustacchi 190*f3e7f55eSRobert Mustacchi This succinctly helps interpret the size and meaning of .debug_frame 191*f3e7f55eSRobert Mustacchi and (for gcc) .eh_frame. 192*f3e7f55eSRobert Mustacchi 193*f3e7f55eSRobert Mustacchi In the case of gcc .eh_frame (gcc 3.3, 3.4) 194*f3e7f55eSRobert Mustacchi z may be followed by one or more of 195*f3e7f55eSRobert Mustacchi L R P. 196*f3e7f55eSRobert Mustacchi 197*f3e7f55eSRobert Mustacchi */ 198*f3e7f55eSRobert Mustacchi enum Dwarf_augmentation_type { 199*f3e7f55eSRobert Mustacchi aug_empty_string, /* Default empty augmentation string. */ 200*f3e7f55eSRobert Mustacchi aug_irix_exception_table, /* IRIX plain "z", 201*f3e7f55eSRobert Mustacchi for exception handling, IRIX CC compiler. 202*f3e7f55eSRobert Mustacchi Proposed z1 z2 ... never implemented. */ 203*f3e7f55eSRobert Mustacchi aug_gcc_eh_z, /* gcc z augmentation, (including 204*f3e7f55eSRobert Mustacchi L R P variations). gcc 3.3 3.4 exception 205*f3e7f55eSRobert Mustacchi handling in eh_frame. */ 206*f3e7f55eSRobert Mustacchi aug_irix_mti_v1, /* IRIX "mti v1" augmentation string. Probably 207*f3e7f55eSRobert Mustacchi never in any released SGI-IRIX compiler. */ 208*f3e7f55eSRobert Mustacchi aug_eh, /* For gcc .eh_frame, "eh" is the string., 209*f3e7f55eSRobert Mustacchi gcc 1,2, egcs. Older values. */ 210*f3e7f55eSRobert Mustacchi aug_armcc, /* "armcc+" meaning the cfa calculation 211*f3e7f55eSRobert Mustacchi is corrected to be standard (output by 212*f3e7f55eSRobert Mustacchi Arm C RVCT 3.0 SP1 and later). See 213*f3e7f55eSRobert Mustacchi http://sourceware.org/ml/gdb-patches/2006-12/msg00249.html 214*f3e7f55eSRobert Mustacchi for details. */ 215*f3e7f55eSRobert Mustacchi aug_unknown, /* Unknown augmentation, we cannot do much. */ 216*f3e7f55eSRobert Mustacchi aug_past_last 217*f3e7f55eSRobert Mustacchi }; 218*f3e7f55eSRobert Mustacchi 219*f3e7f55eSRobert Mustacchi 220*f3e7f55eSRobert Mustacchi /* 221*f3e7f55eSRobert Mustacchi This structure contains all the pertinent info for a Cie. Most 222*f3e7f55eSRobert Mustacchi of the fields are taken straight from the definition of a Cie. 223*f3e7f55eSRobert Mustacchi Ci_cie_start points to the address (in .debug_frame) where this 224*f3e7f55eSRobert Mustacchi Cie begins. Ci_cie_instr_start points to the first byte of the 225*f3e7f55eSRobert Mustacchi frame instructions for this Cie. Ci_dbg points to the associated 226*f3e7f55eSRobert Mustacchi Dwarf_Debug structure. Ci_initial_table is a pointer to the table 227*f3e7f55eSRobert Mustacchi row generated by the instructions for this Cie. 228*f3e7f55eSRobert Mustacchi */ 229*f3e7f55eSRobert Mustacchi struct Dwarf_Cie_s { 230*f3e7f55eSRobert Mustacchi Dwarf_Unsigned ci_length; 231*f3e7f55eSRobert Mustacchi char *ci_augmentation; 232*f3e7f55eSRobert Mustacchi Dwarf_Small ci_code_alignment_factor; 233*f3e7f55eSRobert Mustacchi Dwarf_Sbyte ci_data_alignment_factor; 234*f3e7f55eSRobert Mustacchi Dwarf_Small ci_return_address_register; 235*f3e7f55eSRobert Mustacchi Dwarf_Small *ci_cie_start; 236*f3e7f55eSRobert Mustacchi Dwarf_Small *ci_cie_instr_start; 237*f3e7f55eSRobert Mustacchi Dwarf_Debug ci_dbg; 238*f3e7f55eSRobert Mustacchi Dwarf_Frame ci_initial_table; 239*f3e7f55eSRobert Mustacchi Dwarf_Cie ci_next; 240*f3e7f55eSRobert Mustacchi Dwarf_Small ci_length_size; 241*f3e7f55eSRobert Mustacchi Dwarf_Small ci_extension_size; 242*f3e7f55eSRobert Mustacchi Dwarf_Half ci_cie_version_number; 243*f3e7f55eSRobert Mustacchi enum Dwarf_augmentation_type ci_augmentation_type; 244*f3e7f55eSRobert Mustacchi 245*f3e7f55eSRobert Mustacchi /* The following 2 for GNU .eh_frame exception handling 246*f3e7f55eSRobert Mustacchi Augmentation Data. Set if ci_augmentation_type 247*f3e7f55eSRobert Mustacchi is aug_gcc_eh_z. Zero if unused. */ 248*f3e7f55eSRobert Mustacchi Dwarf_Unsigned ci_gnu_eh_augmentation_len; 249*f3e7f55eSRobert Mustacchi Dwarf_Ptr ci_gnu_eh_augmentation_bytes; 250*f3e7f55eSRobert Mustacchi 251*f3e7f55eSRobert Mustacchi /* These are extracted from the gnu eh_frame 252*f3e7f55eSRobert Mustacchi augmentation if the 253*f3e7f55eSRobert Mustacchi augmentation begins with 'z'. See Linux LSB documents. 254*f3e7f55eSRobert Mustacchi Otherwize these are zero. */ 255*f3e7f55eSRobert Mustacchi unsigned char ci_gnu_personality_handler_encoding; 256*f3e7f55eSRobert Mustacchi unsigned char ci_gnu_lsda_encoding; 257*f3e7f55eSRobert Mustacchi unsigned char ci_gnu_fde_begin_encoding; 258*f3e7f55eSRobert Mustacchi 259*f3e7f55eSRobert Mustacchi /* If 'P' augmentation present, is handler addr. Else 260*f3e7f55eSRobert Mustacchi is zero. */ 261*f3e7f55eSRobert Mustacchi Dwarf_Addr ci_gnu_personality_handler_addr; 262*f3e7f55eSRobert Mustacchi 263*f3e7f55eSRobert Mustacchi 264*f3e7f55eSRobert Mustacchi /* In creating list of cie's (which will become an array) 265*f3e7f55eSRobert Mustacchi record the position so fde can get it on fde creation. */ 266*f3e7f55eSRobert Mustacchi Dwarf_Unsigned ci_index; 267*f3e7f55eSRobert Mustacchi Dwarf_Small * ci_section_ptr; 268*f3e7f55eSRobert Mustacchi /* DWARF4 adds address size and segment size to the CIE: the .debug_info 269*f3e7f55eSRobert Mustacchi section may not always be present to allow libdwarf to 270*f3e7f55eSRobert Mustacchi find address_size from the compilation-unit. */ 271*f3e7f55eSRobert Mustacchi Dwarf_Half ci_address_size; 272*f3e7f55eSRobert Mustacchi Dwarf_Half ci_segment_size; 273*f3e7f55eSRobert Mustacchi 274*f3e7f55eSRobert Mustacchi }; 275*f3e7f55eSRobert Mustacchi 276*f3e7f55eSRobert Mustacchi /* 277*f3e7f55eSRobert Mustacchi This structure contains all the pertinent info for a Fde. 278*f3e7f55eSRobert Mustacchi Most of the fields are taken straight from the definition. 279*f3e7f55eSRobert Mustacchi fd_cie_index is the index of the Cie associated with this 280*f3e7f55eSRobert Mustacchi Fde in the list of Cie's for this debug_frame. Fd_cie 281*f3e7f55eSRobert Mustacchi points to the corresponsing Dwarf_Cie structure. Fd_fde_start 282*f3e7f55eSRobert Mustacchi points to the start address of the Fde. Fd_fde_instr_start 283*f3e7f55eSRobert Mustacchi points to the start of the instructions for this Fde. Fd_dbg 284*f3e7f55eSRobert Mustacchi points to the associated Dwarf_Debug structure. 285*f3e7f55eSRobert Mustacchi */ 286*f3e7f55eSRobert Mustacchi struct Dwarf_Fde_s { 287*f3e7f55eSRobert Mustacchi Dwarf_Unsigned fd_length; 288*f3e7f55eSRobert Mustacchi Dwarf_Addr fd_cie_offset; 289*f3e7f55eSRobert Mustacchi Dwarf_Unsigned fd_cie_index; 290*f3e7f55eSRobert Mustacchi Dwarf_Cie fd_cie; 291*f3e7f55eSRobert Mustacchi Dwarf_Addr fd_initial_location; 292*f3e7f55eSRobert Mustacchi Dwarf_Small *fd_initial_loc_pos; 293*f3e7f55eSRobert Mustacchi Dwarf_Addr fd_address_range; 294*f3e7f55eSRobert Mustacchi Dwarf_Small *fd_fde_start; 295*f3e7f55eSRobert Mustacchi Dwarf_Small *fd_fde_instr_start; 296*f3e7f55eSRobert Mustacchi Dwarf_Debug fd_dbg; 297*f3e7f55eSRobert Mustacchi 298*f3e7f55eSRobert Mustacchi /* fd_offset_into_exception_tables is SGI/IRIX exception table 299*f3e7f55eSRobert Mustacchi offset. Unused and zero if not IRIX .debug_frame. */ 300*f3e7f55eSRobert Mustacchi Dwarf_Signed fd_offset_into_exception_tables; 301*f3e7f55eSRobert Mustacchi 302*f3e7f55eSRobert Mustacchi Dwarf_Fde fd_next; 303*f3e7f55eSRobert Mustacchi Dwarf_Small fd_length_size; 304*f3e7f55eSRobert Mustacchi Dwarf_Small fd_extension_size; 305*f3e7f55eSRobert Mustacchi /* So we know from an fde which 'count' of fde-s in 306*f3e7f55eSRobert Mustacchi Dwarf_Debug applies: eh or standard. */ 307*f3e7f55eSRobert Mustacchi Dwarf_Small fd_is_eh; 308*f3e7f55eSRobert Mustacchi /* The following 2 for GNU .eh_frame exception handling 309*f3e7f55eSRobert Mustacchi Augmentation Data. Set if CIE ci_augmentation_type 310*f3e7f55eSRobert Mustacchi is aug_gcc_eh_z. Zero if unused. */ 311*f3e7f55eSRobert Mustacchi Dwarf_Unsigned fd_gnu_eh_augmentation_len; 312*f3e7f55eSRobert Mustacchi Dwarf_Ptr fd_gnu_eh_augmentation_bytes; 313*f3e7f55eSRobert Mustacchi Dwarf_Addr fd_gnu_eh_lsda; /* If 'L' augmentation letter 314*f3e7f55eSRobert Mustacchi present: is address of the 315*f3e7f55eSRobert Mustacchi Language Specific Data Area (LSDA). If not 'L" is zero. */ 316*f3e7f55eSRobert Mustacchi 317*f3e7f55eSRobert Mustacchi /* The following 3 are about the Elf section the FDEs come from. */ 318*f3e7f55eSRobert Mustacchi Dwarf_Small * fd_section_ptr; 319*f3e7f55eSRobert Mustacchi Dwarf_Unsigned fd_section_length; 320*f3e7f55eSRobert Mustacchi Dwarf_Unsigned fd_section_index; 321*f3e7f55eSRobert Mustacchi 322*f3e7f55eSRobert Mustacchi }; 323*f3e7f55eSRobert Mustacchi 324*f3e7f55eSRobert Mustacchi 325*f3e7f55eSRobert Mustacchi int 326*f3e7f55eSRobert Mustacchi _dwarf_frame_address_offsets(Dwarf_Debug dbg, Dwarf_Addr ** addrlist, 327*f3e7f55eSRobert Mustacchi Dwarf_Off ** offsetlist, 328*f3e7f55eSRobert Mustacchi Dwarf_Signed * returncount, 329*f3e7f55eSRobert Mustacchi Dwarf_Error * err); 330*f3e7f55eSRobert Mustacchi 331*f3e7f55eSRobert Mustacchi int 332*f3e7f55eSRobert Mustacchi _dwarf_get_fde_list_internal(Dwarf_Debug dbg, 333*f3e7f55eSRobert Mustacchi Dwarf_Cie ** cie_data, 334*f3e7f55eSRobert Mustacchi Dwarf_Signed * cie_element_count, 335*f3e7f55eSRobert Mustacchi Dwarf_Fde ** fde_data, 336*f3e7f55eSRobert Mustacchi Dwarf_Signed * fde_element_count, 337*f3e7f55eSRobert Mustacchi Dwarf_Small * section_ptr, 338*f3e7f55eSRobert Mustacchi Dwarf_Unsigned section_index, 339*f3e7f55eSRobert Mustacchi Dwarf_Unsigned section_length, 340*f3e7f55eSRobert Mustacchi Dwarf_Unsigned cie_id_value, 341*f3e7f55eSRobert Mustacchi int use_gnu_cie_calc, /* If non-zero, 342*f3e7f55eSRobert Mustacchi this is gcc eh_frame. */ 343*f3e7f55eSRobert Mustacchi Dwarf_Error * error); 344*f3e7f55eSRobert Mustacchi 345*f3e7f55eSRobert Mustacchi enum Dwarf_augmentation_type 346*f3e7f55eSRobert Mustacchi _dwarf_get_augmentation_type(Dwarf_Debug dbg, 347*f3e7f55eSRobert Mustacchi Dwarf_Small *augmentation_string, 348*f3e7f55eSRobert Mustacchi int is_gcc_eh_frame); 349*f3e7f55eSRobert Mustacchi 350*f3e7f55eSRobert Mustacchi Dwarf_Unsigned _dwarf_get_return_address_reg(Dwarf_Small *frame_ptr, 351*f3e7f55eSRobert Mustacchi int version, 352*f3e7f55eSRobert Mustacchi unsigned long *size); 353*f3e7f55eSRobert Mustacchi 354*f3e7f55eSRobert Mustacchi /* Temporary recording of crucial cie/fde prefix data. 355*f3e7f55eSRobert Mustacchi * Vastly simplifies some argument lists. 356*f3e7f55eSRobert Mustacchi */ 357*f3e7f55eSRobert Mustacchi struct cie_fde_prefix_s { 358*f3e7f55eSRobert Mustacchi /* cf_start_addr is a pointer to the first byte of this fde/cie 359*f3e7f55eSRobert Mustacchi we are reading now. */ 360*f3e7f55eSRobert Mustacchi Dwarf_Small * cf_start_addr; 361*f3e7f55eSRobert Mustacchi Dwarf_Small * cf_addr_after_prefix; 362*f3e7f55eSRobert Mustacchi Dwarf_Unsigned cf_length; 363*f3e7f55eSRobert Mustacchi int cf_local_length_size; 364*f3e7f55eSRobert Mustacchi int cf_local_extension_size; 365*f3e7f55eSRobert Mustacchi Dwarf_Unsigned cf_cie_id; 366*f3e7f55eSRobert Mustacchi Dwarf_Small * cf_cie_id_addr; /* used for eh_frame calculations. */ 367*f3e7f55eSRobert Mustacchi 368*f3e7f55eSRobert Mustacchi /* Simplifies passing around these values to create fde having 369*f3e7f55eSRobert Mustacchi these here. */ 370*f3e7f55eSRobert Mustacchi /* cf_section_ptr is a pointer to the first byte 371*f3e7f55eSRobert Mustacchi of the object section the prefix is read from. */ 372*f3e7f55eSRobert Mustacchi Dwarf_Small * cf_section_ptr; 373*f3e7f55eSRobert Mustacchi Dwarf_Unsigned cf_section_index; 374*f3e7f55eSRobert Mustacchi Dwarf_Unsigned cf_section_length; 375*f3e7f55eSRobert Mustacchi }; 376*f3e7f55eSRobert Mustacchi 377*f3e7f55eSRobert Mustacchi int 378*f3e7f55eSRobert Mustacchi _dwarf_exec_frame_instr(Dwarf_Bool make_instr, 379*f3e7f55eSRobert Mustacchi Dwarf_Frame_Op ** ret_frame_instr, 380*f3e7f55eSRobert Mustacchi Dwarf_Bool search_pc, 381*f3e7f55eSRobert Mustacchi Dwarf_Addr search_pc_val, 382*f3e7f55eSRobert Mustacchi Dwarf_Addr initial_loc, 383*f3e7f55eSRobert Mustacchi Dwarf_Small * start_instr_ptr, 384*f3e7f55eSRobert Mustacchi Dwarf_Small * final_instr_ptr, 385*f3e7f55eSRobert Mustacchi Dwarf_Frame table, 386*f3e7f55eSRobert Mustacchi Dwarf_Cie cie, 387*f3e7f55eSRobert Mustacchi Dwarf_Debug dbg, 388*f3e7f55eSRobert Mustacchi Dwarf_Half reg_num_of_cfa, 389*f3e7f55eSRobert Mustacchi Dwarf_Sword * returned_count, 390*f3e7f55eSRobert Mustacchi int *returned_error); 391*f3e7f55eSRobert Mustacchi 392*f3e7f55eSRobert Mustacchi 393*f3e7f55eSRobert Mustacchi int dwarf_read_cie_fde_prefix(Dwarf_Debug dbg, 394*f3e7f55eSRobert Mustacchi Dwarf_Small *frame_ptr_in, 395*f3e7f55eSRobert Mustacchi Dwarf_Small *section_ptr_in, 396*f3e7f55eSRobert Mustacchi Dwarf_Unsigned section_index_in, 397*f3e7f55eSRobert Mustacchi Dwarf_Unsigned section_length_in, 398*f3e7f55eSRobert Mustacchi struct cie_fde_prefix_s *prefix_out, 399*f3e7f55eSRobert Mustacchi Dwarf_Error *error); 400*f3e7f55eSRobert Mustacchi 401*f3e7f55eSRobert Mustacchi int dwarf_create_fde_from_after_start(Dwarf_Debug dbg, 402*f3e7f55eSRobert Mustacchi struct cie_fde_prefix_s * prefix, 403*f3e7f55eSRobert Mustacchi Dwarf_Small *section_pointer, 404*f3e7f55eSRobert Mustacchi Dwarf_Small *frame_ptr, 405*f3e7f55eSRobert Mustacchi int use_gnu_cie_calc, 406*f3e7f55eSRobert Mustacchi Dwarf_Cie cie_ptr_in, 407*f3e7f55eSRobert Mustacchi Dwarf_Fde *fde_ptr_out, 408*f3e7f55eSRobert Mustacchi Dwarf_Error *error); 409*f3e7f55eSRobert Mustacchi 410*f3e7f55eSRobert Mustacchi int dwarf_create_cie_from_after_start(Dwarf_Debug dbg, 411*f3e7f55eSRobert Mustacchi struct cie_fde_prefix_s *prefix, 412*f3e7f55eSRobert Mustacchi Dwarf_Small* section_pointer, 413*f3e7f55eSRobert Mustacchi Dwarf_Small* frame_ptr, 414*f3e7f55eSRobert Mustacchi Dwarf_Unsigned cie_count, 415*f3e7f55eSRobert Mustacchi int use_gnu_cie_calc, 416*f3e7f55eSRobert Mustacchi Dwarf_Cie *cie_ptr_out, 417*f3e7f55eSRobert Mustacchi Dwarf_Error *error); 418*f3e7f55eSRobert Mustacchi 419*f3e7f55eSRobert Mustacchi 420*f3e7f55eSRobert Mustacchi int _dwarf_frame_constructor(Dwarf_Debug dbg,void * ); 421*f3e7f55eSRobert Mustacchi void _dwarf_frame_destructor (void *); 422