Lines Matching refs:cfi

264 static void init_cfi_state(struct cfi_state *cfi)  in init_cfi_state()  argument
269 cfi->regs[i].base = CFI_UNDEFINED; in init_cfi_state()
270 cfi->vals[i].base = CFI_UNDEFINED; in init_cfi_state()
272 cfi->cfa.base = CFI_UNDEFINED; in init_cfi_state()
273 cfi->drap_reg = CFI_UNDEFINED; in init_cfi_state()
274 cfi->drap_offset = -1; in init_cfi_state()
281 init_cfi_state(&state->cfi); in init_insn_state()
294 struct cfi_state *cfi = calloc(sizeof(struct cfi_state), 1); in cfi_alloc() local
295 if (!cfi) { in cfi_alloc()
300 return cfi; in cfi_alloc()
313 static inline u32 cfi_key(struct cfi_state *cfi) in cfi_key() argument
315 return jhash((void *)cfi + sizeof(cfi->hash), in cfi_key()
316 sizeof(*cfi) - sizeof(cfi->hash), 0); in cfi_key()
319 static struct cfi_state *cfi_hash_find_or_add(struct cfi_state *cfi) in cfi_hash_find_or_add() argument
321 struct hlist_head *head = &cfi_hash[hash_min(cfi_key(cfi), cfi_bits)]; in cfi_hash_find_or_add()
325 if (!cficmp(cfi, obj)) { in cfi_hash_find_or_add()
332 *obj = *cfi; in cfi_hash_find_or_add()
338 static void cfi_hash_add(struct cfi_state *cfi) in cfi_hash_add() argument
340 struct hlist_head *head = &cfi_hash[hash_min(cfi_key(cfi), cfi_bits)]; in cfi_hash_add()
342 hlist_add_head(&cfi->hash, head); in cfi_hash_add()
1744 orig_alt_group->cfi = calloc(special_alt->orig_len, in handle_group_alt()
1746 if (!orig_alt_group->cfi) { in handle_group_alt()
1866 new_alt_group->cfi = orig_alt_group->cfi; in handle_group_alt()
2206 struct cfi_state cfi = init_cfi; in read_unwind_hints() local
2247 insn->cfi = &force_undefined_cfi; in read_unwind_hints()
2273 insn->cfi = &func_cfi; in read_unwind_hints()
2277 if (insn->cfi) in read_unwind_hints()
2278 cfi = *(insn->cfi); in read_unwind_hints()
2280 if (arch_decode_hint_reg(hint->sp_reg, &cfi.cfa.base)) { in read_unwind_hints()
2285 cfi.cfa.offset = bswap_if_needed(file->elf, hint->sp_offset); in read_unwind_hints()
2286 cfi.type = hint->type; in read_unwind_hints()
2287 cfi.signal = hint->signal; in read_unwind_hints()
2289 insn->cfi = cfi_hash_find_or_add(&cfi); in read_unwind_hints()
2670 struct cfi_state *cfi = &state->cfi; in has_modified_stack_frame() local
2673 if (cfi->cfa.base != initial_func_cfi.cfa.base || cfi->drap) in has_modified_stack_frame()
2676 if (cfi->cfa.offset != initial_func_cfi.cfa.offset) in has_modified_stack_frame()
2679 if (cfi->stack_size != initial_func_cfi.cfa.offset) in has_modified_stack_frame()
2683 if (cfi->regs[i].base != initial_func_cfi.regs[i].base || in has_modified_stack_frame()
2684 cfi->regs[i].offset != initial_func_cfi.regs[i].offset) in has_modified_stack_frame()
2700 struct cfi_state *cfi = &state->cfi; in has_valid_stack_frame() local
2702 if (cfi->cfa.base == CFI_BP && in has_valid_stack_frame()
2703 check_reg_frame_pos(&cfi->regs[CFI_BP], -cfi->cfa.offset) && in has_valid_stack_frame()
2704 check_reg_frame_pos(&cfi->regs[CFI_RA], -cfi->cfa.offset + 8)) in has_valid_stack_frame()
2707 if (cfi->drap && cfi->regs[CFI_BP].base == CFI_BP) in has_valid_stack_frame()
2714 struct cfi_state *cfi, in update_cfi_state_regs() argument
2717 struct cfi_reg *cfa = &cfi->cfa; in update_cfi_state_regs()
2738 static void save_reg(struct cfi_state *cfi, unsigned char reg, int base, int offset) in save_reg() argument
2741 cfi->regs[reg].base == CFI_UNDEFINED) { in save_reg()
2742 cfi->regs[reg].base = base; in save_reg()
2743 cfi->regs[reg].offset = offset; in save_reg()
2747 static void restore_reg(struct cfi_state *cfi, unsigned char reg) in restore_reg() argument
2749 cfi->regs[reg].base = initial_func_cfi.regs[reg].base; in restore_reg()
2750 cfi->regs[reg].offset = initial_func_cfi.regs[reg].offset; in restore_reg()
2808 struct cfi_state *cfi, struct stack_op *op) in update_cfi_state() argument
2810 struct cfi_reg *cfa = &cfi->cfa; in update_cfi_state()
2811 struct cfi_reg *regs = cfi->regs; in update_cfi_state()
2814 if (cfi->force_undefined) in update_cfi_state()
2826 if (cfi->type == UNWIND_HINT_TYPE_REGS || in update_cfi_state()
2827 cfi->type == UNWIND_HINT_TYPE_REGS_PARTIAL) in update_cfi_state()
2828 return update_cfi_state_regs(insn, cfi, op); in update_cfi_state()
2842 cfi->bp_scratch = false; in update_cfi_state()
2846 op->dest.reg == CFI_BP && cfi->drap) { in update_cfi_state()
2850 regs[CFI_BP].offset = -cfi->stack_size; in update_cfi_state()
2851 cfi->bp_scratch = false; in update_cfi_state()
2866 cfi->vals[op->dest.reg].base = CFI_CFA; in update_cfi_state()
2867 cfi->vals[op->dest.reg].offset = -cfi->stack_size; in update_cfi_state()
2871 (cfa->base == CFI_BP || cfa->base == cfi->drap_reg)) { in update_cfi_state()
2878 cfi->stack_size = -cfi->regs[CFI_BP].offset; in update_cfi_state()
2885 cfi->vals[op->src.reg].base == CFI_CFA) { in update_cfi_state()
2895 cfa->offset = -cfi->vals[op->src.reg].offset; in update_cfi_state()
2896 cfi->stack_size = cfa->offset; in update_cfi_state()
2899 cfi->vals[op->src.reg].base == CFI_SP_INDIRECT && in update_cfi_state()
2900 cfi->vals[op->src.reg].offset == cfa->offset) { in update_cfi_state()
2937 cfi->vals[op->src.reg].base == CFI_SP_INDIRECT && in update_cfi_state()
2938 cfi->vals[op->src.reg].offset == cfa->offset) { in update_cfi_state()
2946 cfi->stack_size += 8; in update_cfi_state()
2956 cfi->stack_size -= op->src.offset; in update_cfi_state()
2965 cfi->stack_size = -(op->src.offset + regs[CFI_BP].offset); in update_cfi_state()
2972 cfi->drap_reg = op->dest.reg; in update_cfi_state()
2984 cfi->vals[op->dest.reg].base = CFI_CFA; in update_cfi_state()
2985 cfi->vals[op->dest.reg].offset = \ in update_cfi_state()
2986 -cfi->stack_size + op->src.offset; in update_cfi_state()
2991 if (cfi->drap && op->dest.reg == CFI_SP && in update_cfi_state()
2992 op->src.reg == cfi->drap_reg) { in update_cfi_state()
2996 cfa->offset = cfi->stack_size = -op->src.offset; in update_cfi_state()
2997 cfi->drap_reg = CFI_UNDEFINED; in update_cfi_state()
2998 cfi->drap = false; in update_cfi_state()
3002 if (op->dest.reg == cfi->cfa.base && !(next_insn && next_insn->hint)) { in update_cfi_state()
3011 (cfi->drap_reg != CFI_UNDEFINED && cfa->base != CFI_SP) || in update_cfi_state()
3012 (cfi->drap_reg == CFI_UNDEFINED && cfa->base != CFI_BP)) { in update_cfi_state()
3017 if (cfi->drap_reg != CFI_UNDEFINED) { in update_cfi_state()
3019 cfa->base = cfi->drap_reg; in update_cfi_state()
3020 cfa->offset = cfi->stack_size = 0; in update_cfi_state()
3021 cfi->drap = true; in update_cfi_state()
3040 if (!cfi->drap && op->dest.reg == cfa->base) { in update_cfi_state()
3046 if (cfi->drap && cfa->base == CFI_BP_INDIRECT && in update_cfi_state()
3047 op->dest.reg == cfi->drap_reg && in update_cfi_state()
3048 cfi->drap_offset == -cfi->stack_size) { in update_cfi_state()
3051 cfa->base = cfi->drap_reg; in update_cfi_state()
3053 cfi->drap_offset = -1; in update_cfi_state()
3055 } else if (cfi->stack_size == -regs[op->dest.reg].offset) { in update_cfi_state()
3058 restore_reg(cfi, op->dest.reg); in update_cfi_state()
3061 cfi->stack_size -= 8; in update_cfi_state()
3068 if (!cfi->drap && op->dest.reg == cfa->base && in update_cfi_state()
3073 cfa->offset = cfi->stack_size; in update_cfi_state()
3076 if (cfi->drap && op->src.reg == CFI_BP && in update_cfi_state()
3077 op->src.offset == cfi->drap_offset) { in update_cfi_state()
3080 cfa->base = cfi->drap_reg; in update_cfi_state()
3082 cfi->drap_offset = -1; in update_cfi_state()
3085 if (cfi->drap && op->src.reg == CFI_BP && in update_cfi_state()
3089 restore_reg(cfi, op->dest.reg); in update_cfi_state()
3096 restore_reg(cfi, op->dest.reg); in update_cfi_state()
3099 op->src.offset == regs[op->dest.reg].offset + cfi->stack_size) { in update_cfi_state()
3102 restore_reg(cfi, op->dest.reg); in update_cfi_state()
3116 cfi->stack_size += 8; in update_cfi_state()
3123 if (cfi->drap) { in update_cfi_state()
3124 if (op->src.reg == cfa->base && op->src.reg == cfi->drap_reg) { in update_cfi_state()
3128 cfa->offset = -cfi->stack_size; in update_cfi_state()
3131 cfi->drap_offset = -cfi->stack_size; in update_cfi_state()
3133 } else if (op->src.reg == CFI_BP && cfa->base == cfi->drap_reg) { in update_cfi_state()
3136 cfi->stack_size = 0; in update_cfi_state()
3141 save_reg(cfi, op->src.reg, CFI_BP, -cfi->stack_size); in update_cfi_state()
3147 save_reg(cfi, op->src.reg, CFI_CFA, -cfi->stack_size); in update_cfi_state()
3153 cfi->bp_scratch = true; in update_cfi_state()
3158 if (cfi->drap) { in update_cfi_state()
3159 if (op->src.reg == cfa->base && op->src.reg == cfi->drap_reg) { in update_cfi_state()
3166 cfi->drap_offset = op->dest.offset; in update_cfi_state()
3170 save_reg(cfi, op->src.reg, CFI_BP, op->dest.offset); in update_cfi_state()
3177 save_reg(cfi, op->src.reg, CFI_CFA, in update_cfi_state()
3178 op->dest.offset - cfi->cfa.offset); in update_cfi_state()
3183 save_reg(cfi, op->src.reg, CFI_CFA, in update_cfi_state()
3184 op->dest.offset - cfi->stack_size); in update_cfi_state()
3189 cfi->vals[op->dest.reg].base = CFI_SP_INDIRECT; in update_cfi_state()
3190 cfi->vals[op->dest.reg].offset = cfa->offset; in update_cfi_state()
3202 cfi->stack_size -= 8; in update_cfi_state()
3233 if (!insn->cfi) { in propagate_alt_cfi()
3238 alt_cfi = insn->alt_group->cfi; in propagate_alt_cfi()
3242 alt_cfi[group_off] = insn->cfi; in propagate_alt_cfi()
3244 if (cficmp(alt_cfi[group_off], insn->cfi)) { in propagate_alt_cfi()
3265 if (update_cfi_state(insn, next_insn, &state->cfi, op)) in handle_insn_ops()
3297 struct cfi_state *cfi1 = insn->cfi; in insn_cfi_match()
3496 if (state->cfi.bp_scratch) { in validate_return()
3575 if (!insn->hint && !insn_cfi_match(insn, &state.cfi)) in validate_branch()
3611 insn->cfi = save_insn->cfi; in validate_branch()
3615 state.cfi = *insn->cfi; in validate_branch()
3619 if (prev_insn && !cficmp(prev_insn->cfi, &state.cfi)) { in validate_branch()
3620 insn->cfi = prev_insn->cfi; in validate_branch()
3623 insn->cfi = cfi_hash_find_or_add(&state.cfi); in validate_branch()
3765 if (state.cfi.cfa.base == CFI_UNDEFINED) in validate_branch()
4107 struct cfi_state *cfi; in add_prefix_symbol() local
4136 if (!insn->cfi) { in add_prefix_symbol()
4145 cfi = cfi_hash_find_or_add(insn->cfi); in add_prefix_symbol()
4147 prev->cfi = cfi; in add_prefix_symbol()
4209 set_func_state(&state.cfi); in validate_section()
4750 if (opts.cfi) { in check()