17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7257d1b4Sraf * Common Development and Distribution License (the "License"). 6*7257d1b4Sraf * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*7257d1b4Sraf 227c478bd9Sstevel@tonic-gate /* 23*7257d1b4Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * interface used by unwind support to query frame descriptor info 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifndef _LIBCRUN_ 34*7257d1b4Sraf #include "lint.h" 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate #include <sys/types.h> 377c478bd9Sstevel@tonic-gate #include "stack_unwind.h" 387c478bd9Sstevel@tonic-gate #include "unwind_context.h" 397c478bd9Sstevel@tonic-gate #include "reg_num.h" 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate enum CFA_ops { 427c478bd9Sstevel@tonic-gate DW_CFA_nop = 0x00, 437c478bd9Sstevel@tonic-gate DW_CFA_set_loc = 0x01, 447c478bd9Sstevel@tonic-gate DW_CFA_advance_loc1 = 0x02, 457c478bd9Sstevel@tonic-gate DW_CFA_advance_loc2 = 0x03, 467c478bd9Sstevel@tonic-gate DW_CFA_advance_loc4 = 0x04, 477c478bd9Sstevel@tonic-gate DW_CFA_offset_extended = 0x05, 487c478bd9Sstevel@tonic-gate DW_CFA_restore_extended = 0x06, 497c478bd9Sstevel@tonic-gate DW_CFA_undefined = 0x07, 507c478bd9Sstevel@tonic-gate DW_CFA_same_value = 0x08, 517c478bd9Sstevel@tonic-gate DW_CFA_register = 0x09, 527c478bd9Sstevel@tonic-gate DW_CFA_remember_state = 0x0a, 537c478bd9Sstevel@tonic-gate DW_CFA_restore_state = 0x0b, 547c478bd9Sstevel@tonic-gate DW_CFA_def_cfa = 0x0c, 557c478bd9Sstevel@tonic-gate DW_CFA_def_cfa_register = 0x0d, 567c478bd9Sstevel@tonic-gate DW_CFA_def_cfa_offset = 0x0e, 577c478bd9Sstevel@tonic-gate DW_CFA_def_cfa_expression = 0x0f, 587c478bd9Sstevel@tonic-gate DW_CFA_expression = 0x10, 597c478bd9Sstevel@tonic-gate DW_CFA_offset_extended_sf = 0x11, 607c478bd9Sstevel@tonic-gate DW_CFA_def_cfa_sf = 0x12, 617c478bd9Sstevel@tonic-gate DW_CFA_def_cfa_offset_sf = 0x13, 627c478bd9Sstevel@tonic-gate /* skip 9 values */ 637c478bd9Sstevel@tonic-gate DW_CFA_SUNW_advance_loc = 0x1d, 647c478bd9Sstevel@tonic-gate DW_CFA_SUNW_offset = 0x1e, 657c478bd9Sstevel@tonic-gate DW_CFA_SUNW_restore = 0x1f, 667c478bd9Sstevel@tonic-gate DW_CFA_advance_loc = 0x40, 677c478bd9Sstevel@tonic-gate DW_CFA_offset = 0x80, 687c478bd9Sstevel@tonic-gate DW_CFA_restore = 0xc0 697c478bd9Sstevel@tonic-gate }; 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate struct operation_desc { 727c478bd9Sstevel@tonic-gate enum operand_desc op1; 737c478bd9Sstevel@tonic-gate enum operand_desc op2; 747c478bd9Sstevel@tonic-gate }; 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate struct operation_desc cfa_operations[] = { 777c478bd9Sstevel@tonic-gate {NO_OPR, NO_OPR}, /* DW_CFA_nop */ 787c478bd9Sstevel@tonic-gate {ADDR, NO_OPR}, /* DW_CFA_set_loc - address */ 797c478bd9Sstevel@tonic-gate {UNUM8, NO_OPR}, /* DW_CFA_advance_loc1 - delta */ 807c478bd9Sstevel@tonic-gate {UNUM16, NO_OPR}, /* DW_CFA_advance_loc2 - delta */ 817c478bd9Sstevel@tonic-gate {UNUM32, NO_OPR}, /* DW_CFA_advance_loc4 - delta */ 827c478bd9Sstevel@tonic-gate {ULEB128, ULEB128_FAC}, /* DW_CFA_offset_extended - reg, */ 837c478bd9Sstevel@tonic-gate /* data factored offset */ 847c478bd9Sstevel@tonic-gate {ULEB128, NO_OPR}, /* DW_CFA_restore_extended - register */ 857c478bd9Sstevel@tonic-gate {ULEB128, NO_OPR}, /* DW_CFA_undefined - register */ 867c478bd9Sstevel@tonic-gate {ULEB128, NO_OPR}, /* DW_CFA_same_value - register */ 877c478bd9Sstevel@tonic-gate {ULEB128, ULEB128_SREG}, /* DW_CFA_register - register, register */ 887c478bd9Sstevel@tonic-gate {NO_OPR, NO_OPR}, /* DW_CFA_remember_state */ 897c478bd9Sstevel@tonic-gate {NO_OPR, NO_OPR}, /* DW_CFA_restore_state */ 907c478bd9Sstevel@tonic-gate {ULEB128_SREG, ULEB128}, /* DW_CFA_def_cfa - register, offset */ 917c478bd9Sstevel@tonic-gate {ULEB128_SREG, NO_OPR}, /* DW_CFA_def_cfa_register - register */ 927c478bd9Sstevel@tonic-gate {ULEB128, NO_OPR}, /* DW_CFA_def_cfa_offset - offset */ 937c478bd9Sstevel@tonic-gate {BLOCK, NO_OPR}, /* DW_CFA_def_cfa_expression - expression */ 947c478bd9Sstevel@tonic-gate {ULEB128, BLOCK}, /* DW_CFA_expression - reg, expression */ 957c478bd9Sstevel@tonic-gate {ULEB128, SLEB128_FAC}, /* DW_CFA_offset_extended_sf - reg, */ 967c478bd9Sstevel@tonic-gate /* data factored offset */ 977c478bd9Sstevel@tonic-gate {ULEB128_SREG, SLEB128_FAC}, /* DW_CFA_def_cfa_sf - reg, */ 987c478bd9Sstevel@tonic-gate /* data factored offset */ 997c478bd9Sstevel@tonic-gate {SLEB128_FAC, NO_OPR}, /* DW_CFA_def_cfa_offset_sf - */ 1007c478bd9Sstevel@tonic-gate /* data fctored offset */ 1017c478bd9Sstevel@tonic-gate {NO_OPR, NO_OPR}, 1027c478bd9Sstevel@tonic-gate {NO_OPR, NO_OPR}, 1037c478bd9Sstevel@tonic-gate {NO_OPR, NO_OPR}, 1047c478bd9Sstevel@tonic-gate {NO_OPR, NO_OPR}, 1057c478bd9Sstevel@tonic-gate {NO_OPR, NO_OPR}, 1067c478bd9Sstevel@tonic-gate {NO_OPR, NO_OPR}, 1077c478bd9Sstevel@tonic-gate {NO_OPR, NO_OPR}, 1087c478bd9Sstevel@tonic-gate {NO_OPR, NO_OPR}, 1097c478bd9Sstevel@tonic-gate {NO_OPR, NO_OPR}, 1107c478bd9Sstevel@tonic-gate {UNUM6_CFAC, NO_OPR}, /* DW_CFA_SUNW_advance_loc - */ 1117c478bd9Sstevel@tonic-gate /* code factored delta */ 1127c478bd9Sstevel@tonic-gate {UNUM6, ULEB128_FAC}, /* DW_CFA_SUNW_offset - reg */ 1137c478bd9Sstevel@tonic-gate /* data factored offset */ 1147c478bd9Sstevel@tonic-gate {UNUM6, NO_OPR} /* DW_CFA_SUNW_restore */ 1157c478bd9Sstevel@tonic-gate }; 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate uint64_t interpret_ops(void *data, void *data_end, 1187c478bd9Sstevel@tonic-gate ptrdiff_t reloc, uint64_t current_loc, uint64_t pc, 1197c478bd9Sstevel@tonic-gate struct register_state f_state[], 1207c478bd9Sstevel@tonic-gate struct register_state f_start_state[], 1217c478bd9Sstevel@tonic-gate int daf, int caf, int enc); 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate /* 1247c478bd9Sstevel@tonic-gate * The entry-point state of old_ctx defines the current 1257c478bd9Sstevel@tonic-gate * suspended state of the caller (in new_ctx). If the old info 1267c478bd9Sstevel@tonic-gate * will not be refered to again, old_ctx == new_ctx is OK 1277c478bd9Sstevel@tonic-gate */ 1287c478bd9Sstevel@tonic-gate void 1297c478bd9Sstevel@tonic-gate _Unw_Propagate_Registers(struct _Unwind_Context *old_ctx, 1307c478bd9Sstevel@tonic-gate struct _Unwind_Context *new_ctx) 1317c478bd9Sstevel@tonic-gate { 1327c478bd9Sstevel@tonic-gate new_ctx->current_regs[SP_RSP] = old_ctx->cfa; 1337c478bd9Sstevel@tonic-gate new_ctx->pc = old_ctx->ra; 1347c478bd9Sstevel@tonic-gate new_ctx->current_regs[FP_RBP] = old_ctx->entry_regs[FP_RBP]; 1357c478bd9Sstevel@tonic-gate new_ctx->current_regs[GPR_RBX] = old_ctx->entry_regs[GPR_RBX]; 1367c478bd9Sstevel@tonic-gate new_ctx->current_regs[EIR_R12] = old_ctx->entry_regs[EIR_R12]; 1377c478bd9Sstevel@tonic-gate new_ctx->current_regs[EIR_R13] = old_ctx->entry_regs[EIR_R13]; 1387c478bd9Sstevel@tonic-gate new_ctx->current_regs[EIR_R14] = old_ctx->entry_regs[EIR_R14]; 1397c478bd9Sstevel@tonic-gate new_ctx->current_regs[EIR_R15] = old_ctx->entry_regs[EIR_R15]; 1407c478bd9Sstevel@tonic-gate } 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate void 1437c478bd9Sstevel@tonic-gate fix_cfa(struct _Unwind_Context *ctx, struct register_state *rs) 1447c478bd9Sstevel@tonic-gate { 1457c478bd9Sstevel@tonic-gate switch (rs[CF_ADDR].rule) { 1467c478bd9Sstevel@tonic-gate default: 147*7257d1b4Sraf ctx->cfa = 0; 1487c478bd9Sstevel@tonic-gate break; 1497c478bd9Sstevel@tonic-gate case register_rule: /* CFA = offset + source_reg */ 1507c478bd9Sstevel@tonic-gate ctx->cfa = (ctx->current_regs)[rs[CF_ADDR].source_reg] + 151*7257d1b4Sraf rs[CF_ADDR].offset; 1527c478bd9Sstevel@tonic-gate break; 1537c478bd9Sstevel@tonic-gate case constant_rule: /* CFA = offset */ 1547c478bd9Sstevel@tonic-gate ctx->cfa = rs[CF_ADDR].offset; 1557c478bd9Sstevel@tonic-gate break; 1567c478bd9Sstevel@tonic-gate case indirect_rule: /* CFA = *(offset + source_reg) */ 1577c478bd9Sstevel@tonic-gate ctx->cfa = *(uint64_t *) 158*7257d1b4Sraf (ctx->current_regs[rs[CF_ADDR].source_reg] + 159*7257d1b4Sraf rs[CF_ADDR].offset); 1607c478bd9Sstevel@tonic-gate break; 1617c478bd9Sstevel@tonic-gate } 1627c478bd9Sstevel@tonic-gate ctx->entry_regs[SP_RSP] = ctx->cfa; 1637c478bd9Sstevel@tonic-gate } 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate void 1667c478bd9Sstevel@tonic-gate fix_ra(struct _Unwind_Context *ctx, struct register_state *rs) 1677c478bd9Sstevel@tonic-gate { 1687c478bd9Sstevel@tonic-gate switch (rs[RET_ADD].rule) { 1697c478bd9Sstevel@tonic-gate case undefined_rule: 1707c478bd9Sstevel@tonic-gate default: 171*7257d1b4Sraf ctx->ra = 0; 1727c478bd9Sstevel@tonic-gate break; 1737c478bd9Sstevel@tonic-gate case offset_rule: /* RA = *(offset + CFA) */ 1747c478bd9Sstevel@tonic-gate ctx->ra = *(uint64_t *)(ctx->cfa + rs[RET_ADD].offset); 1757c478bd9Sstevel@tonic-gate break; 1767c478bd9Sstevel@tonic-gate case register_rule: /* RA = offset + source_reg */ 1777c478bd9Sstevel@tonic-gate ctx->ra = ctx->current_regs[rs[RET_ADD].source_reg] + 178*7257d1b4Sraf rs[RET_ADD].offset; 1797c478bd9Sstevel@tonic-gate break; 1807c478bd9Sstevel@tonic-gate case indirect_rule: /* RA = *(offset + source_reg) */ 1817c478bd9Sstevel@tonic-gate ctx->ra = *(uint64_t *) 182*7257d1b4Sraf (ctx->current_regs[rs[RET_ADD].source_reg] + 183*7257d1b4Sraf rs[RET_ADD].offset); 1847c478bd9Sstevel@tonic-gate break; 1857c478bd9Sstevel@tonic-gate } 1867c478bd9Sstevel@tonic-gate } 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate void 1897c478bd9Sstevel@tonic-gate fix_reg(struct _Unwind_Context *ctx, struct register_state *rs, int index) 1907c478bd9Sstevel@tonic-gate { 1917c478bd9Sstevel@tonic-gate switch (rs[index].rule) { 1927c478bd9Sstevel@tonic-gate default: 1937c478bd9Sstevel@tonic-gate ctx->entry_regs[index] = ctx->current_regs[index]; 1947c478bd9Sstevel@tonic-gate break; 1957c478bd9Sstevel@tonic-gate case offset_rule: /* target_reg = *(offset + CFA) */ 1967c478bd9Sstevel@tonic-gate ctx->entry_regs[index] = *(uint64_t *) 197*7257d1b4Sraf (ctx->cfa + rs[index].offset); 1987c478bd9Sstevel@tonic-gate break; 1997c478bd9Sstevel@tonic-gate case is_offset_rule: /* target_reg = offset + CFA */ 2007c478bd9Sstevel@tonic-gate ctx->entry_regs[index] = ctx->cfa + rs[index].offset; 2017c478bd9Sstevel@tonic-gate break; 2027c478bd9Sstevel@tonic-gate case register_rule: /* target_reg = offset + source_reg */ 2037c478bd9Sstevel@tonic-gate ctx->entry_regs[index] = 204*7257d1b4Sraf ctx->current_regs[rs[index].source_reg] + 205*7257d1b4Sraf rs[index].offset; 2067c478bd9Sstevel@tonic-gate break; 2077c478bd9Sstevel@tonic-gate case constant_rule: /* target_reg = offset */ 2087c478bd9Sstevel@tonic-gate ctx->entry_regs[index] = rs[index].offset; 2097c478bd9Sstevel@tonic-gate break; 2107c478bd9Sstevel@tonic-gate case indirect_rule: /* target_reg = *(offset + source_reg) */ 2117c478bd9Sstevel@tonic-gate ctx->entry_regs[index] = *(uint64_t *) 212*7257d1b4Sraf (ctx->current_regs[rs[index].source_reg] + 213*7257d1b4Sraf rs[index].offset); 2147c478bd9Sstevel@tonic-gate break; 2157c478bd9Sstevel@tonic-gate } 2167c478bd9Sstevel@tonic-gate } 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate /* 2207c478bd9Sstevel@tonic-gate * Input: f->{cie_ops, cie_ops_end, fde_ops, fde_ops_end} 2217c478bd9Sstevel@tonic-gate * + location of DWARF opcodes 2227c478bd9Sstevel@tonic-gate * ctx->{current_regs, pc} 2237c478bd9Sstevel@tonic-gate * + register values and pc at point of suspension 2247c478bd9Sstevel@tonic-gate * Output: ctx->{entry_regs, cfa, ra} 2257c478bd9Sstevel@tonic-gate * + register values when function was entered 2267c478bd9Sstevel@tonic-gate * + Cannonical Frame Address 2277c478bd9Sstevel@tonic-gate * + return address 2287c478bd9Sstevel@tonic-gate */ 2297c478bd9Sstevel@tonic-gate uint64_t 2307c478bd9Sstevel@tonic-gate _Unw_Rollback_Registers(struct eh_frame_fields *f, 2317c478bd9Sstevel@tonic-gate struct _Unwind_Context *ctx) 2327c478bd9Sstevel@tonic-gate { 2337c478bd9Sstevel@tonic-gate /* GPRs, RET_ADD, and CF_ADDR */ 2347c478bd9Sstevel@tonic-gate struct register_state func_state[18]; 2357c478bd9Sstevel@tonic-gate struct register_state func_start_state[18]; 2367c478bd9Sstevel@tonic-gate struct register_state nop = { 0, undefined_rule, 0 }; 2377c478bd9Sstevel@tonic-gate int i; 2387c478bd9Sstevel@tonic-gate uint64_t first_pc; 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate if (f == 0) { 2417c478bd9Sstevel@tonic-gate /* 2427c478bd9Sstevel@tonic-gate * When no FDE we assume all routines have a frame pointer 2437c478bd9Sstevel@tonic-gate * and pass back existing callee saves registers 2447c478bd9Sstevel@tonic-gate */ 2457c478bd9Sstevel@tonic-gate if (ctx->current_regs[FP_RBP] < ctx->current_regs[SP_RSP]) { 2467c478bd9Sstevel@tonic-gate ctx->cfa = 0; 2477c478bd9Sstevel@tonic-gate ctx->ra = 0; 2487c478bd9Sstevel@tonic-gate ctx->pc = 0; 2497c478bd9Sstevel@tonic-gate return (0); 2507c478bd9Sstevel@tonic-gate } 2517c478bd9Sstevel@tonic-gate ctx->entry_regs[FP_RBP] = ((uint64_t *) 252*7257d1b4Sraf (ctx->current_regs[FP_RBP]))[0]; 2537c478bd9Sstevel@tonic-gate ctx->cfa = ctx->current_regs[FP_RBP] + 16; 2547c478bd9Sstevel@tonic-gate ctx->entry_regs[SP_RSP] = ctx->cfa; 2557c478bd9Sstevel@tonic-gate ctx->entry_regs[GPR_RBX] = ctx->current_regs[GPR_RBX]; 2567c478bd9Sstevel@tonic-gate ctx->entry_regs[EIR_R12] = ctx->current_regs[EIR_R12]; 2577c478bd9Sstevel@tonic-gate ctx->entry_regs[EIR_R13] = ctx->current_regs[EIR_R13]; 2587c478bd9Sstevel@tonic-gate ctx->entry_regs[EIR_R14] = ctx->current_regs[EIR_R14]; 2597c478bd9Sstevel@tonic-gate ctx->entry_regs[EIR_R15] = ctx->current_regs[EIR_R15]; 2607c478bd9Sstevel@tonic-gate ctx->ra = ((uint64_t *)ctx->cfa)[-1]; 2617c478bd9Sstevel@tonic-gate return (ctx->cfa); 2627c478bd9Sstevel@tonic-gate } 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate for (i = 0; i < 18; i++) 2657c478bd9Sstevel@tonic-gate func_start_state[i] = nop; 2667c478bd9Sstevel@tonic-gate first_pc = interpret_ops(f->cie_ops, f->cie_ops_end, 267*7257d1b4Sraf f->cie_reloc, ctx->func, ctx->pc, func_start_state, 0, 268*7257d1b4Sraf f->data_align, f->code_align, f->code_enc); 2697c478bd9Sstevel@tonic-gate for (i = 0; i < 18; i++) 2707c478bd9Sstevel@tonic-gate func_state[i] = func_start_state[i]; 2717c478bd9Sstevel@tonic-gate (void) interpret_ops(f->fde_ops, f->fde_ops_end, 272*7257d1b4Sraf f->fde_reloc, first_pc, ctx->pc, func_state, func_start_state, 273*7257d1b4Sraf f->data_align, f->code_align, f->code_enc); 2747c478bd9Sstevel@tonic-gate 2757c478bd9Sstevel@tonic-gate fix_cfa(ctx, func_state); 2767c478bd9Sstevel@tonic-gate if (ctx->cfa < ctx->current_regs[SP_RSP]) { 2777c478bd9Sstevel@tonic-gate ctx->cfa = 0; 2787c478bd9Sstevel@tonic-gate ctx->ra = 0; 2797c478bd9Sstevel@tonic-gate ctx->pc = 0; 2807c478bd9Sstevel@tonic-gate return (0); 2817c478bd9Sstevel@tonic-gate } 2827c478bd9Sstevel@tonic-gate fix_ra(ctx, func_state); 2837c478bd9Sstevel@tonic-gate fix_reg(ctx, func_state, GPR_RBX); 2847c478bd9Sstevel@tonic-gate fix_reg(ctx, func_state, FP_RBP); 2857c478bd9Sstevel@tonic-gate fix_reg(ctx, func_state, EIR_R12); 2867c478bd9Sstevel@tonic-gate fix_reg(ctx, func_state, EIR_R13); 2877c478bd9Sstevel@tonic-gate fix_reg(ctx, func_state, EIR_R14); 2887c478bd9Sstevel@tonic-gate fix_reg(ctx, func_state, EIR_R15); 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate return (ctx->cfa); 2917c478bd9Sstevel@tonic-gate } 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate /* 2947c478bd9Sstevel@tonic-gate * remap two-bit opcodes into a separate range or grab eight-bit opcode 2957c478bd9Sstevel@tonic-gate * and advance pointer past it. 2967c478bd9Sstevel@tonic-gate */ 2977c478bd9Sstevel@tonic-gate static enum CFA_ops 2987c478bd9Sstevel@tonic-gate separate_op(void **pp) 2997c478bd9Sstevel@tonic-gate { 3007c478bd9Sstevel@tonic-gate uint8_t c = **((uint8_t **)pp); 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate if (c & 0xc0) { 3037c478bd9Sstevel@tonic-gate switch (c & 0xc0) { 3047c478bd9Sstevel@tonic-gate case DW_CFA_advance_loc: 3057c478bd9Sstevel@tonic-gate return (DW_CFA_SUNW_advance_loc); 3067c478bd9Sstevel@tonic-gate case DW_CFA_offset: 3077c478bd9Sstevel@tonic-gate return (DW_CFA_SUNW_offset); 3087c478bd9Sstevel@tonic-gate case DW_CFA_restore: 3097c478bd9Sstevel@tonic-gate return (DW_CFA_SUNW_restore); 3107c478bd9Sstevel@tonic-gate } 3117c478bd9Sstevel@tonic-gate } else { 3127c478bd9Sstevel@tonic-gate *pp = (void *)((*(intptr_t *)pp) + 1); 3137c478bd9Sstevel@tonic-gate } 3147c478bd9Sstevel@tonic-gate return (c); 3157c478bd9Sstevel@tonic-gate } 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate static uint64_t 3187c478bd9Sstevel@tonic-gate extractuleb(void **datap) 3197c478bd9Sstevel@tonic-gate { 3207c478bd9Sstevel@tonic-gate uint8_t *data = *(uint8_t **)datap; 3217c478bd9Sstevel@tonic-gate uint64_t res = 0; 3227c478bd9Sstevel@tonic-gate int more = 1; 3237c478bd9Sstevel@tonic-gate int shift = 0; 3247c478bd9Sstevel@tonic-gate int val; 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate while (more) { 3277c478bd9Sstevel@tonic-gate val = (*data) & 0x7f; 3287c478bd9Sstevel@tonic-gate more = ((*data++) & 0x80) >> 7; 3297c478bd9Sstevel@tonic-gate res = res | val << shift; 3307c478bd9Sstevel@tonic-gate shift += 7; 3317c478bd9Sstevel@tonic-gate } 3327c478bd9Sstevel@tonic-gate *datap = (void *)data; 3337c478bd9Sstevel@tonic-gate return (res); 3347c478bd9Sstevel@tonic-gate } 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate static uint64_t 3377c478bd9Sstevel@tonic-gate extractsleb(void** datap) 3387c478bd9Sstevel@tonic-gate { 3397c478bd9Sstevel@tonic-gate uint8_t *data = *datap; 3407c478bd9Sstevel@tonic-gate int64_t res = 0; 3417c478bd9Sstevel@tonic-gate int more = 1; 3427c478bd9Sstevel@tonic-gate int shift = 0; 3437c478bd9Sstevel@tonic-gate unsigned int val; 3447c478bd9Sstevel@tonic-gate 3457c478bd9Sstevel@tonic-gate while (more) { 3467c478bd9Sstevel@tonic-gate val = (*data) & 0x7f; 3477c478bd9Sstevel@tonic-gate more = ((*data++) & 0x80) >> 7; 3487c478bd9Sstevel@tonic-gate res = res | val<< shift; 3497c478bd9Sstevel@tonic-gate shift += 7; 3507c478bd9Sstevel@tonic-gate } 3517c478bd9Sstevel@tonic-gate *datap = (void*) data; 3527c478bd9Sstevel@tonic-gate res = (res << (64 - shift)) >> (64 - shift); 3537c478bd9Sstevel@tonic-gate return (res); 3547c478bd9Sstevel@tonic-gate } 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate static uint64_t get_encoded_val(void **datap, ptrdiff_t reloc, int enc); 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate /* 3597c478bd9Sstevel@tonic-gate * do all field extractions needed for CFA operands and encoded FDE 3607c478bd9Sstevel@tonic-gate * fields 3617c478bd9Sstevel@tonic-gate */ 3627c478bd9Sstevel@tonic-gate uint64_t 3637c478bd9Sstevel@tonic-gate _Unw_get_val(void **datap, ptrdiff_t reloc, 3647c478bd9Sstevel@tonic-gate enum operand_desc opr, int daf, int caf, int enc) 3657c478bd9Sstevel@tonic-gate { 3667c478bd9Sstevel@tonic-gate intptr_t data = (intptr_t)*datap; 3677c478bd9Sstevel@tonic-gate uint64_t res; 3687c478bd9Sstevel@tonic-gate char *dp, *rp; 3697c478bd9Sstevel@tonic-gate 3707c478bd9Sstevel@tonic-gate switch (opr) { 3717c478bd9Sstevel@tonic-gate case NO_OPR: 3727c478bd9Sstevel@tonic-gate res = 0; 3737c478bd9Sstevel@tonic-gate break; 3747c478bd9Sstevel@tonic-gate case ULEB128_FAC: 3757c478bd9Sstevel@tonic-gate return (daf * extractuleb(datap)); 3767c478bd9Sstevel@tonic-gate break; 3777c478bd9Sstevel@tonic-gate case ULEB128: 3787c478bd9Sstevel@tonic-gate return (extractuleb(datap)); 3797c478bd9Sstevel@tonic-gate break; 3807c478bd9Sstevel@tonic-gate case ULEB128_SREG: 3817c478bd9Sstevel@tonic-gate res = (uint64_t)(*((uint8_t *)data)); 3827c478bd9Sstevel@tonic-gate data += 1; 3837c478bd9Sstevel@tonic-gate switch (res) { 3847c478bd9Sstevel@tonic-gate /* verify that register is one which is being tracked */ 3857c478bd9Sstevel@tonic-gate case GPR_RBX: 3867c478bd9Sstevel@tonic-gate case FP_RBP: 3877c478bd9Sstevel@tonic-gate case SP_RSP: 3887c478bd9Sstevel@tonic-gate case EIR_R12: 3897c478bd9Sstevel@tonic-gate case EIR_R13: 3907c478bd9Sstevel@tonic-gate case EIR_R14: 3917c478bd9Sstevel@tonic-gate case EIR_R15: 3927c478bd9Sstevel@tonic-gate break; 3937c478bd9Sstevel@tonic-gate default: 3947c478bd9Sstevel@tonic-gate res = BAD_REG; 3957c478bd9Sstevel@tonic-gate break; 3967c478bd9Sstevel@tonic-gate } 3977c478bd9Sstevel@tonic-gate break; 3987c478bd9Sstevel@tonic-gate case UNUM6: 3997c478bd9Sstevel@tonic-gate res = (uint64_t)(0x3f & *((uint8_t *)data)); 4007c478bd9Sstevel@tonic-gate data += 1; 4017c478bd9Sstevel@tonic-gate break; 4027c478bd9Sstevel@tonic-gate case UNUM8: 4037c478bd9Sstevel@tonic-gate res = (uint64_t)(*((uint8_t *)data)); 4047c478bd9Sstevel@tonic-gate data += 1; 4057c478bd9Sstevel@tonic-gate break; 4067c478bd9Sstevel@tonic-gate case UNUM16: 4077c478bd9Sstevel@tonic-gate res = (uint64_t)(*((uint16_t *)data)); 4087c478bd9Sstevel@tonic-gate data += 2; 4097c478bd9Sstevel@tonic-gate break; 4107c478bd9Sstevel@tonic-gate case UNUM32: 4117c478bd9Sstevel@tonic-gate res = (uint64_t)(*((uint32_t *)data)); 4127c478bd9Sstevel@tonic-gate data += 4; 4137c478bd9Sstevel@tonic-gate break; 4147c478bd9Sstevel@tonic-gate case UNUM6_CFAC: 4157c478bd9Sstevel@tonic-gate res = caf * (uint64_t)(0x3f & *((uint8_t *)data)); 4167c478bd9Sstevel@tonic-gate data += 1; 4177c478bd9Sstevel@tonic-gate break; 4187c478bd9Sstevel@tonic-gate case UNUM8_CFAC: 4197c478bd9Sstevel@tonic-gate res = caf * (uint64_t)(*((uint8_t *)data)); 4207c478bd9Sstevel@tonic-gate data += 1; 4217c478bd9Sstevel@tonic-gate break; 4227c478bd9Sstevel@tonic-gate case UNUM16_CFAC: 4237c478bd9Sstevel@tonic-gate res = caf * (uint64_t)(*((uint16_t *)data)); 4247c478bd9Sstevel@tonic-gate data += 2; 4257c478bd9Sstevel@tonic-gate break; 4267c478bd9Sstevel@tonic-gate case UNUM32_CFAC: 4277c478bd9Sstevel@tonic-gate res = caf * (uint64_t)(*((uint32_t *)data)); 4287c478bd9Sstevel@tonic-gate data += 4; 4297c478bd9Sstevel@tonic-gate break; 4307c478bd9Sstevel@tonic-gate case UNUM64: 4317c478bd9Sstevel@tonic-gate res = (uint64_t)(*((uint64_t *)data)); 4327c478bd9Sstevel@tonic-gate data += 8; 4337c478bd9Sstevel@tonic-gate break; 4347c478bd9Sstevel@tonic-gate case SNUM8: 4357c478bd9Sstevel@tonic-gate res = (uint64_t)(int64_t)(*((int8_t *)data)); 4367c478bd9Sstevel@tonic-gate data += 1; 4377c478bd9Sstevel@tonic-gate break; 4387c478bd9Sstevel@tonic-gate case SNUM16: 4397c478bd9Sstevel@tonic-gate res = (uint64_t)(int64_t)(*((int16_t *)data)); 4407c478bd9Sstevel@tonic-gate data += 2; 4417c478bd9Sstevel@tonic-gate break; 4427c478bd9Sstevel@tonic-gate case SNUM32: 4437c478bd9Sstevel@tonic-gate res = (uint64_t)(int64_t)(*((int32_t *)data)); 4447c478bd9Sstevel@tonic-gate data += 4; 4457c478bd9Sstevel@tonic-gate break; 4467c478bd9Sstevel@tonic-gate case SNUM64: 4477c478bd9Sstevel@tonic-gate res = (uint64_t)(*((int64_t *)data)); 4487c478bd9Sstevel@tonic-gate data += 8; 4497c478bd9Sstevel@tonic-gate break; 4507c478bd9Sstevel@tonic-gate case SLEB128_FAC: 4517c478bd9Sstevel@tonic-gate return (daf * extractsleb(datap)); 4527c478bd9Sstevel@tonic-gate break; 4537c478bd9Sstevel@tonic-gate case SLEB128: 4547c478bd9Sstevel@tonic-gate return (extractsleb(datap)); 4557c478bd9Sstevel@tonic-gate break; 4567c478bd9Sstevel@tonic-gate case ZTSTRING: 4577c478bd9Sstevel@tonic-gate /* max length of augmentation string is 4 */ 4587c478bd9Sstevel@tonic-gate rp = (char *)&res; 4597c478bd9Sstevel@tonic-gate dp = (char *)data; 4607c478bd9Sstevel@tonic-gate while (*rp++ = *dp++) 4617c478bd9Sstevel@tonic-gate ; 4627c478bd9Sstevel@tonic-gate data = (intptr_t)dp; 4637c478bd9Sstevel@tonic-gate break; 4647c478bd9Sstevel@tonic-gate case ADDR: 4657c478bd9Sstevel@tonic-gate return (get_encoded_val(datap, reloc, enc)); 4667c478bd9Sstevel@tonic-gate break; 4677c478bd9Sstevel@tonic-gate case SIZE: 4687c478bd9Sstevel@tonic-gate return (get_encoded_val(datap, reloc, enc & 0x7)); 4697c478bd9Sstevel@tonic-gate case BLOCK: 4707c478bd9Sstevel@tonic-gate res = 0; /* not implemented */ 4717c478bd9Sstevel@tonic-gate break; 4727c478bd9Sstevel@tonic-gate } 4737c478bd9Sstevel@tonic-gate *datap = (void*)data; 4747c478bd9Sstevel@tonic-gate return (res); 4757c478bd9Sstevel@tonic-gate } 4767c478bd9Sstevel@tonic-gate 4777c478bd9Sstevel@tonic-gate static uint64_t 4787c478bd9Sstevel@tonic-gate get_encoded_val(void **datap, ptrdiff_t reloc, int enc) 4797c478bd9Sstevel@tonic-gate { 4807c478bd9Sstevel@tonic-gate int val = enc & 0xf; 4817c478bd9Sstevel@tonic-gate int rel = (enc >> 4) & 0xf; 4827c478bd9Sstevel@tonic-gate intptr_t loc = ((intptr_t)*datap) + reloc; 4837c478bd9Sstevel@tonic-gate uint64_t res = 0; 4847c478bd9Sstevel@tonic-gate 4857c478bd9Sstevel@tonic-gate switch (val) { 4867c478bd9Sstevel@tonic-gate case 0x01: 4877c478bd9Sstevel@tonic-gate res = _Unw_get_val(datap, reloc, ULEB128, 1, 1, 0); 4887c478bd9Sstevel@tonic-gate break; 4897c478bd9Sstevel@tonic-gate case 0x2: 4907c478bd9Sstevel@tonic-gate res = _Unw_get_val(datap, reloc, UNUM16, 1, 1, 0); 4917c478bd9Sstevel@tonic-gate break; 4927c478bd9Sstevel@tonic-gate case 0x3: 4937c478bd9Sstevel@tonic-gate res = _Unw_get_val(datap, reloc, UNUM32, 1, 1, 0); 4947c478bd9Sstevel@tonic-gate break; 4957c478bd9Sstevel@tonic-gate case 0x04: 4967c478bd9Sstevel@tonic-gate res = _Unw_get_val(datap, reloc, UNUM64, 1, 1, 0); 4977c478bd9Sstevel@tonic-gate break; 4987c478bd9Sstevel@tonic-gate case 0x09: 4997c478bd9Sstevel@tonic-gate res = _Unw_get_val(datap, reloc, SLEB128, 1, 1, 0); 5007c478bd9Sstevel@tonic-gate break; 5017c478bd9Sstevel@tonic-gate case 0x0a: 5027c478bd9Sstevel@tonic-gate res = _Unw_get_val(datap, reloc, SNUM16, 1, 1, 0); 5037c478bd9Sstevel@tonic-gate break; 5047c478bd9Sstevel@tonic-gate case 0x0b: 5057c478bd9Sstevel@tonic-gate res = _Unw_get_val(datap, reloc, SNUM32, 1, 1, 0); 5067c478bd9Sstevel@tonic-gate break; 5077c478bd9Sstevel@tonic-gate case 0x0c: 5087c478bd9Sstevel@tonic-gate res = _Unw_get_val(datap, reloc, SNUM64, 1, 1, 0); 5097c478bd9Sstevel@tonic-gate break; 5107c478bd9Sstevel@tonic-gate } 5117c478bd9Sstevel@tonic-gate 5127c478bd9Sstevel@tonic-gate switch (rel) { 5137c478bd9Sstevel@tonic-gate case 0: 5147c478bd9Sstevel@tonic-gate break; 5157c478bd9Sstevel@tonic-gate case 1: 5167c478bd9Sstevel@tonic-gate if (res != 0) 5177c478bd9Sstevel@tonic-gate res += loc; 5187c478bd9Sstevel@tonic-gate break; 5197c478bd9Sstevel@tonic-gate default: 5207c478bd9Sstevel@tonic-gate /* remainder not implemented */ 5217c478bd9Sstevel@tonic-gate break; 5227c478bd9Sstevel@tonic-gate } 5237c478bd9Sstevel@tonic-gate return (res); 5247c478bd9Sstevel@tonic-gate } 5257c478bd9Sstevel@tonic-gate 5267c478bd9Sstevel@tonic-gate 5277c478bd9Sstevel@tonic-gate int interpret_op(void **datap, ptrdiff_t reloc, 5287c478bd9Sstevel@tonic-gate uint64_t *reached_pc_p, uint64_t pc, 5297c478bd9Sstevel@tonic-gate struct register_state f_state[], 5307c478bd9Sstevel@tonic-gate struct register_state f_start_state[], 5317c478bd9Sstevel@tonic-gate int daf, int caf, int enc); 5327c478bd9Sstevel@tonic-gate 5337c478bd9Sstevel@tonic-gate uint64_t 5347c478bd9Sstevel@tonic-gate interpret_ops(void *data, void *data_end, 5357c478bd9Sstevel@tonic-gate ptrdiff_t reloc, 5367c478bd9Sstevel@tonic-gate uint64_t start_pc, uint64_t pc, 5377c478bd9Sstevel@tonic-gate struct register_state f_state[], 5387c478bd9Sstevel@tonic-gate struct register_state f_start_state[], 5397c478bd9Sstevel@tonic-gate int daf, int caf, int enc) 5407c478bd9Sstevel@tonic-gate { 5417c478bd9Sstevel@tonic-gate void *d = data; 5427c478bd9Sstevel@tonic-gate uint64_t reached_pc = start_pc; 5437c478bd9Sstevel@tonic-gate 5447c478bd9Sstevel@tonic-gate while (d < data_end) { 5457c478bd9Sstevel@tonic-gate if (interpret_op(&d, reloc, &reached_pc, pc, 5467c478bd9Sstevel@tonic-gate f_state, f_start_state, daf, caf, enc)) 5477c478bd9Sstevel@tonic-gate break; 5487c478bd9Sstevel@tonic-gate } 5497c478bd9Sstevel@tonic-gate return (reached_pc); 5507c478bd9Sstevel@tonic-gate } 5517c478bd9Sstevel@tonic-gate 5527c478bd9Sstevel@tonic-gate int 5537c478bd9Sstevel@tonic-gate interpret_op(void **datap, ptrdiff_t reloc, 5547c478bd9Sstevel@tonic-gate uint64_t *reached_pc_p, uint64_t pc, 5557c478bd9Sstevel@tonic-gate struct register_state f_state[], 5567c478bd9Sstevel@tonic-gate struct register_state f_start_state[], 5577c478bd9Sstevel@tonic-gate int daf, int caf, int enc) 5587c478bd9Sstevel@tonic-gate { 5597c478bd9Sstevel@tonic-gate enum CFA_ops op = separate_op(datap); 5607c478bd9Sstevel@tonic-gate enum operand_desc opr1 = (cfa_operations[op]).op1; 5617c478bd9Sstevel@tonic-gate enum operand_desc opr2 = (cfa_operations[op]).op2; 5627c478bd9Sstevel@tonic-gate 5637c478bd9Sstevel@tonic-gate uint64_t val1 = _Unw_get_val(datap, reloc, opr1, daf, caf, enc); 5647c478bd9Sstevel@tonic-gate uint64_t val2 = _Unw_get_val(datap, reloc, opr2, daf, caf, enc); 5657c478bd9Sstevel@tonic-gate if ((opr1 == ULEB128_SREG && val1 == BAD_REG) || 5667c478bd9Sstevel@tonic-gate (opr2 == ULEB128_SREG && val2 == BAD_REG)) 5677c478bd9Sstevel@tonic-gate return (0); 5687c478bd9Sstevel@tonic-gate switch (op) { 5697c478bd9Sstevel@tonic-gate case DW_CFA_nop: 5707c478bd9Sstevel@tonic-gate break; 5717c478bd9Sstevel@tonic-gate case DW_CFA_set_loc: 5727c478bd9Sstevel@tonic-gate if (val1 > pc) 5737c478bd9Sstevel@tonic-gate return (1); 5747c478bd9Sstevel@tonic-gate *reached_pc_p = val1; 5757c478bd9Sstevel@tonic-gate break; 5767c478bd9Sstevel@tonic-gate case DW_CFA_advance_loc1: 5777c478bd9Sstevel@tonic-gate case DW_CFA_advance_loc2: 5787c478bd9Sstevel@tonic-gate case DW_CFA_advance_loc4: 5797c478bd9Sstevel@tonic-gate if (*reached_pc_p + val1 > pc) 5807c478bd9Sstevel@tonic-gate return (1); 5817c478bd9Sstevel@tonic-gate *reached_pc_p += val1; 5827c478bd9Sstevel@tonic-gate break; 5837c478bd9Sstevel@tonic-gate case DW_CFA_offset_extended: 5847c478bd9Sstevel@tonic-gate f_state[val1].rule = offset_rule; 5857c478bd9Sstevel@tonic-gate f_state[val1].source_reg = CF_ADDR; 5867c478bd9Sstevel@tonic-gate f_state[val1].offset = val2; 5877c478bd9Sstevel@tonic-gate break; 5887c478bd9Sstevel@tonic-gate case DW_CFA_restore_extended: 5897c478bd9Sstevel@tonic-gate if (f_start_state != 0) 5907c478bd9Sstevel@tonic-gate f_state[val1] = f_start_state[val1]; 5917c478bd9Sstevel@tonic-gate break; 5927c478bd9Sstevel@tonic-gate case DW_CFA_undefined: 5937c478bd9Sstevel@tonic-gate f_state[val1].rule = undefined_rule; 5947c478bd9Sstevel@tonic-gate break; 5957c478bd9Sstevel@tonic-gate case DW_CFA_same_value: 5967c478bd9Sstevel@tonic-gate f_state[val1].rule = same_value_rule; 5977c478bd9Sstevel@tonic-gate break; 5987c478bd9Sstevel@tonic-gate case DW_CFA_register: 5997c478bd9Sstevel@tonic-gate f_state[val1].rule = register_rule; 6007c478bd9Sstevel@tonic-gate f_state[val1].source_reg = val2; 6017c478bd9Sstevel@tonic-gate f_state[val1].offset = 0; 6027c478bd9Sstevel@tonic-gate break; 6037c478bd9Sstevel@tonic-gate case DW_CFA_remember_state: 6047c478bd9Sstevel@tonic-gate break; 6057c478bd9Sstevel@tonic-gate case DW_CFA_restore_state: 6067c478bd9Sstevel@tonic-gate break; 6077c478bd9Sstevel@tonic-gate case DW_CFA_def_cfa: 6087c478bd9Sstevel@tonic-gate f_state[CF_ADDR].rule = register_rule; 6097c478bd9Sstevel@tonic-gate f_state[CF_ADDR].source_reg = val1; 6107c478bd9Sstevel@tonic-gate f_state[CF_ADDR].offset = val2; 6117c478bd9Sstevel@tonic-gate break; 6127c478bd9Sstevel@tonic-gate case DW_CFA_def_cfa_register: 6137c478bd9Sstevel@tonic-gate f_state[CF_ADDR].source_reg = val1; 6147c478bd9Sstevel@tonic-gate break; 6157c478bd9Sstevel@tonic-gate case DW_CFA_def_cfa_offset: 6167c478bd9Sstevel@tonic-gate f_state[CF_ADDR].offset = val1; 6177c478bd9Sstevel@tonic-gate break; 6187c478bd9Sstevel@tonic-gate case DW_CFA_def_cfa_expression: 6197c478bd9Sstevel@tonic-gate break; 6207c478bd9Sstevel@tonic-gate case DW_CFA_expression: 6217c478bd9Sstevel@tonic-gate break; 6227c478bd9Sstevel@tonic-gate case DW_CFA_offset_extended_sf: 6237c478bd9Sstevel@tonic-gate f_state[val1].rule = offset_rule; 6247c478bd9Sstevel@tonic-gate f_state[val1].source_reg = CF_ADDR; 6257c478bd9Sstevel@tonic-gate f_state[val1].offset = val2; 6267c478bd9Sstevel@tonic-gate break; 6277c478bd9Sstevel@tonic-gate case DW_CFA_def_cfa_sf: 6287c478bd9Sstevel@tonic-gate f_state[CF_ADDR].rule = register_rule; 6297c478bd9Sstevel@tonic-gate f_state[CF_ADDR].source_reg = val1; 6307c478bd9Sstevel@tonic-gate f_state[CF_ADDR].offset = val2; 6317c478bd9Sstevel@tonic-gate break; 6327c478bd9Sstevel@tonic-gate case DW_CFA_def_cfa_offset_sf: 6337c478bd9Sstevel@tonic-gate f_state[CF_ADDR].offset = val1; 6347c478bd9Sstevel@tonic-gate break; 6357c478bd9Sstevel@tonic-gate case DW_CFA_SUNW_advance_loc: 6367c478bd9Sstevel@tonic-gate if (*reached_pc_p + val1 > pc) 6377c478bd9Sstevel@tonic-gate return (1); 6387c478bd9Sstevel@tonic-gate *reached_pc_p += val1; 6397c478bd9Sstevel@tonic-gate break; 6407c478bd9Sstevel@tonic-gate case DW_CFA_SUNW_offset: 6417c478bd9Sstevel@tonic-gate f_state[val1].rule = offset_rule; 6427c478bd9Sstevel@tonic-gate f_state[val1].source_reg = CF_ADDR; 6437c478bd9Sstevel@tonic-gate f_state[val1].offset = val2; 6447c478bd9Sstevel@tonic-gate break; 6457c478bd9Sstevel@tonic-gate case DW_CFA_SUNW_restore: 6467c478bd9Sstevel@tonic-gate if (f_start_state != 0) 6477c478bd9Sstevel@tonic-gate f_state[val1] = f_start_state[val1]; 6487c478bd9Sstevel@tonic-gate break; 6497c478bd9Sstevel@tonic-gate } 6507c478bd9Sstevel@tonic-gate return (0); 6517c478bd9Sstevel@tonic-gate } 652